E
- the type of an element in the setspublic final class Diff<E> extends Object
added
, removed
, and unchanged
elements) is
computed against the first set.
Example of usage:
Set<Integer> set1 = ... // { 1, 3, <strong>5</strong>, <strong>7</strong> } Set<Integer> set2 = ... // { <strong>5</strong>, 6, <strong>7</strong>, 8, 9 } <strong>Diff<</strong>Integer<strong>> diff</strong> = <strong>Diff.of(</strong>set1, set2<strong>)</strong>; Set<Integer> added = <strong>diff.added()</strong> // { 6, 8, 9 } Set<Integer> removed = <strong>diff.removed()</strong> // { 1, 3 } Set<Integer> unchanged = <strong>diff.unchanged()</strong> // { 5, 7 } // set2 == set1 + added - removed
Modifier and Type | Method and Description |
---|---|
Set<? extends E> |
added()
Returns the set of elements that are missing in the first set, but are
present in the second set (they need to be added into the first set).
|
static <E> Diff<E> |
of(Set<? extends E> set1,
Set<? extends E> set2)
|
Set<? extends E> |
removed()
Returns the set of elements that are present in the first set, but are
missing in the second set (they need to be removed from the first set).
|
Set<? extends E> |
unchanged()
Returns the set of elements that exist in both sets being compared.
|
public Set<? extends E> added()
public Set<? extends E> removed()
Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.