Package org.apache.wayang.core.util
Class WayangCollections
java.lang.Object
org.apache.wayang.core.util.WayangCollections
Utilities to operate
Collections.-
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends Collection<T>,T>
Cadd(C collection, T element) Adds an element to aCollectionand returns theCollection.static <T,C extends Collection<T>>
CaddAll(C collection, C elements) Adds elements to aCollectionand returns theCollection.static <T,C extends Collection<T>>
CasCollection(Iterable<T> iterable, Supplier<C> collectionFactory) Provides the giveniterableasCollection.static <T> List<T>asList(Collection<T> collection) static <T> Set<T>static <T> Set<T>asSet(Collection<T> collection) static <T> Set<T>asSet(T... values) Provides the givenvaluesasSet.static <K,V> Map<K, V> static <T> ArrayList<T>createNullFilledArrayList(int k) static <T> Collection<List<T>>createPowerList(Collection<T> base) Creates the power list of the givenbase(akin to power sets of sets).static <T> Collection<List<T>>createPowerList(Collection<T> base, int maxElements) Creates the power list of the givenbase(akin to power sets of sets).static <T> TReturn any element from theiterable.static <T> Optional<T>getAnyOptional(Iterable<T> iterable) Return any element from theiterableif it exists.static <T> TgetSingle(Collection<T> collection) Validate that there is only a single element in thecollectionand return it.static <T> TgetSingleOrNull(Collection<T> collection) Validate that there is at most one element in thecollectionand return it (ornullotherwise).static <S,T> List<T> map(List<S> list, BiFunction<Integer, S, T> mapFunction) Return a newListwith mapped values.static <S,T> List<T> Return a newListwith mapped values.static <K,V> void put(Map<K, Collection<V>> map, K key, V value) streamedCrossProduct(List<? extends Iterable<T>> iterables) Returns anIterablethat iterates the cross product of the giveniterables.
-
Method Details
-
put
-
asSet
-
asSet
-
asSet
Provides the givenvaluesasSet. -
asList
-
asCollection
public static <T,C extends Collection<T>> C asCollection(Iterable<T> iterable, Supplier<C> collectionFactory) Provides the giveniterableasCollection. -
getSingle
Validate that there is only a single element in thecollectionand return it. -
getSingleOrNull
Validate that there is at most one element in thecollectionand return it (ornullotherwise). -
getAny
Return any element from theiterable. -
getAnyOptional
Return any element from theiterableif it exists. -
add
Adds an element to aCollectionand returns theCollection.- Parameters:
collection- to which the element should be addedelement- that should be added to thecollection- Returns:
- the
collection
-
addAll
Adds elements to aCollectionand returns theCollection.- Parameters:
collection- to which the element should be addedelements- that should be added to thecollection- Returns:
- the
collection
-
map
Return a newListwith mapped values. -
map
Return a newListwith mapped values. -
streamedCrossProduct
Returns anIterablethat iterates the cross product of the giveniterables.- Parameters:
iterables- should be iterable multiple times
-
createNullFilledArrayList
-
createPowerList
Creates the power list of the givenbase(akin to power sets of sets). -
createPowerList
Creates the power list of the givenbase(akin to power sets of sets).- Parameters:
maxElements- maximum number of elements in theLists in the power list
-
createMap
-