Class AbstractCollectionWrapper<T>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.AbstractCollectionWrapper<T>
-
- Type Parameters:
T- the element type
- All Implemented Interfaces:
java.lang.Iterable<T>,Collection<T>,IStringValueProvider,IVilGenericType,IVilType
- Direct Known Subclasses:
AbstractArrayWrapper,AbstractListWrapper,SetSet
public abstract class AbstractCollectionWrapper<T> extends java.lang.Object implements Collection<T>
Abstract basic wrapper implementation.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
IStringValueProvider.StringComparator
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<java.lang.Number>NUMBER_COMPARATOR
-
Constructor Summary
Constructors Constructor Description AbstractCollectionWrapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Taggregate(Collection<T> collection, java.lang.String opName)Aggregates elements overcollectionby resolving the given operation over the element type of the collection.Tany(ExpressionEvaluator evaluator)Returns any element complying with theevaluator.static <T> Tany(Collection<T> collection, ExpressionEvaluator evaluator)Returns the first match fromcollection.static <T> java.util.List<T>append(Collection<T> base, Collection<T> elements)Appends all elements fromelementstobase.static <T> java.lang.Objectapply(Collection<T> collection, ExpressionEvaluator evaluator)Processes elements in this set by applying to given expression.private static booleanassertBooleanIterator(ExpressionEvaluator evaluator)Asserts an iterator of boolean type.java.lang.Objectavg()Returns the average of all elements.static java.util.Set<java.lang.Object>closure(Collection<?> collection, ExpressionEvaluator evaluator)Calculates the closure overcollectionandevaluator.private static booleanclosureOnElement(java.lang.Object value, java.util.Set<java.lang.Object> result, ExpressionEvaluator evaluator, boolean stopOnCycle)Calculates the closure forvalueusingevaluatorand does not visit already visited elements inresultagain.private static voidcollect(java.lang.Object value, ExpressionEvaluator evaluator, java.util.Collection<java.lang.Object> result, boolean flatten)Performs a (non-)flattening collect operation onvalue.static java.util.List<java.lang.Object>collect(Collection<?> collection, ExpressionEvaluator evaluator, boolean flatten)Collects the application ofevaluatortocollection.protected static voidcollect(Collection<?> collection, ExpressionEvaluator evaluator, java.util.Collection<java.lang.Object> result, boolean flatten)Collects the application ofevaluatortocollection.protected static TypeDescriptor<?>constructType(TypeDescriptor<?>[] param, boolean set)Constructs a collection type.static booleancontainsAll(Collection<?> base, Collection<?> elements, boolean negate)Returns whether all elements inelementsare also inbasecollection.intcount(T element)Returns the number of elements in this collection which are equal toelement.private static java.util.Collection<java.lang.Object>createSubCollection(java.util.Collection<java.lang.Object> parent, java.lang.Object template, boolean flatten)Creates a sub-collection for non-flattened collect operations.static booleanequals(Collection<?> c1, Collection<?> c2)Returns whether two collection contains the same elements in the same sequence thanelements.booleanexcludes(T element)Returns whether this collection does not contain a certain element.booleanexcludesAll(Collection<?> elements)Returns whether this collection contains no elements fromelements.static <T> java.util.List<T>excluding(Collection<T> base, Collection<?> elements)Returns all elements frombasenot containing those inelements.java.lang.Booleanexists(ExpressionEvaluator evaluator)Returns whether there exists on element in the collection for which theevaluatorreturnstrue.static <T> java.lang.Booleanexists(Collection<T> collection, ExpressionEvaluator evaluator)Returns whether there is an element matching theevaluator.protected static <T1,T2>
voidflatten(Collection<T1> collection, java.util.Collection<T2> result)Flattens a collection.private static <T1,T2>
voidflatten(T1 value, java.util.Collection<T2> result)Flattens an element value (may contain a Java collection).java.lang.BooleanforAll(ExpressionEvaluator evaluator)Returns whether all elements in the collection for which theevaluatorreturnstrue.static <T> java.lang.BooleanforAll(Collection<T> collection, ExpressionEvaluator evaluator)Returns whether there is an element matching theevaluator.private static TypeDescriptor<?>getElementType(Collection<?> collection)Returns the element type ofcollection.TypeDescriptor<?>[]getFlattenedParams(Collection<?> collection)Returns the type parameters for a flattened collection.private static <K,V>
java.util.List<V>getList(java.util.Map<K,java.util.List<V>> map, K key)Returns a list indicated bykeyfrom the multi-entrymap.booleanincludes(T element)Returns whether this collection contains a certain element.booleanincludesAll(Collection<?> elements)Returns whether this collection contains all elements inelements.static <T> java.util.List<T>including(Collection<T> base, Collection<T> elements)Returns all elements frombaseincluding those inelements.static <T> java.util.List<T>intersection(Collection<T> c1, Collection<T> c2)Returns the intersection ofc1andc2.booleanisAcyclic(ExpressionEvaluator evaluator)Returns whether the closure over this collection andevaluatoris acyclic.static booleanisAcyclic(Collection<?> collection, ExpressionEvaluator evaluator)Returns whether the closure overcollectionandevaluatoris acyclic.booleanisEmpty()Returns whether the collection is empty.booleanisNotEmpty()Returns whether the collection is not empty (inverse ofCollection.isEmpty().private static booleanisSelected(boolean selectionCriterion, boolean select)Determines whether an element is selected.private static booleanisSelectedByType(TypeDescriptor<?> type, java.lang.Object element, boolean byKind, boolean negate)Returns whether type selection matches.java.lang.BooleanisUnique(ExpressionEvaluator evaluator)Returns whether the evaluator returns a different result for all elements in the collection.static <T> java.lang.BooleanisUnique(Collection<T> collection, ExpressionEvaluator evaluator)Returns whether there is an element matching theevaluator.Tmax()Returns the maximum of all elements.Tmin()Returns the minimum of all elements.Tone(ExpressionEvaluator evaluator)Returns the element complying with theevaluatorif there is exactly one.static <T> Tone(Collection<T> collection, ExpressionEvaluator evaluator)Returns the first match fromcollectionif there can be only one match.Tproduct()Returns the product of all elements.protected java.util.List<T>revertImpl()Implements the revert operation.static booleansameElements(Collection<?> c1, Collection<?> c2)Returns whether two collections contain the same elements regardless of their sequence.static <T> java.util.List<T>select(Collection<T> collection, ExpressionEvaluator evaluator, boolean select)Selects those elements fromcollectionwhich comply to the result ofevaluator.protected static <T> Tselect(Collection<T> collection, ExpressionEvaluator evaluator, java.util.Collection<T> result, boolean select)Selects those elements fromcollectionwhich comply to the result ofevaluator.static <T> java.util.List<T>selectByType(Collection<T> collection, TypeDescriptor<?> type, boolean byKind, boolean negate)Returns the selection of elements fromcollectioncomplying to the giventype.protected static <T> voidselectByType(Collection<T> collection, TypeDescriptor<?> type, java.util.Collection<T> result, boolean byKind, boolean negate)Calculates the selection of elements fromcollectioncomplying to the giventype.protected java.util.List<T>sortAlphaImpl()Implements the sortAlpha function.static <T> java.util.List<T>sortImpl(java.util.Iterator<T> iter, ExpressionEvaluator evaluator)Sorts the elements initer(take numbers if the evaluator returns numbers, else lexicographic sort).protected java.util.List<T>sortImpl(ExpressionEvaluator evaluator)Implements the more generic sort function (take numbers if the evaluator returns numbers, else lexicographic sort).Tsum()Returns the sum of all elements.private static <K,V>
java.util.List<V>toEntryList(java.util.Map<K,java.util.List<V>> map)Turns the multi-entrymapinto a list of single elements, preserving the sequence of the elements in the individual lists inmap.static <T> java.util.List<T>union(Collection<T> c1, Collection<T> c2)Compute the union ofc1andc2(without duplicates).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.Collection
allowSequenceAdjustment, apply, asSequence, asSet, clear, cloneCollection, closure, collect, collectNested, flatten, getGenericParameterCount, getGenericParameterType, isEquals, iterator, reject, select, selectByKind, selectByType, size, sortedBy, typeReject
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
getStringValue
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IVilGenericType
getType
-
-
-
-
Method Detail
-
equals
public static boolean equals(Collection<?> c1, Collection<?> c2)
Returns whether two collection contains the same elements in the same sequence thanelements.- Parameters:
c1- the first collection to be comparedc2- the second collection to be compared- Returns:
trueif both collections contain the same elements in the same sequence,falseelse
-
sameElements
public static boolean sameElements(Collection<?> c1, Collection<?> c2)
Returns whether two collections contain the same elements regardless of their sequence.- Parameters:
c1- the first collectionc2- the second collection- Returns:
trueif both collections contain the same elements,falseelse
-
union
public static <T> java.util.List<T> union(Collection<T> c1, Collection<T> c2)
Compute the union ofc1andc2(without duplicates).- Type Parameters:
T- the element type- Parameters:
c1- the first collection to be consideredc2- the second collection to be considered- Returns:
- the union of
c1andc2
-
intersection
public static <T> java.util.List<T> intersection(Collection<T> c1, Collection<T> c2)
Returns the intersection ofc1andc2.- Type Parameters:
T- the element type- Parameters:
c1- the first collection to be consideredc2- the second collection to be considered- Returns:
- the intersection of
c1andc2
-
excluding
public static <T> java.util.List<T> excluding(Collection<T> base, Collection<?> elements)
Returns all elements frombasenot containing those inelements.- Type Parameters:
T- the element type- Parameters:
base- the base collection to exclude the elements fromelements- the elements which must not be in the result- Returns:
- the projected result
-
including
public static <T> java.util.List<T> including(Collection<T> base, Collection<T> elements)
Returns all elements frombaseincluding those inelements.- Type Parameters:
T- the element type- Parameters:
base- the base collection to include the elements toelements- the elements which must also be in the result- Returns:
- the projected result
-
append
public static <T> java.util.List<T> append(Collection<T> base, Collection<T> elements)
Appends all elements fromelementstobase.- Type Parameters:
T- the element type- Parameters:
base- the base collection to include the elements toelements- the elements which shall be appended- Returns:
- the projected result
-
selectByType
public static <T> java.util.List<T> selectByType(Collection<T> collection, TypeDescriptor<?> type, boolean byKind, boolean negate)
Returns the selection of elements fromcollectioncomplying to the giventype.- Type Parameters:
T- the element type- Parameters:
collection- the collection to analyzetype- the type to select forbyKind- select by kind (true, including subclasses) or by type equalityfalsenegate- negate the selection- Returns:
- the elements of type
type
-
selectByType
protected static <T> void selectByType(Collection<T> collection, TypeDescriptor<?> type, java.util.Collection<T> result, boolean byKind, boolean negate)
Calculates the selection of elements fromcollectioncomplying to the giventype.- Type Parameters:
T- the element type- Parameters:
collection- the collection to analyzetype- the type to select forresult- the elements of typetype(modified as a side effect)negate- negate the selectionbyKind- select by kind (true, including subclasses) or by type equalityfalse
-
isSelectedByType
private static boolean isSelectedByType(TypeDescriptor<?> type, java.lang.Object element, boolean byKind, boolean negate)
Returns whether type selection matches.- Parameters:
type- the type to be considered (may be null, than this parameter is ignored)element- the element to testbyKind- do the selection by subtyping (true) or by equality (false)negate- negate the result- Returns:
trueif types match,falseelse
-
select
public static <T> java.util.List<T> select(Collection<T> collection, ExpressionEvaluator evaluator, boolean select) throws VilException
Selects those elements fromcollectionwhich comply to the result ofevaluator.- Type Parameters:
T- the element type- Parameters:
collection- the collection to select fromevaluator- the evaluator instanceselect- do a select (true) or a reject (false)- Returns:
- the selected elements
- Throws:
VilException- in case that evaluation or selection fails
-
select
protected static <T> T select(Collection<T> collection, ExpressionEvaluator evaluator, java.util.Collection<T> result, boolean select) throws VilException
Selects those elements fromcollectionwhich comply to the result ofevaluator.- Type Parameters:
T- the element type- Parameters:
collection- the collection to select fromevaluator- the evaluator instanceresult- the elements of typetype(modified as a side effect) - may be null then stop at first matchselect- do a select (true) or a reject (false)- Returns:
- the last match
- Throws:
VilException- in case that evaluation or selection fails
-
assertBooleanIterator
private static boolean assertBooleanIterator(ExpressionEvaluator evaluator) throws VilException
Asserts an iterator of boolean type.- Parameters:
evaluator- the evaluator to check- Returns:
- whether the actual iterator is also a decision variable
- Throws:
VilException- in case that evaluation
-
any
public T any(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionReturns any element complying with theevaluator.- Specified by:
anyin interfaceCollection<T>- Parameters:
evaluator- the evaluator (results must evaluate to Boolean)- Returns:
- one element complying with
evaluator - Throws:
VilException- in case that application fails
-
any
public static <T> T any(Collection<T> collection, ExpressionEvaluator evaluator) throws VilException
Returns the first match fromcollection.- Type Parameters:
T- the element type- Parameters:
collection- the collectionevaluator- the evaluator to check- Returns:
- the first match or null
- Throws:
VilException- in case that evaluation
-
exists
public static <T> java.lang.Boolean exists(Collection<T> collection, ExpressionEvaluator evaluator) throws VilException
Returns whether there is an element matching theevaluator.- Type Parameters:
T- the element type- Parameters:
collection- the collectionevaluator- the evaluator to check- Returns:
truethere is one,falseelse- Throws:
VilException- in case that evaluation
-
forAll
public static <T> java.lang.Boolean forAll(Collection<T> collection, ExpressionEvaluator evaluator) throws VilException
Returns whether there is an element matching theevaluator.- Type Parameters:
T- the element type- Parameters:
collection- the collectionevaluator- the evaluator to check- Returns:
truethere is one,falseelse- Throws:
VilException- in case that evaluation
-
isUnique
public static <T> java.lang.Boolean isUnique(Collection<T> collection, ExpressionEvaluator evaluator) throws VilException
Returns whether there is an element matching theevaluator.- Type Parameters:
T- the element type- Parameters:
collection- the collectionevaluator- the evaluator to check- Returns:
truethere is one,falseelse- Throws:
VilException- in case that evaluation
-
exists
public java.lang.Boolean exists(ExpressionEvaluator evaluator) throws VilException
Returns whether there exists on element in the collection for which theevaluatorreturnstrue.- Specified by:
existsin interfaceCollection<T>- Parameters:
evaluator- the evaluator- Returns:
truefor the exists one,falseelse- Throws:
VilException- in case that evaluation fails
-
forAll
public java.lang.Boolean forAll(ExpressionEvaluator evaluator) throws VilException
Returns whether all elements in the collection for which theevaluatorreturnstrue.- Specified by:
forAllin interfaceCollection<T>- Parameters:
evaluator- the evaluator- Returns:
truefor the exists one,falseelse- Throws:
VilException- in case that evaluation fails
-
isUnique
public java.lang.Boolean isUnique(ExpressionEvaluator evaluator) throws VilException
Returns whether the evaluator returns a different result for all elements in the collection.- Specified by:
isUniquein interfaceCollection<T>- Parameters:
evaluator- the evaluator- Returns:
trueif all results are different,falseelse- Throws:
VilException- in case that evaluation fails
-
one
public static <T> T one(Collection<T> collection, ExpressionEvaluator evaluator) throws VilException
Returns the first match fromcollectionif there can be only one match.- Type Parameters:
T- the element type- Parameters:
collection- the collectionevaluator- the evaluator to check- Returns:
- the first and only match or null
- Throws:
VilException- in case that evaluation
-
one
public T one(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionReturns the element complying with theevaluatorif there is exactly one.- Specified by:
onein interfaceCollection<T>- Parameters:
evaluator- the evaluator (results must evaluate to Boolean)- Returns:
- the element complying with
evaluator - Throws:
VilException- in case that evaluation fails
-
getFlattenedParams
public TypeDescriptor<?>[] getFlattenedParams(Collection<?> collection)
Returns the type parameters for a flattened collection.- Parameters:
collection- the original collection- Returns:
- the flattened type parameter(s)
-
flatten
protected static <T1,T2> void flatten(Collection<T1> collection, java.util.Collection<T2> result) throws VilException
Flattens a collection.- Type Parameters:
T1- the element type of the input collectionT2- the element type of the result collection- Parameters:
collection- the VIL collection to flattenresult- the result (to be modified as a side effect)- Throws:
VilException- in case that a single element value cannot be added to the result collection
-
flatten
private static <T1,T2> void flatten(T1 value, java.util.Collection<T2> result) throws VilExceptionFlattens an element value (may contain a Java collection).- Type Parameters:
T1- the element typeT2- the element type of the result collection- Parameters:
value- the element valueresult- the result (to be modified as a side effect)- Throws:
VilException- in case that a single element value cannot be added to the result collection
-
isSelected
private static boolean isSelected(boolean selectionCriterion, boolean select)Determines whether an element is selected.- Parameters:
selectionCriterion- the original criterionselect- select or reject (negate)- Returns:
truefor selected,falseelse
-
apply
public static <T> java.lang.Object apply(Collection<T> collection, ExpressionEvaluator evaluator) throws VilException
Processes elements in this set by applying to given expression.- Type Parameters:
T- the element type- Parameters:
collection- the collection to iterate overevaluator- the evaluator holding the iterator / expression to apply- Returns:
- the aggregated result, null in case of a non-aggregating evaluation
- Throws:
VilException- in case that evaluator fails
-
closure
public static java.util.Set<java.lang.Object> closure(Collection<?> collection, ExpressionEvaluator evaluator) throws VilException
Calculates the closure overcollectionandevaluator.- Parameters:
collection- the collection to operate onevaluator- the evaluator used to determine the next closure elements- Returns:
- the closure
- Throws:
VilException- in case that evaluation fails
-
isAcyclic
public boolean isAcyclic(ExpressionEvaluator evaluator) throws VilException
Returns whether the closure over this collection andevaluatoris acyclic.- Specified by:
isAcyclicin interfaceCollection<T>- Parameters:
evaluator- the evaluator- Returns:
truefor acyclic,falsefor cyclic- Throws:
VilException- in case that evaluation fails
-
isAcyclic
public static boolean isAcyclic(Collection<?> collection, ExpressionEvaluator evaluator) throws VilException
Returns whether the closure overcollectionandevaluatoris acyclic.- Parameters:
collection- the collection to run overevaluator- the evaluator- Returns:
truefor acyclic,falsefor cyclic- Throws:
VilException- in case that evaluation fails
-
closureOnElement
private static boolean closureOnElement(java.lang.Object value, java.util.Set<java.lang.Object> result, ExpressionEvaluator evaluator, boolean stopOnCycle) throws VilExceptionCalculates the closure forvalueusingevaluatorand does not visit already visited elements inresultagain.- Parameters:
value- the value to calculate the closure onresult- the resultevaluator- the evaluatorstopOnCycle- whether iteration/recursion shall stop immediately if a cycle is detected- Returns:
trueif a cycle was detected,falseelse- Throws:
VilException- in case that evaluator fails
-
collect
public static java.util.List<java.lang.Object> collect(Collection<?> collection, ExpressionEvaluator evaluator, boolean flatten) throws VilException
Collects the application ofevaluatortocollection.- Parameters:
collection- the collection to select fromevaluator- the evaluator instanceflatten- flatten the result- Returns:
- the application results
- Throws:
VilException- in case that evaluation fails
-
collect
protected static void collect(Collection<?> collection, ExpressionEvaluator evaluator, java.util.Collection<java.lang.Object> result, boolean flatten) throws VilException
Collects the application ofevaluatortocollection.- Parameters:
collection- the collection to select fromevaluator- the evaluator instanceresult- the elements of typetype(modified as a side effect)flatten- flatten the result- Throws:
VilException- in case that evaluation fails
-
collect
private static void collect(java.lang.Object value, ExpressionEvaluator evaluator, java.util.Collection<java.lang.Object> result, boolean flatten) throws VilExceptionPerforms a (non-)flattening collect operation onvalue.- Parameters:
value- the value to collectevaluator- the evaluator to apply onvalueresult- the result collection to fill as a side effectflatten- whether the result shall be flattened or nesting shall be kept- Throws:
VilException- in case that evaluation fails
-
createSubCollection
private static java.util.Collection<java.lang.Object> createSubCollection(java.util.Collection<java.lang.Object> parent, java.lang.Object template, boolean flatten)Creates a sub-collection for non-flattened collect operations.- Parameters:
parent- the parent collection the sub-collection shall be added totemplate- the template defining the type (set or sequence)flatten- whether the result shall be flattened or nesting shall be kept- Returns:
- the sub-collection or
parentif no sub-collection can be created
-
isEmpty
public boolean isEmpty()
Description copied from interface:CollectionReturns whether the collection is empty.- Specified by:
isEmptyin interfaceCollection<T>- Returns:
trueif it is empty,falseelse
-
isNotEmpty
public boolean isNotEmpty()
Description copied from interface:CollectionReturns whether the collection is not empty (inverse ofCollection.isEmpty().- Specified by:
isNotEmptyin interfaceCollection<T>- Returns:
falseif it is empty,trueelse
-
includes
public boolean includes(T element)
Description copied from interface:CollectionReturns whether this collection contains a certain element.- Specified by:
includesin interfaceCollection<T>- Parameters:
element- the element to look for- Returns:
trueif this collection containselement,falseelse
-
excludes
public boolean excludes(T element)
Description copied from interface:CollectionReturns whether this collection does not contain a certain element.- Specified by:
excludesin interfaceCollection<T>- Parameters:
element- the element to look for- Returns:
trueif this collection does not containelement,trueelse
-
count
public int count(T element)
Description copied from interface:CollectionReturns the number of elements in this collection which are equal toelement.- Specified by:
countin interfaceCollection<T>- Parameters:
element- the element to look for- Returns:
- the number of equal elements in this collection
-
sortAlphaImpl
protected java.util.List<T> sortAlphaImpl()
Implements the sortAlpha function.- Returns:
- a sorted (internal) list
-
getList
private static <K,V> java.util.List<V> getList(java.util.Map<K,java.util.List<V>> map, K key)Returns a list indicated bykeyfrom the multi-entrymap. Creates a new list if it does not exist.- Type Parameters:
K- the key typeV- the value type- Parameters:
map- the map to be modified as a side effectkey- the key- Returns:
- the list containing entries assigned to
key, potentially a new list
-
toEntryList
private static <K,V> java.util.List<V> toEntryList(java.util.Map<K,java.util.List<V>> map)
Turns the multi-entrymapinto a list of single elements, preserving the sequence of the elements in the individual lists inmap.- Type Parameters:
K- the key typeV- the value type- Parameters:
map- the map to be modified as a side effect- Returns:
- the list of elements
-
sortImpl
protected java.util.List<T> sortImpl(ExpressionEvaluator evaluator) throws VilException
Implements the more generic sort function (take numbers if the evaluator returns numbers, else lexicographic sort).- Parameters:
evaluator- the evaluator- Returns:
- a sorted sequence
- Throws:
VilException- in case of evaluation problems
-
sortImpl
public static <T> java.util.List<T> sortImpl(java.util.Iterator<T> iter, ExpressionEvaluator evaluator) throws VilExceptionSorts the elements initer(take numbers if the evaluator returns numbers, else lexicographic sort).- Type Parameters:
T- the data type- Parameters:
iter- the iterator holding the dataevaluator- the evaluator- Returns:
- the sorted sequence from
iter - Throws:
VilException- in case of evaluation problems
-
revertImpl
protected java.util.List<T> revertImpl()
Implements the revert operation.- Returns:
- the reverted list
-
constructType
protected static TypeDescriptor<?> constructType(TypeDescriptor<?>[] param, boolean set)
Constructs a collection type.- Parameters:
param- the parameterset- whether the result shall represent a set or a sequence- Returns:
- the constructed type
-
sum
public T sum()
Description copied from interface:CollectionReturns the sum of all elements.- Specified by:
sumin interfaceCollection<T>- Returns:
- the sum of all elements or null if the elements do not define addition
-
avg
public java.lang.Object avg()
Description copied from interface:CollectionReturns the average of all elements.- Specified by:
avgin interfaceCollection<T>- Returns:
- the average of all elements or null if the elements do not define addition or division
-
product
public T product()
Description copied from interface:CollectionReturns the product of all elements.- Specified by:
productin interfaceCollection<T>- Returns:
- the product of all elements or null if the elements do not define multiplication
-
min
public T min()
Description copied from interface:CollectionReturns the minimum of all elements.- Specified by:
minin interfaceCollection<T>- Returns:
- the minimum of all elements or null if the elements do not define the minimum operation
-
max
public T max()
Description copied from interface:CollectionReturns the maximum of all elements.- Specified by:
maxin interfaceCollection<T>- Returns:
- the maximum of all elements or null if the elements do not define the maximum operation
-
getElementType
private static TypeDescriptor<?> getElementType(Collection<?> collection)
Returns the element type ofcollection.- Parameters:
collection- the collection- Returns:
- the element type
-
aggregate
public static <T> T aggregate(Collection<T> collection, java.lang.String opName)
Aggregates elements overcollectionby resolving the given operation over the element type of the collection.- Type Parameters:
T- the element type of the collection- Parameters:
collection- the collectionopName- denotes an operation on the elements of this collection. The operation must be binary (2 parameters) on the element type of this collection and return a type that is assignable to the element type of this collection- Returns:
- the aggregated result or null if undefined/aggregation not possible
-
includesAll
public boolean includesAll(Collection<?> elements)
Description copied from interface:CollectionReturns whether this collection contains all elements inelements.- Specified by:
includesAllin interfaceCollection<T>- Parameters:
elements- the elements to look for- Returns:
trueif this collection contains allelements,falseelse
-
excludesAll
public boolean excludesAll(Collection<?> elements)
Description copied from interface:CollectionReturns whether this collection contains no elements fromelements.- Specified by:
excludesAllin interfaceCollection<T>- Parameters:
elements- the elements to look for- Returns:
trueif this collection contains none fromelements,falseelse
-
containsAll
public static boolean containsAll(Collection<?> base, Collection<?> elements, boolean negate)
Returns whether all elements inelementsare also inbasecollection.- Parameters:
base- the base collectionelements- the elements to check fornegate- whether the result shall be negated, i.e., it shall be checked for not being member of this collection- Returns:
trueif (non-)containment holds for all elements
-
-