Java Code Examples for org.osgl.util.C#newMap()

The following examples show how to use org.osgl.util.C#newMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EndpointTester.java    From actframework with Apache License 2.0 6 votes vote down vote up
protected Map<String, Object> prepareJsonData(List<$.T2<String, Object>> params) {
    Map<String, Object> map = C.newMap();
    if (null != params) {
        for ($.T2<String, Object> pair : params) {
            String key = pair._1;
            Object val = pair._2;
            if (map.containsKey(key)) {
                List list;
                Object x = map.get(key);
                if (x instanceof List) {
                    list = $.cast(x);
                } else {
                    list = C.newList(x);
                    map.put(key, list);
                }
                list.add(val);
            } else {
                map.put(key, val);
            }
        }
    }
    return map;
}
 
Example 2
Source File: Module.java    From java-di with Apache License 2.0 5 votes vote down vote up
private void validate(Genie genie) {
    Map<Object, Binder> map = C.newMap();
    for (Binder<?> binder : binders) {
        Object spec = binder.beanSpec(genie);
        if (map.containsKey(spec)) {
            throw E.invalidConfiguration("Duplicate bean spec found: ", spec);
        }
        map.put(spec, binder);
    }
}
 
Example 3
Source File: UploadFileStorageService.java    From actframework with Apache License 2.0 5 votes vote down vote up
public static UploadFileStorageService create(App app) {
    File tmp = app.tmpDir();
    if (!tmp.exists() && !tmp.mkdirs()) {
        throw E.unexpected("Cannot create tmp dir");
    }
    Map<String, String> conf = C.newMap("storage.fs.home.dir", Files.file(app.tmpDir(), "uploads").getAbsolutePath(),
            "storage.keygen", KeyGenerator.Predefined.BY_DATE.name());
    conf.put(IStorageService.CONF_ID, "__upload");
    conf.put("storage.storeSuffix", "false");
    return new UploadFileStorageService(conf, app.config().uploadInMemoryCacheThreshold());
}
 
Example 4
Source File: SimpleTypeMapValBindingTestBase.java    From actframework with Apache License 2.0 5 votes vote down vote up
protected static <T> Map<T, String> flip(Map<String, T> map) {
    Map ret = C.newMap();
    for (Map.Entry<String, T> entry : map.entrySet()) {
        ret.put(entry.getValue(), entry.getKey());
    }
    return ret;
}
 
Example 5
Source File: Gh78.java    From java-tool with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    Map<String, String> from = C.Map("name", "Tom");
    Map<String, String> to = C.newMap();
    $.map(from).to(to);
    eq(1, to.size());
    eq("Tom", to.get("name"));
}
 
Example 6
Source File: OsglMapProvider.java    From java-di with Apache License 2.0 4 votes vote down vote up
@Override
public C.Map<?, ?> get() {
    return C.newMap();
}
 
Example 7
Source File: ConfigKeyHelperTest.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Before
public void prepare() {
    conf = C.newMap((Map)System.getProperties());
    conf.putAll(System.getenv());
}
 
Example 8
Source File: EndpointTester.java    From actframework with Apache License 2.0 4 votes vote down vote up
protected Map<String, Object> prepareJsonData(String key, Object val, Object ... otherPairs) {
    Map<String, Object> params = C.newMap(key, val);
    Map<String, Object> otherParams = C.Map(otherPairs);
    params.putAll(otherParams);
    return params;
}