Java Code Examples for io.vavr.collection.HashMap#ofEntries()

The following examples show how to use io.vavr.collection.HashMap#ofEntries() . 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: ParameterizedPojoTest.java    From vavr-jackson with Apache License 2.0 5 votes vote down vote up
@Test
void testHashMapOfString() throws Exception {
    Integer src00 = 1;
    String src01 = "A";
    Tuple2<Integer, String> src0 = Tuple.of(src00, src01);
    HashMap<Integer, String> src = HashMap.ofEntries(src0);
    String json = MAPPER.writeValueAsString(new ParameterizedHashMapPojo<>(src));
    Assertions.assertEquals(json, "{\"value\":{\"1\":\"A\"}}");
    ParameterizedHashMapPojo<java.lang.Integer, java.lang.String> restored =
            MAPPER.readValue(json, new TypeReference<ParameterizedHashMapPojo<java.lang.Integer, java.lang.String>>(){});
    Assertions.assertEquals(src, restored.getValue());
}
 
Example 2
Source File: ParameterizedPojoTest.java    From vavr-jackson with Apache License 2.0 5 votes vote down vote up
@Test
void testHashMapOfTuple() throws Exception {
    Integer src00 = 1;
    String src010 = "A";
    String src011 = "B";
    Tuple2<String, String> src01 = Tuple.of(src010, src011);
    Tuple2<Integer, Tuple2<String, String>> src0 = Tuple.of(src00, src01);
    HashMap<Integer, Tuple2<String, String>> src = HashMap.ofEntries(src0);
    String json = MAPPER.writeValueAsString(new ParameterizedHashMapPojo<>(src));
    Assertions.assertEquals(json, "{\"value\":{\"1\":[\"A\",\"B\"]}}");
    ParameterizedHashMapPojo<java.lang.Integer, io.vavr.Tuple2<java.lang.String, java.lang.String>> restored =
            MAPPER.readValue(json, new TypeReference<ParameterizedHashMapPojo<java.lang.Integer, io.vavr.Tuple2<java.lang.String, java.lang.String>>>(){});
    Assertions.assertEquals(src, restored.getValue());
}
 
Example 3
Source File: SimplePojoTest.java    From vavr-jackson with Apache License 2.0 5 votes vote down vote up
@Test
void testHashMapOfString() throws Exception {
    Integer src00 = 1;
    String src01 = "A";
    Tuple2<Integer, String> src0 = Tuple.of(src00, src01);
    HashMap<Integer, String> src = HashMap.ofEntries(src0);
    String json = MAPPER.writeValueAsString(new HashMapOfString().setValue(src));
    Assertions.assertEquals(json, "{\"value\":{\"1\":\"A\"}}");
    HashMapOfString restored = MAPPER.readValue(json, HashMapOfString.class);
    Assertions.assertEquals(src, restored.getValue());
}
 
Example 4
Source File: SimplePojoTest.java    From vavr-jackson with Apache License 2.0 5 votes vote down vote up
@Test
void testHashMapOfTuple() throws Exception {
    Integer src00 = 1;
    String src010 = "A";
    String src011 = "B";
    Tuple2<String, String> src01 = Tuple.of(src010, src011);
    Tuple2<Integer, Tuple2<String, String>> src0 = Tuple.of(src00, src01);
    HashMap<Integer, Tuple2<String, String>> src = HashMap.ofEntries(src0);
    String json = MAPPER.writeValueAsString(new HashMapOfTuple().setValue(src));
    Assertions.assertEquals(json, "{\"value\":{\"1\":[\"A\",\"B\"]}}");
    HashMapOfTuple restored = MAPPER.readValue(json, HashMapOfTuple.class);
    Assertions.assertEquals(src, restored.getValue());
}