TwoPhaseSet implements CrdtAddRemoveSet<ElementType, Set<ElementType>, TwoPhaseSet<ElementType>> { @Override public Set<ElementType> value(){ return added.stream().filter(e -> !removed.contains(e)).collect(Collectors.toSet()); } TwoPhaseSet(); @SafeVarargs  TwoPhaseSet(ElementType... elements);  TwoPhaseSet(Set<ElementType> set);  TwoPhaseSet(TwoPhaseSet<ElementType> first, TwoPhaseSet<ElementType> second);   TwoPhaseSet(Set<ElementType> added, Set<ElementType> removed); TwoPhaseSet<ElementType> add(ElementType e); TwoPhaseSet<ElementType> remove(ElementType e); @Override TwoPhaseSet<ElementType> merge(TwoPhaseSet<ElementType> other); @Override Set<ElementType> value(); @Override TwoPhaseSet<ElementType> optimize(); @Override boolean equals(Object obj);  }
@Test public void setConstructorTest(){ Assert.assertEquals(new TwoPhaseSet<>(sampleSet).value(), sampleSet); }
@Test public void valueTest(){ Set<Character> added = new HashSet<>(); added.add('a'); added.add('b'); Set<Character> removed = new HashSet<>(); removed.add('b'); Assert.assertEquals(new TwoPhaseSet<>(added, removed), new TwoPhaseSet<>('a')); }