當前位置: 首頁>>代碼示例>>Java>>正文


Java Maps類代碼示例

本文整理匯總了Java中io.advantageous.boon.core.Maps的典型用法代碼示例。如果您正苦於以下問題:Java Maps類的具體用法?Java Maps怎麽用?Java Maps使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Maps類屬於io.advantageous.boon.core包,在下文中一共展示了Maps類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doGetFields

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
private final Map<String, FieldAccess> doGetFields ( Class<? extends Object> aClass ) {
    Map<String, FieldAccess> fields =  Maps.copy ( Reflection.getPropertyFieldAccessMapFieldFirstForSerializer ( aClass ) );

    List<FieldAccess> removeFields = new ArrayList<>();

    for (FieldAccess field : fields.values()) {
        if (field.isWriteOnly ())  {
            removeFields.add(field);
        }
    }

    for (FieldAccess fieldAccess : removeFields) {
        fields.remove(fieldAccess.name());
    }
    return fields;
}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:17,代碼來源:JsonSimpleSerializerImpl.java

示例2: main

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
public static void main(String... args) {
    final Vertx vertx = Vertx.vertx();
    //final DnsSupport dnsSupport = new DnsSupport(new DnsSingleClientSupplier(vertx, "localhost", 5354),
    //        Maps.map("db", "dbService"), ".skydns.local");

    final DnsSupport dnsSupport = new DnsSupport(new DnsClientFromResolveConfSupplier(vertx),
            Maps.map("db", "dbService"),
            ".skydns.local");

    dnsSupport.loadServiceEndpointsByServiceName(
            CallbackBuilder.newCallbackBuilder().withListCallback(EndpointDefinition.class,
                    endpointDefinitions ->
                    {
                        endpointDefinitions.forEach(endpointDefinition ->
                                System.out.printf("%s %s %s \n", endpointDefinition.getPort(),
                                        endpointDefinition.getHost(),
                                        endpointDefinition.getId()));
                    }).withErrorHandler(Throwable::printStackTrace)
                    .build(), "dbService");

}
 
開發者ID:advantageous,項目名稱:qbit,代碼行數:22,代碼來源:IntegrationTestWithSkyDNS.java

