Class ArraySet<T>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.AbstractCollectionWrapper<T>
-
- net.ssehub.easy.instantiation.core.model.vilTypes.AbstractArrayWrapper<T>
-
- net.ssehub.easy.instantiation.core.model.vilTypes.ArraySet<T>
-
- Type Parameters:
T- the element type
- All Implemented Interfaces:
java.lang.Iterable<T>,Collection<T>,IStringValueProvider,IVilGenericType,IVilType,Set<T>
public class ArraySet<T> extends AbstractArrayWrapper<T> implements Set<T>
Implements an array wrapper for the VIL set type.- 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 inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.AbstractCollectionWrapper
NUMBER_COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description ArraySet(T[] array, java.lang.Class<?> param)Creates a new array collection wrapper using the default type registry.ArraySet(T[] array, java.lang.Class<?> param, TypeRegistry registry)Creates a new array collection wrapper.ArraySet(T[] array, TypeDescriptor<?>... params)Creates a new array collection wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Tadd(T element)Adds an element to this set.java.lang.Objectapply(ExpressionEvaluator evaluator)Processes elements in this set by applying to given expression.Sequence<T>asSequence()Turns this collection into a sequence.Set<T>asSet()Turns this collection into a set.Set<T>cloneCollection()Clones this collection.Set<?>closure(ExpressionEvaluator evaluator)Calculates a transitive closure over elements provided by this collection andevaluator.Set<?>collect(ExpressionEvaluator evaluator)Collects the application ofevaluatorto each individual element and flattens nested structures.Set<?>collectNested(ExpressionEvaluator evaluator)Collects the application ofevaluatorto each individual element and keeps nested structures.Set<T>difference(Set<T> set)Calculates the difference between this and the given set.static <T> Set<T>empty(java.lang.Class<?> param, TypeRegistry registry)Returns an empty set for one type parameter.static <T extends IVilType>
Set<T>empty(java.lang.Class<T> param)Returns an empty set for one type parameter using the default type registry.static <T> Set<T>empty(TypeDescriptor<?> param)Returns an empty set for one type parameter.Set<T>excluding(Collection<T> set)Exclude the elements inset.Set<?>flatten()Flattens this collection if needed, i.e., flatten sub-collections.Set<T>including(Collection<T> set)Include the elements inset.Set<T>intersection(Set<T> set)Returns the intersection of this set withset.booleanisEquals(Collection<?> elements)Returns whether this collection is equal toelements.TprojectSingle()In case that the sequence has exactly one element, this will be returned.Set<T>reject(ExpressionEvaluator evaluator)Rejects elements in this collection according to the given expression.Set<T>select(ExpressionEvaluator evaluator)Selects elements in this collection according to the given expression.Set<T>selectByKind(TypeDescriptor<?> type)Does type selection of elements (including subtypes).Set<T>selectByType(TypeDescriptor<?> type)Does type selection of elements (only the same type).Collection<T>sortedBy(ExpressionEvaluator evaluator)Sorts the elements in this collection according to the given expression in ascending order.Set<T>symmetricDifference(Set<T> set)Calculates the symmetric difference between this and the given set.Sequence<T>toSequence()Turns this set into a sequence.Set<T>typeReject(TypeDescriptor<?> type)Does type selection of elements not having the same type (including subtypes).Set<T>union(Set<T> set)Compute the union of this set andset(without duplicates).-
Methods inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.AbstractArrayWrapper
allowSequenceAdjustment, clear, decreaseCapacity, equals, extendCapacity, getArray, getGenericParameter, getGenericParameterCount, getGenericParameterType, getStringValue, getType, hashCode, iterator, remove, removeAll, removeAt, removeDuplicates, removeFirst, removeLast, size, toMappedList, toMappedSet
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.AbstractCollectionWrapper
aggregate, any, any, append, apply, avg, closure, collect, collect, constructType, containsAll, count, equals, excludes, excludesAll, excluding, exists, exists, flatten, forAll, forAll, getFlattenedParams, includes, includesAll, including, intersection, isAcyclic, isAcyclic, isEmpty, isNotEmpty, isUnique, isUnique, max, min, one, one, product, revertImpl, sameElements, select, select, selectByType, selectByType, sortAlphaImpl, sortImpl, sortImpl, sum, union
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.Collection
allowSequenceAdjustment, any, avg, clear, count, excludes, excludesAll, exists, forAll, getGenericParameterCount, getGenericParameterType, includes, includesAll, isAcyclic, isEmpty, isNotEmpty, isUnique, iterator, max, min, one, product, size, sum
-
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
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.Set
remove, toMappedSet
-
-
-
-
Constructor Detail
-
ArraySet
public ArraySet(T[] array, java.lang.Class<?> param)
Creates a new array collection wrapper using the default type registry.- Parameters:
array- the array to be wrappedparam- the only type parameter characterizing
-
ArraySet
public ArraySet(T[] array, java.lang.Class<?> param, TypeRegistry registry)
Creates a new array collection wrapper.- Parameters:
array- the array to be wrappedregistry- the type registry to useparam- the only type parameter characterizing
-
ArraySet
public ArraySet(T[] array, TypeDescriptor<?>... params)
Creates a new array collection wrapper.- Parameters:
array- the array to be wrappedparams- the type parameter characterizing
-
-
Method Detail
-
empty
public static final <T extends IVilType> Set<T> empty(java.lang.Class<T> param)
Returns an empty set for one type parameter using the default type registry.- Type Parameters:
T- the element type- Parameters:
param- the type parameter characterizing- Returns:
- an empty set
-
empty
public static final <T> Set<T> empty(java.lang.Class<?> param, TypeRegistry registry)
Returns an empty set for one type parameter.- Type Parameters:
T- the element type- Parameters:
param- the type parameter characterizingregistry- the type registry used for resolution- Returns:
- an empty set
-
empty
public static final <T> Set<T> empty(TypeDescriptor<?> param)
Returns an empty set for one type parameter.- Type Parameters:
T- the element type- Parameters:
param- the type parameter characterizing- Returns:
- an empty set
-
selectByType
public Set<T> selectByType(TypeDescriptor<?> type)
Description copied from interface:CollectionDoes type selection of elements (only the same type).- Specified by:
selectByTypein interfaceCollection<T>- Specified by:
selectByTypein interfaceSet<T>- Parameters:
type- the target type- Returns:
- the selected elements (the type will be adjusted to the actual
type for
type)
-
selectByKind
public Set<T> selectByKind(TypeDescriptor<?> type)
Description copied from interface:CollectionDoes type selection of elements (including subtypes).- Specified by:
selectByKindin interfaceCollection<T>- Specified by:
selectByKindin interfaceSet<T>- Parameters:
type- the target type- Returns:
- the selected elements (the type will be adjusted to the actual
type for
type)
-
typeReject
public Set<T> typeReject(TypeDescriptor<?> type)
Description copied from interface:CollectionDoes type selection of elements not having the same type (including subtypes).- Specified by:
typeRejectin interfaceCollection<T>- Specified by:
typeRejectin interfaceSet<T>- Parameters:
type- the target type- Returns:
- the selected elements (the type will be adjusted to the actual
type for
type)
-
excluding
public Set<T> excluding(Collection<T> set)
Description copied from interface:SetExclude the elements inset.
-
including
public Set<T> including(Collection<T> set)
Description copied from interface:SetInclude the elements inset. Duplicates will not be included.
-
flatten
public Set<?> flatten() throws VilException
Description copied from interface:CollectionFlattens this collection if needed, i.e., flatten sub-collections.- Specified by:
flattenin interfaceCollection<T>- Specified by:
flattenin interfaceSet<T>- Returns:
- the flattened collection
- Throws:
VilException- in case of type incompatibilities
-
select
public Set<T> select(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionSelects elements in this collection according to the given expression.- Specified by:
selectin interfaceCollection<T>- Specified by:
selectin interfaceSet<T>- Parameters:
evaluator- the evaluator (results must evaluate to Boolean)- Returns:
- the selected elements
- Throws:
VilException- in case that evaluation fails
-
reject
public Set<T> reject(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionRejects elements in this collection according to the given expression.- Specified by:
rejectin interfaceCollection<T>- Specified by:
rejectin interfaceSet<T>- Parameters:
evaluator- the evaluator (results must evaluate to Boolean)- Returns:
- the rejected elements
- Throws:
VilException- in case that evaluation fails
-
collect
public Set<?> collect(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionCollects the application ofevaluatorto each individual element and flattens nested structures.- Specified by:
collectin interfaceCollection<T>- Specified by:
collectin interfaceSet<T>- Parameters:
evaluator- the evaluator (results must evaluate to Boolean)- Returns:
- the application results
- Throws:
VilException- in case that evaluation fails
-
collectNested
public Set<?> collectNested(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionCollects the application ofevaluatorto each individual element and keeps nested structures.- Specified by:
collectNestedin interfaceCollection<T>- Specified by:
collectNestedin interfaceSet<T>- Parameters:
evaluator- the evaluator (results must evaluate to Boolean)- Returns:
- the application results
- Throws:
VilException- in case that evaluation fails
-
closure
public Set<?> closure(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionCalculates a transitive closure over elements provided by this collection andevaluator.- Specified by:
closurein interfaceCollection<T>- Specified by:
closurein interfaceSet<T>- Parameters:
evaluator- the evaluator providing the links/collections to follow- Returns:
- the closure
- Throws:
VilException- in case that evaluation fails
-
apply
public java.lang.Object apply(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionProcesses elements in this set by applying to given expression.- Specified by:
applyin interfaceCollection<T>- Parameters:
evaluator- the evaluator holding the iterator / expression to apply- Returns:
- the aggregated value, null in case of no aggregation
- Throws:
VilException- in case that selection fails
-
isEquals
public boolean isEquals(Collection<?> elements)
Description copied from interface:CollectionReturns whether this collection is equal toelements. Please note that the actual semantics, i.e., whether the elements must also be in the same sequence, depends on the actual semantics of the collection.- Specified by:
isEqualsin interfaceCollection<T>- Parameters:
elements- the collection to be tested- Returns:
trueif both collections are considered to be equal,falseelse
-
toSequence
public Sequence<T> toSequence()
Description copied from interface:SetTurns this set into a sequence.- Specified by:
toSequencein interfaceSet<T>- Returns:
- the set containing the elements of this set
-
asSequence
public Sequence<T> asSequence()
Description copied from interface:CollectionTurns this collection into a sequence.- Specified by:
asSequencein interfaceCollection<T>- Returns:
- the set containing the elements of this collection
-
asSet
public Set<T> asSet()
Description copied from interface:CollectionTurns this collection into a set.- Specified by:
asSetin interfaceCollection<T>- Returns:
- the set containing the elements of this collection (excluding duplicates)
-
projectSingle
public T projectSingle()
Description copied from interface:SetIn case that the sequence has exactly one element, this will be returned.- Specified by:
projectSinglein interfaceSet<T>- Returns:
- the only element or null
-
intersection
public Set<T> intersection(Set<T> set)
Returns the intersection of this set withset.- Specified by:
intersectionin interfaceSet<T>- Parameters:
set- the elements to be unified with this set- Returns:
- the union of this set and
set
-
sortedBy
public Collection<T> sortedBy(ExpressionEvaluator evaluator) throws VilException
Description copied from interface:CollectionSorts the elements in this collection according to the given expression in ascending order.- Specified by:
sortedByin interfaceCollection<T>- Parameters:
evaluator- the evaluator- Returns:
- the selected elements
- Throws:
VilException- in case that selection fails
-
difference
public Set<T> difference(Set<T> set)
Description copied from interface:SetCalculates the difference between this and the given set.- Specified by:
differencein interfaceSet<T>- Parameters:
set- the set to calculate the difference for- Returns:
- the set difference
-
symmetricDifference
public Set<T> symmetricDifference(Set<T> set)
Description copied from interface:SetCalculates the symmetric difference between this and the given set.- Specified by:
symmetricDifferencein interfaceSet<T>- Parameters:
set- the set to calculate the difference for- Returns:
- the symmetric set difference
-
cloneCollection
public Set<T> cloneCollection()
Description copied from interface:CollectionClones this collection. (QVT)- Specified by:
cloneCollectionin interfaceCollection<T>- Specified by:
cloneCollectionin interfaceSet<T>- Returns:
- a clone of this collection
-
-