Class AbstractArrayWrapper<T>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.AbstractCollectionWrapper<T>
-
- net.ssehub.easy.instantiation.core.model.vilTypes.AbstractArrayWrapper<T>
-
- Type Parameters:
T- the element type
- All Implemented Interfaces:
java.lang.Iterable<T>,Collection<T>,IStringValueProvider,IVilGenericType,IVilType
- Direct Known Subclasses:
ArraySequence,ArraySet
public abstract class AbstractArrayWrapper<T> extends AbstractCollectionWrapper<T> implements Collection<T>
Implements an array wrapper for the VIL collection 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 Modifier and Type Field Description private T[]arrayprivate TypeDescriptor<?>[]paramsprivate TypeDescriptor<?>type-
Fields inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.AbstractCollectionWrapper
NUMBER_COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description AbstractArrayWrapper(T[] array, boolean set, TypeDescriptor<?>... params)Creates a new array collection wrapper.AbstractArrayWrapper(T[] array, TypeRegistry registry, boolean set, java.lang.Class<?> param)Creates a new array collection wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowSequenceAdjustment()Returns whether aIStringValueProvidermay reorder the sequence of this collection for (test) output.voidclear()Clears this collection.protected voiddecreaseCapacity(int decrement)Decreases the capacity.booleanequals(java.lang.Object object)protected voidextendCapacity(int increment)Extends the capacity byincrement.protected T[]getArray()Returns the array for further use.protected TypeDescriptor<?>[]getGenericParameter()Returns the generic parameter for further use.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.inthashCode()java.util.Iterator<T>iterator()Returns an iterator on the individual elements of this collection.booleanremove(T element)Removes the first occurrence of the given element from this sequence.voidremoveAll(T element)Removes all elements equal toelement.TremoveAt(int index)Removes the element atindex.private TremoveAtImpl(int index)Removes the element atindex.protected static <T> T[]removeDuplicates(T[] elements)Removes duplicates from the given array.TremoveFirst()Removes the first element.TremoveLast()Removes the last element.intsize()Returns the number of elements in the underlying collection.java.util.List<T>toMappedList()Turns the array into a list for mapping to external Java types.java.util.Set<T>toMappedSet()Turns the array into a set for mapping to external Java types.-
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
any, apply, asSequence, asSet, avg, cloneCollection, closure, collect, collectNested, count, excludes, excludesAll, exists, flatten, forAll, includes, includesAll, isAcyclic, isEmpty, isEquals, isNotEmpty, isUnique, max, min, one, product, reject, select, selectByKind, selectByType, sortedBy, sum, typeReject
-
-
-
-
Field Detail
-
array
private T[] array
-
params
private TypeDescriptor<?>[] params
-
type
private TypeDescriptor<?> type
-
-
Constructor Detail
-
AbstractArrayWrapper
public AbstractArrayWrapper(T[] array, TypeRegistry registry, boolean set, java.lang.Class<?> param)
Creates a new array collection wrapper.- Parameters:
array- the wrapped arrayset- does this type represent a set or a sequenceregistry- the type registry to use for the conversion ofparamparam- the type parameter characterizing
-
AbstractArrayWrapper
public AbstractArrayWrapper(T[] array, boolean set, TypeDescriptor<?>... params)
Creates a new array collection wrapper.- Parameters:
array- the wrapped arrayset- does this type represent a set or a sequenceparams- the type parameter characterizing
-
-
Method Detail
-
getArray
protected T[] getArray()
Returns the array for further use.- Returns:
- the array
-
getGenericParameter
protected TypeDescriptor<?>[] getGenericParameter()
Returns the generic parameter for further use.- Returns:
- the generic parameter
-
removeDuplicates
protected static <T> T[] removeDuplicates(T[] elements)
Removes duplicates from the given array.- Type Parameters:
T- the element type- Parameters:
elements- the elements to remove duplicates from (may be null)- Returns:
- an array of elements without duplicates, may be null if elements is null
-
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
-
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
-
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
-
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
-
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
-
extendCapacity
protected void extendCapacity(int increment)
Extends the capacity byincrement.- Parameters:
increment- the increment
-
decreaseCapacity
protected void decreaseCapacity(int decrement)
Decreases the capacity.- Parameters:
decrement- the decrement for decreasing the capacity
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toMappedList
public java.util.List<T> toMappedList()
Turns the array into a list for mapping to external Java types.- Returns:
- the list
-
toMappedSet
public java.util.Set<T> toMappedSet()
Turns the array into a set for mapping to external Java types.- Returns:
- the list
-
remove
public boolean remove(T element)
Removes the first occurrence of the given element from this sequence.- Parameters:
element- the element to be removed- Returns:
trueof the element was removed,falseelse
-
removeAll
public void removeAll(T element)
Removes all elements equal toelement. (QVT)- Parameters:
element- the element to remove all copies for
-
removeAt
public T removeAt(int index)
Removes the element atindex. (QVT)- Parameters:
index- the index of the element to remove- Returns:
- the removed index, undefined if index is not valid
-
removeAtImpl
private T removeAtImpl(int index)
Removes the element atindex. (QVT)- Parameters:
index- the 0-based index of the element to remove- Returns:
- the removed index, undefined if index is not valid
-
removeFirst
public T removeFirst()
Removes the first element. (QVT)- Returns:
- the removed element, undefined if there is no first element
-
removeLast
public T removeLast()
Removes the last element. (QVT)- Returns:
- the removed element, undefined if there is no last element
-
clear
public void clear()
Description copied from interface:CollectionClears this collection.- Specified by:
clearin interfaceCollection<T>
-
-