本文整理汇总了Java中io.vavr.collection.HashMap.of方法的典型用法代码示例。如果您正苦于以下问题:Java HashMap.of方法的具体用法?Java HashMap.of怎么用?Java HashMap.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vavr.collection.HashMap
的用法示例。
在下文中一共展示了HashMap.of方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diff
import io.vavr.collection.HashMap; //导入方法依赖的package包/类
public static Map<Phase, Vector<Patch>> diff(Option<VNode> a, Option<VNode> b) {
if (!a.isEmpty() && b.isEmpty()) {
LOG.error("Tried to remove root node");
return HashMap.empty();
}
final Map<Phase, Vector<Patch>> patches;
if (a.isEmpty()) {
patches = b.isEmpty() ? HashMap.empty() : HashMap.of(Phase.STRUCTURE, Vector.of(new UpdateRootPatch(b.get())));
} else {
patches = doDiff(Vector.empty(), a.get(), b.get());
}
LOG.trace("Diff:\na:\n{}\nb:\n{}\nresult:\n{}", a, b, patches);
return patches;
}
示例2: testHashMap
import io.vavr.collection.HashMap; //导入方法依赖的package包/类
@Test
public void testHashMap() throws Exception {
HashMap<String, A> src = HashMap.of("a", new B("a", "b"));
String json = MAPPER.writeValueAsString(new HashMapPojo().setValue(src));
Assert.assertEquals(json, "{\"value\":{\"a\":{\"ExtFieldsPojoTest$B\":{\"a\":\"a\",\"b\":\"b\"}}}}");
HashMapPojo pojo = MAPPER.readValue(json, HashMapPojo.class);
HashMap<String, A> restored = pojo.getValue();
Assert.assertTrue(restored.get("a").get() instanceof B);
Assert.assertEquals(restored.get("a").get().a, "a");
Assert.assertEquals(((B) restored.get("a").get()).b, "b");
}
示例3: testHashMap
import io.vavr.collection.HashMap; //导入方法依赖的package包/类
@Test
public void testHashMap() throws Exception {
HashMap<String, I> src = HashMap.of("a", new A(), "b", new B());
String json = MAPPER.writeValueAsString(new HashMapPojo().setValue(src));
Assert.assertEquals(json, "{\"value\":{\"a\":{\"type\":\"a\"},\"b\":{\"type\":\"b\"}}}");
HashMapPojo pojo = MAPPER.readValue(json, HashMapPojo.class);
HashMap<String, I> restored = pojo.getValue();
Assert.assertTrue(restored.get("a").get() instanceof A);
Assert.assertTrue(restored.get("b").get() instanceof B);
}
示例4: of
import io.vavr.collection.HashMap; //导入方法依赖的package包/类
@Override
HashMap<?, ?> of(Object key, Object value) {
return HashMap.of(key, value);
}
示例5: AttributesPatch
import io.vavr.collection.HashMap; //导入方法依赖的package包/类
public AttributesPatch(Vector<Object> path, String name, VProperty property) {
this(path, HashMap.of(name, property), HashMap.empty());
}
示例6: StagesBuilder
import io.vavr.collection.HashMap; //导入方法依赖的package包/类
public StagesBuilder(Array<VNode> children) {
super(Stages.class, HashMap.of(CHILDREN, children), HashMap.empty(), HashMap.empty(), HashMap.empty());
}
示例7: testMap
import io.vavr.collection.HashMap; //导入方法依赖的package包/类
@Test
public void testMap() throws IOException {
M m = new M(HashMap.of(1, new X("a", 1), 42, new X("bbb", 42)));
json_roundtrip_test(m, M.class);
}