Class SetSet<T>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.AbstractCollectionWrapper<T>
-
- net.ssehub.easy.instantiation.core.model.vilTypes.SetSet<T>
-
- Type Parameters:
T- the element type
- All Implemented Interfaces:
java.lang.Iterable<T>,Collection<T>,IStringValueProvider,IVilGenericType,IVilType,Set<T>
public class SetSet<T> extends AbstractCollectionWrapper<T> implements Set<T>
A VIL set wrapper based on a Java set.- 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 private TypeDescriptor<?>[]paramsprivate java.util.Set<T>setprivate TypeDescriptor<?>type-
Fields inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.AbstractCollectionWrapper
NUMBER_COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description SetSet(java.util.Set<T> set, java.lang.Class<?> param)Creates a new array collection wrapper using the default type registry.SetSet(java.util.Set<T> set, java.lang.Class<?> param, TypeRegistry registry)Creates a new array collection wrapper.SetSet(java.util.Set<T> set, TypeDescriptor<?>... params)Creates a new set wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tadd(T element)Adds an element to this set.booleanallowSequenceAdjustment()Returns whether aIStringValueProvidermay reorder the sequence of this collection for (test) output.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.voidclear()Clears this collection.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.Set<T>excluding(Collection<T> set)Exclude the elements inset.Set<?>flatten()Flattens this collection if needed, i.e., flatten sub-collections.intgetGenericParameterCount()Returns the number of generic parameters ofT.TypeDescriptor<?>getGenericParameterType(int index)Returns the type of the specified generic parameter ofT.java.lang.StringgetStringValue(IStringValueProvider.StringComparator comparator)Returns the string value of this object.TypeDescriptor<?>getType()Returns the actual type including generics.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.java.util.Iterator<T>iterator()Returns an iterator on the individual elements of this collection.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.booleanremove(T element)Removes the given element from this sequence.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).intsize()Returns the number of elements in the underlying collection.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.java.util.Set<T>toMappedSet()Converts back to a set for utilizing this with external classes.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.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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.Collection
any, avg, count, excludes, excludesAll, exists, forAll, includes, includesAll, isAcyclic, isEmpty, isNotEmpty, isUnique, max, min, one, product, sum
-
-
-
-
Field Detail
-
set
private java.util.Set<T> set
-
params
private TypeDescriptor<?>[] params
-
type
private TypeDescriptor<?> type
-
-
Constructor Detail
-
SetSet
public SetSet(java.util.Set<T> set, java.lang.Class<?> param)
Creates a new array collection wrapper using the default type registry.- Parameters:
set- the set to be wrappedparam- the only type parameter characterizing
-
SetSet
public SetSet(java.util.Set<T> set, java.lang.Class<?> param, TypeRegistry registry)
Creates a new array collection wrapper.- Parameters:
set- the set to be wrappedregistry- the type registry to useparam- the only type parameter characterizing
-
SetSet
public SetSet(java.util.Set<T> set, TypeDescriptor<?>... params)
Creates a new set wrapper.- Parameters:
set- the set to be wrappedparams- the type parameter characterizing
-
-
Method Detail
-
getGenericParameterCount
public int getGenericParameterCount()
Description copied from interface:CollectionReturns the number of generic parameters ofT.- Specified by:
getGenericParameterCountin interfaceCollection<T>- Returns:
- the number of generic parameter
-
getGenericParameterType
public TypeDescriptor<?> getGenericParameterType(int index)
Description copied from interface:CollectionReturns the type of the specified generic parameter ofT.- Specified by:
getGenericParameterTypein interfaceCollection<T>- Parameters:
index- the 0-based index of the generic parameter- Returns:
- the actual type of the generic parameter
-
size
public int size()
Description copied from interface:CollectionReturns the number of elements in the underlying collection.- Specified by:
sizein interfaceCollection<T>- Returns:
- the number of elements
-
allowSequenceAdjustment
public boolean allowSequenceAdjustment()
Description copied from interface:CollectionReturns whether aIStringValueProvidermay reorder the sequence of this collection for (test) output.- Specified by:
allowSequenceAdjustmentin interfaceCollection<T>- Returns:
trueif a value provider may reorder the sequence,falseelse
-
iterator
public java.util.Iterator<T> iterator()
Description copied from interface:CollectionReturns an iterator on the individual elements of this collection.- Specified by:
iteratorin interfaceCollection<T>- Specified by:
iteratorin interfacejava.lang.Iterable<T>- Returns:
- the iterator
-
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
-
getType
public TypeDescriptor<?> getType()
Description copied from interface:IVilGenericTypeReturns the actual type including generics. "Overrides"PseudoAny.getType(Object).- Specified by:
getTypein interfaceIVilGenericType- Returns:
- the actual type
-
getStringValue
public java.lang.String getStringValue(IStringValueProvider.StringComparator comparator)
Description copied from interface:IStringValueProviderReturns the string value of this object.- Specified by:
getStringValuein interfaceIStringValueProvider- Parameters:
comparator- if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned- Returns:
- the string value
-
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.
-
union
public Set<T> union(Set<T> set)
Description copied from interface:SetCompute the union of this set andset(without duplicates).
-
intersection
public Set<T> intersection(Set<T> set)
Description copied from interface:SetReturns the intersection of this set withset.- Specified by:
intersectionin interfaceSet<T>- Parameters:
set- the elements to be unified with this set- Returns:
- the intersection of this set and
set
-
remove
public boolean remove(T element)
Description copied from interface:SetRemoves the given element from this sequence.
-
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)
-
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
-
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
-
toMappedSet
public java.util.Set<T> toMappedSet()
Description copied from interface:SetConverts back to a set for utilizing this with external classes.- Specified by:
toMappedSetin interfaceSet<T>- Returns:
- the internal map
-
clear
public void clear()
Description copied from interface:CollectionClears this collection.- Specified by:
clearin interfaceCollection<T>
-
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
-
-