Interface Collection<T>

    • Method Detail

      • getGenericParameterCount

        int getGenericParameterCount()
        Returns the number of generic parameters of T.
        Returns:
        the number of generic parameter
      • getGenericParameterType

        TypeDescriptor<?> getGenericParameterType​(int index)
        Returns the type of the specified generic parameter of T.
        Parameters:
        index - the 0-based index of the generic parameter
        Returns:
        the actual type of the generic parameter
      • size

        int size()
        Returns the number of elements in the underlying collection.
        Returns:
        the number of elements
      • allowSequenceAdjustment

        boolean allowSequenceAdjustment()
        Returns whether a IStringValueProvider may reorder the sequence of this collection for (test) output.
        Returns:
        true if a value provider may reorder the sequence, false else
      • isEmpty

        boolean isEmpty()
        Returns whether the collection is empty.
        Returns:
        true if it is empty, false else
      • isNotEmpty

        boolean isNotEmpty()
        Returns whether the collection is not empty (inverse of isEmpty().
        Returns:
        false if it is empty, true else
      • includes

        boolean includes​(T element)
        Returns whether this collection contains a certain element.
        Parameters:
        element - the element to look for
        Returns:
        true if this collection contains element, false else
      • excludes

        boolean excludes​(T element)
        Returns whether this collection does not contain a certain element.
        Parameters:
        element - the element to look for
        Returns:
        true if this collection does not contain element, true else
      • count

        int count​(T element)
        Returns the number of elements in this collection which are equal to element.
        Parameters:
        element - the element to look for
        Returns:
        the number of equal elements in this collection
      • iterator

        java.util.Iterator<T> iterator()
        Returns an iterator on the individual elements of this collection.
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Returns:
        the iterator
      • isEquals

        boolean isEquals​(Collection<?> elements)
        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.
        Parameters:
        elements - the collection to be tested
        Returns:
        true if both collections are considered to be equal, false else
      • clear

        void clear()
        Clears this collection.
      • select

        Collection<T> select​(ExpressionEvaluator evaluator)
                      throws VilException
        Selects elements in this collection according to the given expression.
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the selected elements
        Throws:
        VilException - in case that evaluation fails
      • reject

        Collection<T> reject​(ExpressionEvaluator evaluator)
                      throws VilException
        Rejects elements in this collection according to the given expression.
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the rejected elements
        Throws:
        VilException - in case that evaluation fails
      • closure

        Collection<?> closure​(ExpressionEvaluator evaluator)
                       throws VilException
        Calculates a transitive closure over elements provided by this collection and evaluator.
        Parameters:
        evaluator - the evaluator providing the links/collections to follow
        Returns:
        the closure
        Throws:
        VilException - in case that evaluation fails
      • isAcyclic

        boolean isAcyclic​(ExpressionEvaluator evaluator)
                   throws VilException
        Returns whether the transitive closure over elements provided by this collection and evaluator does not contain a cycle.
        Parameters:
        evaluator - the evaluator providing the links/collections to follow
        Returns:
        true for cycle, false else
        Throws:
        VilException - in case that evaluation fails
      • collect

        Collection<?> collect​(ExpressionEvaluator evaluator)
                       throws VilException
        Collects the application of evaluator to each individual element and flattens nested structures.
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the application results
        Throws:
        VilException - in case that evaluation fails
      • collectNested

        Collection<?> collectNested​(ExpressionEvaluator evaluator)
                             throws VilException
        Collects the application of evaluator to each individual element and keeps nested structures.
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the application results
        Throws:
        VilException - in case that evaluation fails
      • any

        T any​(ExpressionEvaluator evaluator)
        throws VilException
        Returns any element complying with the evaluator.
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        one element complying with evaluator
        Throws:
        VilException - in case that application fails
      • one

        T one​(ExpressionEvaluator evaluator)
        throws VilException
        Returns the element complying with the evaluator if there is exactly one.
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the element complying with evaluator
        Throws:
        VilException - in case that evaluation fails
      • exists

        java.lang.Boolean exists​(ExpressionEvaluator evaluator)
                          throws VilException
        Returns whether there exists on element in the collection for which the evaluator returns true.
        Parameters:
        evaluator - the evaluator
        Returns:
        true for the exists one, false else
        Throws:
        VilException - in case that evaluation fails
      • forAll

        java.lang.Boolean forAll​(ExpressionEvaluator evaluator)
                          throws VilException
        Returns whether all elements in the collection for which the evaluator returns true.
        Parameters:
        evaluator - the evaluator
        Returns:
        true for the exists one, false else
        Throws:
        VilException - in case that evaluation fails
      • isUnique

        java.lang.Boolean isUnique​(ExpressionEvaluator evaluator)
                            throws VilException
        Returns whether the evaluator returns a different result for all elements in the collection.
        Parameters:
        evaluator - the evaluator
        Returns:
        true if all results are different, false else
        Throws:
        VilException - in case that evaluation fails
      • selectByType

        Collection<T> selectByType​(TypeDescriptor<?> type)
        Does type selection of elements (only the same type).
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • selectByKind

        Collection<T> selectByKind​(TypeDescriptor<?> type)
        Does type selection of elements (including subtypes).
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • typeReject

        Collection<T> typeReject​(TypeDescriptor<?> type)
        Does type selection of elements not having the same type (including subtypes).
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • sum

        T sum()
        Returns the sum of all elements.
        Returns:
        the sum of all elements or null if the elements do not define addition
      • avg

        java.lang.Object avg()
        Returns the average of all elements.
        Returns:
        the average of all elements or null if the elements do not define addition or division
      • product

        T product()
        Returns the product of all elements.
        Returns:
        the product of all elements or null if the elements do not define multiplication
      • min

        T min()
        Returns the minimum of all elements.
        Returns:
        the minimum of all elements or null if the elements do not define the minimum operation
      • max

        T max()
        Returns the maximum of all elements.
        Returns:
        the maximum of all elements or null if the elements do not define the maximum operation
      • includesAll

        boolean includesAll​(Collection<?> elements)
        Returns whether this collection contains all elements in elements.
        Parameters:
        elements - the elements to look for
        Returns:
        true if this collection contains all elements, false else
      • excludesAll

        boolean excludesAll​(Collection<?> elements)
        Returns whether this collection contains no elements from elements.
        Parameters:
        elements - the elements to look for
        Returns:
        true if this collection contains none from elements, false else
      • asSequence

        Sequence<T> asSequence()
        Turns this collection into a sequence.
        Returns:
        the set containing the elements of this collection
      • asSet

        Set<T> asSet()
        Turns this collection into a set.
        Returns:
        the set containing the elements of this collection (excluding duplicates)
      • flatten

        Collection<?> flatten()
                       throws VilException
        Flattens this collection if needed, i.e., flatten sub-collections.
        Returns:
        the flattened collection
        Throws:
        VilException - in case of type incompatibilities
      • sortedBy

        Collection<T> sortedBy​(ExpressionEvaluator evaluator)
                        throws VilException
        Sorts the elements in this collection according to the given expression in ascending order.
        Parameters:
        evaluator - the evaluator
        Returns:
        the selected elements
        Throws:
        VilException - in case that selection fails
      • apply

        java.lang.Object apply​(ExpressionEvaluator evaluator)
                        throws VilException
        Processes elements in this set by applying to given expression.
        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
      • cloneCollection

        Collection<T> cloneCollection()
        Clones this collection. (QVT)
        Returns:
        a clone of this collection