Class ListSequence<T>

    • Constructor Detail

      • ListSequence

        public ListSequence​(java.util.List<T> list,
                            java.lang.Class<?> param)
        Creates a new array collection wrapper using the default type registry.
        Parameters:
        list - the wrapped list
        param - the only type parameter characterizing
      • ListSequence

        public ListSequence​(java.util.List<T> list,
                            TypeRegistry registry,
                            java.lang.Class<?> param)
        Creates a new array collection wrapper.
        Parameters:
        list - the wrapped list
        registry - the registry to convert param
        param - the only type parameter characterizing
      • ListSequence

        public ListSequence​(java.util.List<T> list,
                            TypeDescriptor<?>... params)
        Creates a new array collection wrapper using the default type registry.
        Parameters:
        list - the wrapped list
        params - the type parameter characterizing
    • Method Detail

      • at

        public T at​(int index)
        Description copied from interface: Sequence
        Returns a specific element from the collection.
        Specified by:
        at in interface Sequence<T>
        Parameters:
        index - the index of the element to be returned
        Returns:
        the element or null in case of non-existing data or if index < 0 || index >= Collection.size()
      • get

        public T get​(int index)
        Description copied from interface: Sequence
        Returns a specific element from the collection.
        Specified by:
        get in interface Sequence<T>
        Parameters:
        index - the index of the element to be returned
        Returns:
        the element or null in case of non-existing data or if index < 0 || index >= Collection.size()
      • empty

        public static final <T> Sequence<T> empty​(TypeDescriptor<?> param)
        Returns an empty sequence for one type parameter.
        Type Parameters:
        T - the element type
        Parameters:
        param - the type parameter characterizing
        Returns:
        an empty sequence
      • selectByType

        public Sequence<T> selectByType​(TypeDescriptor<?> type)
        Description copied from interface: Collection
        Does type selection of elements (only the same type).
        Specified by:
        selectByType in interface Collection<T>
        Specified by:
        selectByType in interface Sequence<T>
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • selectByKind

        public Sequence<T> selectByKind​(TypeDescriptor<?> type)
        Description copied from interface: Collection
        Does type selection of elements (including subtypes).
        Specified by:
        selectByKind in interface Collection<T>
        Specified by:
        selectByKind in interface Sequence<T>
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • typeReject

        public Sequence<T> typeReject​(TypeDescriptor<?> type)
        Description copied from interface: Collection
        Does type selection of elements not having the same type (including subtypes).
        Specified by:
        typeReject in interface Collection<T>
        Specified by:
        typeReject in interface Sequence<T>
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • excluding

        public Sequence<T> excluding​(Collection<T> sequence)
        Description copied from interface: Sequence
        Exclude the elements in sequence.
        Specified by:
        excluding in interface Sequence<T>
        Parameters:
        sequence - the elements to be excluded
        Returns:
        this set without the elements in set
      • append

        public Sequence<T> append​(Collection<T> sequence)
        Description copied from interface: Sequence
        Append the elements in set.
        Specified by:
        append in interface Sequence<T>
        Parameters:
        sequence - the elements to be appended
        Returns:
        this set including the elements in set
      • collect

        public Sequence<?> collect​(ExpressionEvaluator evaluator)
                            throws VilException
        Description copied from interface: Collection
        Collects the application of evaluator to each individual element and flattens nested structures.
        Specified by:
        collect in interface Collection<T>
        Specified by:
        collect in interface Sequence<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: Collection
        Calculates a transitive closure over elements provided by this collection and evaluator.
        Specified by:
        closure in interface Collection<T>
        Specified by:
        closure in interface Sequence<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: Collection
        Processes elements in this set by applying to given expression.
        Specified by:
        apply in interface Collection<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: Collection
        Returns whether this collection is equal to elements. 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:
        isEquals in interface Collection<T>
        Parameters:
        elements - the collection to be tested
        Returns:
        true if both collections are considered to be equal, false else
      • toSet

        public Set<T> toSet()
        Description copied from interface: Sequence
        Turns this sequence into a set.
        Specified by:
        toSet in interface Sequence<T>
        Returns:
        the set containing the elements of this sequence (excluding duplicates)
      • asSet

        public Set<T> asSet()
        Description copied from interface: Collection
        Turns this collection into a set.
        Specified by:
        asSet in interface Collection<T>
        Returns:
        the set containing the elements of this collection (excluding duplicates)
      • asSequence

        public Sequence<T> asSequence()
        Description copied from interface: Collection
        Turns this collection into a sequence.
        Specified by:
        asSequence in interface Collection<T>
        Returns:
        the set containing the elements of this collection
      • sortAlpha

        public Sequence<T> sortAlpha()
        Description copied from interface: Sequence
        Returns an alphabetically sorted sequence. Elements are considered using their (internal) string representations and sorted.
        Specified by:
        sortAlpha in interface Sequence<T>
        Returns:
        the sorted sequence
      • revert

        public Sequence<T> revert()
        Description copied from interface: Sequence
        Reverts this sequence.
        Specified by:
        revert in interface Sequence<T>
        Returns:
        the reverted sequence
      • first

        public T first()
        Description copied from interface: Sequence
        Returns the first element.
        Specified by:
        first in interface Sequence<T>
        Returns:
        the first element
      • last

        public T last()
        Description copied from interface: Sequence
        Returns the last element.
        Specified by:
        last in interface Sequence<T>
        Returns:
        the last element
      • indexOf

        public int indexOf​(T element)
        Description copied from interface: Sequence
        Returns the index of element in this sequence.
        Specified by:
        indexOf in interface Sequence<T>
        Parameters:
        element - the element to return the index for
        Returns:
        the 0-based index of element in this sequence, -1 if not found
      • add

        public T add​(T element)
        Description copied from interface: Sequence
        Adds an element to the end of this sequence.
        Specified by:
        add in interface Sequence<T>
        Parameters:
        element - the element to be added
        Returns:
        element
      • remove

        public boolean remove​(T element)
        Description copied from interface: Sequence
        Removes the first occurrence of the given element from this sequence.
        Specified by:
        remove in interface Sequence<T>
        Parameters:
        element - the element to be removed
        Returns:
        true of the element was removed, false else
      • mapSequence

        public Map<T,​T> mapSequence​(Sequence<T> other)
        Description copied from interface: Sequence
        Maps the elements of this sequence to the elements of other and returns the mapping pairs (based on the equals operation) in the given sequence. Please note that both sequences must have exactly one type parameter.
        Specified by:
        mapSequence in interface Sequence<T>
        Parameters:
        other - the second sequence to map against
        Returns:
        the mapping (key is taken from this sequence, value from other)
      • mapAny

        public Map<T,​T> mapAny​(Sequence<T> other)
        Description copied from interface: Sequence
        Maps the elements of this sequence to the elements of other and returns the mapping pairs (based on the equals operation) regardless of the sequence. Please note that both sequences must have exactly one type parameter.
        Specified by:
        mapAny in interface Sequence<T>
        Parameters:
        other - the second sequence to map against
        Returns:
        the mapping (key is taken from this sequence, value from other)
      • union

        public Sequence<T> union​(Sequence<T> seq)
        Description copied from interface: Sequence
        Append the elements in seq.
        Specified by:
        union in interface Sequence<T>
        Parameters:
        seq - the elements to be appended
        Returns:
        this set including the elements in seq
      • append

        public Sequence<T> append​(T object)
        Description copied from interface: Sequence
        Returns the combined sequence of seq and objectappended.
        Specified by:
        append in interface Sequence<T>
        Parameters:
        object - the object to append
        Returns:
        the combined sequence
      • prepend

        public Sequence<T> prepend​(T object)
        Description copied from interface: Sequence
        Returns the combined sequence of object prepended before this sequence.
        Specified by:
        prepend in interface Sequence<T>
        Parameters:
        object - the object to prepend
        Returns:
        the combined sequence
      • insertAt

        public Sequence<T> insertAt​(int index,
                                    T object)
        Description copied from interface: Sequence
        Returns the sequence having object inserted at position index.
        Specified by:
        insertAt in interface Sequence<T>
        Parameters:
        index - the index to insert at
        object - the object to insert
        Returns:
        the combined sequence
      • subSequence

        public Sequence<T> subSequence​(int lower,
                                       int upper)
        Description copied from interface: Sequence
        Returns the sub-sequence of this sequence.
        Specified by:
        subSequence in interface Sequence<T>
        Parameters:
        lower - the lower index where the sub-sequence shall start
        upper - the end index where the sub-sequence shall end
        Returns:
        the sub-sequence
      • hasDuplicates

        public boolean hasDuplicates()
        Description copied from interface: Sequence
        Returns whether at least one of the elements in operand has a duplicate.
        Specified by:
        hasDuplicates in interface Sequence<T>
        Returns:
        true for duplicates, false else
      • overlaps

        public boolean overlaps​(Sequence<T> other)
        Description copied from interface: Sequence
        Returns the sequence in that this sequence and other have in common.
        Specified by:
        overlaps in interface Sequence<T>
        Parameters:
        other - the other sequence
        Returns:
        true for overlaps, false else
      • isSubsequenceOf

        public boolean isSubsequenceOf​(Sequence<T> other)
        Description copied from interface: Sequence
        Returns whether operand is a subsequence (considering the sequence and including equality) of other.
        Specified by:
        isSubsequenceOf in interface Sequence<T>
        Parameters:
        other - the other sequence
        Returns:
        true for subsequence, false else
      • joinfields

        public java.lang.String joinfields​(java.lang.String separator,
                                           java.lang.String begin,
                                           java.lang.String end)
        Description copied from interface: Sequence
        Returns a concatenation of the string representation of elements, with begin as lead in, sep as separator between the elements and end as lead out. (QVT)
        Specified by:
        joinfields in interface Sequence<T>
        Parameters:
        separator - the separator
        begin - the lead in
        end - the lead out
        Returns:
        the concatenated result
      • removeAll

        public void removeAll​(T element)
        Description copied from interface: Sequence
        Removes all elements equal to element. (QVT)
        Specified by:
        removeAll in interface Sequence<T>
        Parameters:
        element - the element to remove all copies for
      • removeAt

        public T removeAt​(int index)
        Description copied from interface: Sequence
        Removes the element at index. (QVT)
        Specified by:
        removeAt in interface Sequence<T>
        Parameters:
        index - the index of the element to remove
        Returns:
        the removed index, undefined if index is not valid
      • removeFirst

        public T removeFirst()
        Description copied from interface: Sequence
        Removes the first element. (QVT)
        Specified by:
        removeFirst in interface Sequence<T>
        Returns:
        the removed element, undefined if there is no first element
      • removeLast

        public T removeLast()
        Description copied from interface: Sequence
        Removes the last element. (QVT)
        Specified by:
        removeLast in interface Sequence<T>
        Returns:
        the removed element, undefined if there is no last element