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