Class IdentityUtils
- java.lang.Object
-
- com.hybris.cockpitng.core.util.impl.IdentityUtils
-
public final class IdentityUtils extends java.lang.ObjectSet of tools that allows to identify instance duplicates in different collection-related objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIdentityUtils.DistinctCollection<E>Collection that contains only single copy of each instance.static classIdentityUtils.DistinctFilter<E>Filter that returns true only for the first time specified element is tested.static classIdentityUtils.DistinctSpliterator<T>A wrapping spliterator that only reports distinct elements instances of the underlying spliterator.static classIdentityUtils.Wrapper<E>An object that wraps any other in the way, thatIdentityUtils.Wrapper.equals(Object)andIdentityUtils.Wrapper.hashCode()depends only on wrapped object's instance.static classIdentityUtils.WrapperIterator<E>Iterator to iterate over elements while having iterator of their wrapped instances.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> java.util.stream.Collector<E,?,java.util.Collection<E>>distinctCollector()Creates a collector for stream to return a collection with no duplicated instance.static <E> java.util.stream.Collector<E,?,java.util.Collection<E>>distinctCollector(int initialCapacity)Creates a collector for stream to return a collection with no duplicated instance.static <E> voidremoveDuplicates(java.util.Collection<E> collection)Iterates over provided collection and removes all duplicated instances.
-
-
-
Method Detail
-
removeDuplicates
public static <E> void removeDuplicates(java.util.Collection<E> collection)
Iterates over provided collection and removes all duplicated instances.- Type Parameters:
E- element type- Parameters:
collection- collection to be cleared from duplicates
-
distinctCollector
public static <E> java.util.stream.Collector<E,?,java.util.Collection<E>> distinctCollector()
Creates a collector for stream to return a collection with no duplicated instance.- Type Parameters:
E- element type- Returns:
- collector
- See Also:
IdentityUtils.DistinctCollection
-
distinctCollector
public static <E> java.util.stream.Collector<E,?,java.util.Collection<E>> distinctCollector(int initialCapacity)
Creates a collector for stream to return a collection with no duplicated instance.- Type Parameters:
E- element type- Parameters:
initialCapacity- collection initial capacity- Returns:
- collector
- See Also:
IdentityUtils.DistinctCollection
-
-