示例3: testFromMapWithAList

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@Test
public void testFromMapWithAList() {
    List<Object> list = Lists.list( ( Object ) "Jason", 21 );
    Employee emp = fromMap( Maps.map( "name", ( Object ) "Rick", "age", 29, "boss", list ), Employee.class );
    boolean ok = emp != null || die();
    ok = emp.name != null || die();
    ok = emp.name.equals( "Rick" ) || die();
    ok = emp.age == 29 || die();

    ok = emp.boss != null || die();
    ok = emp.boss.name.equals( "Jason" ) || die();
    ok = emp.boss.age == 21 || die();

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:15,代碼來源:MapConversionTest.java

示例4: testFromMapWithAList

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@Test
public void testFromMapWithAList() {
    List<Object> list = Lists.list((Object) "Jason", 21);
    Employee emp = mapper.fromMap( Maps.map( "name",  "Rick", "age", 29, "boss", list ), Employee.class );
    ok = emp != null || die();
    ok = emp.name != null || die();
    ok = emp.name.equals( "Rick" ) || die();
    ok = emp.age == 29 || die();

    ok = emp.boss != null || die();
    ok = emp.boss.name.equals( "Jason" ) || die();
    ok = emp.boss.age == 21 || die();

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:15,代碼來源:MapperTest.java

示例5: testSendEmployeesWithCallbackMap

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@Test
public void testSendEmployeesWithCallbackMap() {

    final HttpTextResponse httpResponse = httpServerSimulator.postBody("/es/sendEmployeesWithCallbackMap",
            Maps.map("1", new Employee(1, "Rick"), "2",
                    new Employee(2, "Diana")));

    assertEquals(200, httpResponse.code());
    assertEquals("true", httpResponse.body());

}
 
開發者ID:advantageous,項目名稱:qbit,代碼行數:12,代碼來源:CollectionArrayUserDefinedObjectRESTTest.java

示例6: getEmployeesAsMap

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@Override
public void getEmployeesAsMap(final Callback<Map<String, Employee>> empMapCallback) {

    empMapCallback.returnThis(Maps.map("rick", new Employee("Rick")));
}
 
開發者ID:advantageous,項目名稱:qbit-extensions,代碼行數:6,代碼來源:EmployeeServiceImpl.java

示例7: prettyPrintBean

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
public  CharBuf prettyPrintBean(Object object) {
    final Map<String, Object> map = Maps.toPrettyMap(object);
    return prettyPrintMap(map,  0);
}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:5,代碼來源:CharBuf.java

示例8: prettyPrintBeanWithTypes

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
public  CharBuf prettyPrintBeanWithTypes(Object object) {
    final Map<String, Object> map = Maps.toMap(object);
    return prettyPrintMap(map,  0);
}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:5,代碼來源:CharBuf.java

示例9: prettyPrintObject

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
public CharBuf prettyPrintObject(Object value, boolean type, int indent) {


        TypeType instanceType = TypeType.getInstanceType(value);
        switch (instanceType) {


            case BYTE_WRAPPER:
            case SHORT_WRAPPER:
            case BOOLEAN_WRAPPER:
            case BIG_DECIMAL:
            case BIG_INT:
            case DOUBLE_WRAPPER:
            case INTEGER_WRAPPER:
            case LONG_WRAPPER:
            case NUMBER:
                add(value);
                break;

            case NULL:
                addNull();
                break;

            case MAP:
                prettyPrintMap((Map) value, indent + 2);
                break;

            case INSTANCE:
                if (type) {
                    prettyPrintMap(Maps.toMap(value), indent);
                } else {
                    prettyPrintMap(Maps.toPrettyMap(value), indent);
                }
                break;


            case COLLECTION:
            case SET:
            case LIST:
                prettyPrintCollection((Collection) value, type, indent);
                break;




            case ARRAY:
            case ARRAY_INT:
            case ARRAY_BYTE:
            case ARRAY_SHORT:
            case ARRAY_FLOAT:
            case ARRAY_DOUBLE:
            case ARRAY_LONG:
            case ARRAY_STRING:
            case ARRAY_OBJECT:
                prettyPrintCollection(Lists.list(Conversions.iterator(value)), type, indent);
                break;

            case ENUM:
                addJsonEscapedString(((Enum)value).name().toCharArray());
                break;


            default:
                addJsonEscapedString(value.toString().toCharArray());


        }

        return this;
    }
 
開發者ID:advantageous,項目名稱:boon,代碼行數:71,代碼來源:CharBuf.java

示例10: testFromMap

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@Test
public void testFromMap() throws Exception {

    final Department engineering =
            Maps.fromMap( department, Department.class );


    boolean ok = true;

    ok &= engineering.name.equals( "engineering" ) || die();

    ok &= engineering.employees.size() == 2 || die();


    final Department hr =
            Maps.fromMap( department2, Department.class );


    ok &= hr.name.equals( "hr" ) || die();

    ok &= hr.employees.size() == 3 || die();




}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:27,代碼來源:ReflectionTest.java

示例11: testWithField

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@Test
public void testWithField() {
    Employee rick = new Employee();
    String actualJson = toJson(rick);
    puts(actualJson);


    /* Convert it back to an employee. */
    Map<String, Object> fromJson = (Map<String, Object>) fromJson(actualJson);

    /* Grab the password an convert it into a HashCode. */
    String password = idxStr(fromJson, "password");
    fromJson = Maps.copy(fromJson);
    /* Convert and shove it back into the map. */
    idx(fromJson, "password", HashCode.fromString(password));

    /* Now convert the map into an Employee. */
    Employee rick2 = fromMap(fromJson, Employee.class);


    ok = rick.firstName == rick2.firstName.intern() || die();

    ok = rick.password.equals(rick2.password) || die(rick2.password);

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:26,代碼來源:Bugs231.java

示例12: test

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@Test
public void test() {
    JsonSerializerFactory factory = new JsonSerializerFactory();
    final JsonSerializer jsonSerializer = factory.includeNulls().create();

    final String json = jsonSerializer.serialize(

            Maps.map("job", "programmer",
                    "age", null,
                    "showSize", 12)
    ).toString();


    ok |= json.contains("\"age\":null") || die();


}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:18,代碼來源:Bug232.java

示例13: test

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@Test
public void test() {


    final ClassMeta<?> classMeta = ClassMeta.classMeta(Foo.class);

    ServiceMetaBuilder serviceMetaBuilder = new ServiceMetaBuilder().setRequestPaths(Lists.list("foo"));

    serviceMetaBuilder.addMethods("foo", Lists.list(classMeta.methods()));

    final Map<String, ServiceMethodMeta> serviceMethodMetaMap = Maps.toMap("name", serviceMetaBuilder.getMethods());

    final ServiceMethodMeta serviceMethodMeta = serviceMethodMetaMap.get("foo");


    assertEquals(int.class, serviceMethodMeta.getReturnType());

    final RequestMeta requestMeta = serviceMethodMeta.getRequestEndpoints().get(0);

    assertEquals("/foo", requestMeta.getRequestURI());

}
 
開發者ID:advantageous,項目名稱:qbit,代碼行數:23,代碼來源:ServiceMetaBuilderTest.java

示例14: returnMap

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@RequestMapping("/returnMap")
public Map<String, Employee> returnMap() {
    return Maps.map("1", new Employee(1, "Rick"), "2", new Employee(2, "Diana"));

}
 
開發者ID:advantageous,項目名稱:qbit,代碼行數:6,代碼來源:EmployeeServiceCollectionTestService.java

示例15: returnMapByCallback

import io.advantageous.boon.core.Maps; //導入依賴的package包/類
@RequestMapping("/returnMapByCallback")
public void returnMapByCallback(Callback<Map<String, Employee>> callback) {
    callback.resolve(Maps.map("1", new Employee(1, "Rick"), "2", new Employee(2, "Diana")));
}
 
開發者ID:advantageous,項目名稱:qbit,代碼行數:5,代碼來源:EmployeeServiceCollectionTestService.java


注:本文中的io.advantageous.boon.core.Maps類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。