MaxChangeSet implements CrdtAddRemoveSet<ElementType, Set<ElementType>, MaxChangeSet<ElementType>> { @Override public Set<ElementType> value(){ return struct.entrySet().stream() .filter(entry -> (entry.getValue() % 2 == 1)) .map(Map.Entry::getKey) .collect(Collectors.toSet()); } MaxChangeSet(); @SafeVarargs  MaxChangeSet(ElementType... elements);  MaxChangeSet(Set<ElementType> set);  MaxChangeSet(MaxChangeSet<ElementType> first, MaxChangeSet<ElementType> second);   MaxChangeSet(Map<ElementType, Integer> struct); MaxChangeSet<ElementType> add(ElementType e); MaxChangeSet<ElementType> remove(ElementType e); @Override MaxChangeSet<ElementType> merge(MaxChangeSet<ElementType> other); @Override Set<ElementType> value(); @Override MaxChangeSet<ElementType> optimize(); @Override boolean equals(Object obj);  }
@Test public void valueTest(){ Map<Character, Integer> struct = new HashMap<>(); struct.put('a', 0); struct.put('b', 1); struct.put('c', 2); struct.put('d', 3); Set<Character> result = new HashSet<>(); result.add('b'); result.add('d'); Assert.assertEquals(new MaxChangeSet<>(struct).value(), result); }