Class AbstractCollectionWrapper<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Comparator<java.lang.Number> NUMBER_COMPARATOR  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T aggregate​(Collection<T> collection, java.lang.String opName)
      Aggregates elements over collection by resolving the given operation over the element type of the collection.
      T any​(ExpressionEvaluator evaluator)
      Returns any element complying with the evaluator.
      static <T> T any​(Collection<T> collection, ExpressionEvaluator evaluator)
      Returns the first match from collection.
      static <T> java.util.List<T> append​(Collection<T> base, Collection<T> elements)
      Appends all elements from elements to base.
      static <T> java.lang.Object apply​(Collection<T> collection, ExpressionEvaluator evaluator)
      Processes elements in this set by applying to given expression.
      private static boolean assertBooleanIterator​(ExpressionEvaluator evaluator)
      Asserts an iterator of boolean type.
      java.lang.Object avg()
      Returns the average of all elements.
      static java.util.Set<java.lang.Object> closure​(Collection<?> collection, ExpressionEvaluator evaluator)
      Calculates the closure over collection and evaluator.
      private static boolean closureOnElement​(java.lang.Object value, java.util.Set<java.lang.Object> result, ExpressionEvaluator evaluator, boolean stopOnCycle)
      Calculates the closure for value using evaluator and does not visit already visited elements in result again.
      private static void collect​(java.lang.Object value, ExpressionEvaluator evaluator, java.util.Collection<java.lang.Object> result, boolean flatten)
      Performs a (non-)flattening collect operation on value.
      static java.util.List<java.lang.Object> collect​(Collection<?> collection, ExpressionEvaluator evaluator, boolean flatten)
      Collects the application of evaluator to collection.
      protected static void collect​(Collection<?> collection, ExpressionEvaluator evaluator, java.util.Collection<java.lang.Object> result, boolean flatten)
      Collects the application of evaluator to collection.
      protected static TypeDescriptor<?> constructType​(TypeDescriptor<?>[] param, boolean set)
      Constructs a collection type.
      static boolean containsAll​(Collection<?> base, Collection<?> elements, boolean negate)
      Returns whether all elements in elements are also in base collection.
      int count​(T element)
      Returns the number of elements in this collection which are equal to element.
      private static java.util.Collection<java.lang.Object> createSubCollection​(java.util.Collection<java.lang.Object> parent, java.lang.Object template, boolean flatten)
      Creates a sub-collection for non-flattened collect operations.
      static boolean equals​(Collection<?> c1, Collection<?> c2)
      Returns whether two collection contains the same elements in the same sequence than elements.
      boolean excludes​(T element)
      Returns whether this collection does not contain a certain element.
      boolean excludesAll​(Collection<?> elements)
      Returns whether this collection contains no elements from elements.
      static <T> java.util.List<T> excluding​(Collection<T> base, Collection<?> elements)
      Returns all elements from base not containing those in elements.
      java.lang.Boolean exists​(ExpressionEvaluator evaluator)
      Returns whether there exists on element in the collection for which the evaluator returns true.
      static <T> java.lang.Boolean exists​(Collection<T> collection, ExpressionEvaluator evaluator)
      Returns whether there is an element matching the evaluator.
      protected static <T1,​T2>
      void
      flatten​(Collection<T1> collection, java.util.Collection<T2> result)
      Flattens a collection.
      private static <T1,​T2>
      void
      flatten​(T1 value, java.util.Collection<T2> result)
      Flattens an element value (may contain a Java collection).
      java.lang.Boolean forAll​(ExpressionEvaluator evaluator)
      Returns whether all elements in the collection for which the evaluator returns true.
      static <T> java.lang.Boolean forAll​(Collection<T> collection, ExpressionEvaluator evaluator)
      Returns whether there is an element matching the evaluator.
      private static TypeDescriptor<?> getElementType​(Collection<?> collection)
      Returns the element type of collection.
      TypeDescriptor<?>[] getFlattenedParams​(Collection<?> collection)
      Returns the type parameters for a flattened collection.
      private static <K,​V>
      java.util.List<V>
      getList​(java.util.Map<K,​java.util.List<V>> map, K key)
      Returns a list indicated by key from the multi-entry map.
      boolean includes​(T element)
      Returns whether this collection contains a certain element.
      boolean includesAll​(Collection<?> elements)
      Returns whether this collection contains all elements in elements.
      static <T> java.util.List<T> including​(Collection<T> base, Collection<T> elements)
      Returns all elements from base including those in elements.
      static <T> java.util.List<T> intersection​(Collection<T> c1, Collection<T> c2)
      Returns the intersection of c1 and c2.
      boolean isAcyclic​(ExpressionEvaluator evaluator)
      Returns whether the closure over this collection and evaluator is acyclic.
      static boolean isAcyclic​(Collection<?> collection, ExpressionEvaluator evaluator)
      Returns whether the closure over collection and evaluator is acyclic.
      boolean isEmpty()
      Returns whether the collection is empty.
      boolean isNotEmpty()
      Returns whether the collection is not empty (inverse of Collection.isEmpty().
      private static boolean isSelected​(boolean selectionCriterion, boolean select)
      Determines whether an element is selected.
      private static boolean isSelectedByType​(TypeDescriptor<?> type, java.lang.Object element, boolean byKind, boolean negate)
      Returns whether type selection matches.
      java.lang.Boolean isUnique​(ExpressionEvaluator evaluator)
      Returns whether the evaluator returns a different result for all elements in the collection.
      static <T> java.lang.Boolean isUnique​(Collection<T> collection, ExpressionEvaluator evaluator)
      Returns whether there is an element matching the evaluator.
      T max()
      Returns the maximum of all elements.
      T min()
      Returns the minimum of all elements.
      T one​(ExpressionEvaluator evaluator)
      Returns the element complying with the evaluator if there is exactly one.
      static <T> T one​(Collection<T> collection, ExpressionEvaluator evaluator)
      Returns the first match from collection if there can be only one match.
      T product()
      Returns the product of all elements.
      protected java.util.List<T> revertImpl()
      Implements the revert operation.
      static boolean sameElements​(Collection<?> c1, Collection<?> c2)
      Returns whether two collections contain the same elements regardless of their sequence.
      static <T> java.util.List<T> select​(Collection<T> collection, ExpressionEvaluator evaluator, boolean select)
      Selects those elements from collection which comply to the result of evaluator.
      protected static <T> T select​(Collection<T> collection, ExpressionEvaluator evaluator, java.util.Collection<T> result, boolean select)
      Selects those elements from collection which comply to the result of evaluator.
      static <T> java.util.List<T> selectByType​(Collection<T> collection, TypeDescriptor<?> type, boolean byKind, boolean negate)
      Returns the selection of elements from collection complying to the given type.
      protected static <T> void selectByType​(Collection<T> collection, TypeDescriptor<?> type, java.util.Collection<T> result, boolean byKind, boolean negate)
      Calculates the selection of elements from collection complying to the given type.
      protected java.util.List<T> sortAlphaImpl()
      Implements the sortAlpha function.
      static <T> java.util.List<T> sortImpl​(java.util.Iterator<T> iter, ExpressionEvaluator evaluator)
      Sorts the elements in iter (take numbers if the evaluator returns numbers, else lexicographic sort).
      protected java.util.List<T> sortImpl​(ExpressionEvaluator evaluator)
      Implements the more generic sort function (take numbers if the evaluator returns numbers, else lexicographic sort).
      T sum()
      Returns the sum of all elements.
      private static <K,​V>
      java.util.List<V>
      toEntryList​(java.util.Map<K,​java.util.List<V>> map)
      Turns the multi-entry map into a list of single elements, preserving the sequence of the elements in the individual lists in map.
      static <T> java.util.List<T> union​(Collection<T> c1, Collection<T> c2)
      Compute the union of c1 and c2 (without duplicates).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • NUMBER_COMPARATOR

        public static final java.util.Comparator<java.lang.Number> NUMBER_COMPARATOR
    • Constructor Detail

      • AbstractCollectionWrapper

        public AbstractCollectionWrapper()
    • Method Detail

      • equals

        public static boolean equals​(Collection<?> c1,
                                     Collection<?> c2)
        Returns whether two collection contains the same elements in the same sequence than elements.
        Parameters:
        c1 - the first collection to be compared
        c2 - the second collection to be compared
        Returns:
        true if both collections contain the same elements in the same sequence, false else
      • sameElements

        public static boolean sameElements​(Collection<?> c1,
                                           Collection<?> c2)
        Returns whether two collections contain the same elements regardless of their sequence.
        Parameters:
        c1 - the first collection
        c2 - the second collection
        Returns:
        true if both collections contain the same elements, false else
      • union

        public static <T> java.util.List<T> union​(Collection<T> c1,
                                                  Collection<T> c2)
        Compute the union of c1 and c2 (without duplicates).
        Type Parameters:
        T - the element type
        Parameters:
        c1 - the first collection to be considered
        c2 - the second collection to be considered
        Returns:
        the union of c1 and c2
      • intersection

        public static <T> java.util.List<T> intersection​(Collection<T> c1,
                                                         Collection<T> c2)
        Returns the intersection of c1 and c2.
        Type Parameters:
        T - the element type
        Parameters:
        c1 - the first collection to be considered
        c2 - the second collection to be considered
        Returns:
        the intersection of c1 and c2
      • excluding

        public static <T> java.util.List<T> excluding​(Collection<T> base,
                                                      Collection<?> elements)
        Returns all elements from base not containing those in elements.
        Type Parameters:
        T - the element type
        Parameters:
        base - the base collection to exclude the elements from
        elements - the elements which must not be in the result
        Returns:
        the projected result
      • including

        public static <T> java.util.List<T> including​(Collection<T> base,
                                                      Collection<T> elements)
        Returns all elements from base including those in elements.
        Type Parameters:
        T - the element type
        Parameters:
        base - the base collection to include the elements to
        elements - the elements which must also be in the result
        Returns:
        the projected result
      • append

        public static <T> java.util.List<T> append​(Collection<T> base,
                                                   Collection<T> elements)
        Appends all elements from elements to base.
        Type Parameters:
        T - the element type
        Parameters:
        base - the base collection to include the elements to
        elements - the elements which shall be appended
        Returns:
        the projected result
      • selectByType

        public static <T> java.util.List<T> selectByType​(Collection<T> collection,
                                                         TypeDescriptor<?> type,
                                                         boolean byKind,
                                                         boolean negate)
        Returns the selection of elements from collection complying to the given type.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection to analyze
        type - the type to select for
        byKind - select by kind (true, including subclasses) or by type equality false
        negate - negate the selection
        Returns:
        the elements of type type
      • selectByType

        protected static <T> void selectByType​(Collection<T> collection,
                                               TypeDescriptor<?> type,
                                               java.util.Collection<T> result,
                                               boolean byKind,
                                               boolean negate)
        Calculates the selection of elements from collection complying to the given type.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection to analyze
        type - the type to select for
        result - the elements of type type (modified as a side effect)
        negate - negate the selection
        byKind - select by kind (true, including subclasses) or by type equality false
      • isSelectedByType

        private static boolean isSelectedByType​(TypeDescriptor<?> type,
                                                java.lang.Object element,
                                                boolean byKind,
                                                boolean negate)
        Returns whether type selection matches.
        Parameters:
        type - the type to be considered (may be null, than this parameter is ignored)
        element - the element to test
        byKind - do the selection by subtyping (true) or by equality (false)
        negate - negate the result
        Returns:
        true if types match, false else
      • select

        public static <T> java.util.List<T> select​(Collection<T> collection,
                                                   ExpressionEvaluator evaluator,
                                                   boolean select)
                                            throws VilException
        Selects those elements from collection which comply to the result of evaluator.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection to select from
        evaluator - the evaluator instance
        select - do a select (true) or a reject (false)
        Returns:
        the selected elements
        Throws:
        VilException - in case that evaluation or selection fails
      • select

        protected static <T> T select​(Collection<T> collection,
                                      ExpressionEvaluator evaluator,
                                      java.util.Collection<T> result,
                                      boolean select)
                               throws VilException
        Selects those elements from collection which comply to the result of evaluator.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection to select from
        evaluator - the evaluator instance
        result - the elements of type type (modified as a side effect) - may be null then stop at first match
        select - do a select (true) or a reject (false)
        Returns:
        the last match
        Throws:
        VilException - in case that evaluation or selection fails
      • assertBooleanIterator

        private static boolean assertBooleanIterator​(ExpressionEvaluator evaluator)
                                              throws VilException
        Asserts an iterator of boolean type.
        Parameters:
        evaluator - the evaluator to check
        Returns:
        whether the actual iterator is also a decision variable
        Throws:
        VilException - in case that evaluation
      • any

        public T any​(ExpressionEvaluator evaluator)
              throws VilException
        Description copied from interface: Collection
        Returns any element complying with the evaluator.
        Specified by:
        any in interface Collection<T>
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        one element complying with evaluator
        Throws:
        VilException - in case that application fails
      • any

        public static <T> T any​(Collection<T> collection,
                                ExpressionEvaluator evaluator)
                         throws VilException
        Returns the first match from collection.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection
        evaluator - the evaluator to check
        Returns:
        the first match or null
        Throws:
        VilException - in case that evaluation
      • exists

        public static <T> java.lang.Boolean exists​(Collection<T> collection,
                                                   ExpressionEvaluator evaluator)
                                            throws VilException
        Returns whether there is an element matching the evaluator.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection
        evaluator - the evaluator to check
        Returns:
        true there is one, false else
        Throws:
        VilException - in case that evaluation
      • forAll

        public static <T> java.lang.Boolean forAll​(Collection<T> collection,
                                                   ExpressionEvaluator evaluator)
                                            throws VilException
        Returns whether there is an element matching the evaluator.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection
        evaluator - the evaluator to check
        Returns:
        true there is one, false else
        Throws:
        VilException - in case that evaluation
      • isUnique

        public static <T> java.lang.Boolean isUnique​(Collection<T> collection,
                                                     ExpressionEvaluator evaluator)
                                              throws VilException
        Returns whether there is an element matching the evaluator.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection
        evaluator - the evaluator to check
        Returns:
        true there is one, false else
        Throws:
        VilException - in case that evaluation
      • exists

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

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

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

        public static <T> T one​(Collection<T> collection,
                                ExpressionEvaluator evaluator)
                         throws VilException
        Returns the first match from collection if there can be only one match.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection
        evaluator - the evaluator to check
        Returns:
        the first and only match or null
        Throws:
        VilException - in case that evaluation
      • one

        public T one​(ExpressionEvaluator evaluator)
              throws VilException
        Description copied from interface: Collection
        Returns the element complying with the evaluator if there is exactly one.
        Specified by:
        one in interface Collection<T>
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the element complying with evaluator
        Throws:
        VilException - in case that evaluation fails
      • getFlattenedParams

        public TypeDescriptor<?>[] getFlattenedParams​(Collection<?> collection)
        Returns the type parameters for a flattened collection.
        Parameters:
        collection - the original collection
        Returns:
        the flattened type parameter(s)
      • flatten

        protected static <T1,​T2> void flatten​(Collection<T1> collection,
                                                    java.util.Collection<T2> result)
                                             throws VilException
        Flattens a collection.
        Type Parameters:
        T1 - the element type of the input collection
        T2 - the element type of the result collection
        Parameters:
        collection - the VIL collection to flatten
        result - the result (to be modified as a side effect)
        Throws:
        VilException - in case that a single element value cannot be added to the result collection
      • flatten

        private static <T1,​T2> void flatten​(T1 value,
                                                  java.util.Collection<T2> result)
                                           throws VilException
        Flattens an element value (may contain a Java collection).
        Type Parameters:
        T1 - the element type
        T2 - the element type of the result collection
        Parameters:
        value - the element value
        result - the result (to be modified as a side effect)
        Throws:
        VilException - in case that a single element value cannot be added to the result collection
      • isSelected

        private static boolean isSelected​(boolean selectionCriterion,
                                          boolean select)
        Determines whether an element is selected.
        Parameters:
        selectionCriterion - the original criterion
        select - select or reject (negate)
        Returns:
        true for selected, false else
      • apply

        public static <T> java.lang.Object apply​(Collection<T> collection,
                                                 ExpressionEvaluator evaluator)
                                          throws VilException
        Processes elements in this set by applying to given expression.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the collection to iterate over
        evaluator - the evaluator holding the iterator / expression to apply
        Returns:
        the aggregated result, null in case of a non-aggregating evaluation
        Throws:
        VilException - in case that evaluator fails
      • closure

        public static java.util.Set<java.lang.Object> closure​(Collection<?> collection,
                                                              ExpressionEvaluator evaluator)
                                                       throws VilException
        Calculates the closure over collection and evaluator.
        Parameters:
        collection - the collection to operate on
        evaluator - the evaluator used to determine the next closure elements
        Returns:
        the closure
        Throws:
        VilException - in case that evaluation fails
      • isAcyclic

        public boolean isAcyclic​(ExpressionEvaluator evaluator)
                          throws VilException
        Returns whether the closure over this collection and evaluator is acyclic.
        Specified by:
        isAcyclic in interface Collection<T>
        Parameters:
        evaluator - the evaluator
        Returns:
        true for acyclic, false for cyclic
        Throws:
        VilException - in case that evaluation fails
      • isAcyclic

        public static boolean isAcyclic​(Collection<?> collection,
                                        ExpressionEvaluator evaluator)
                                 throws VilException
        Returns whether the closure over collection and evaluator is acyclic.
        Parameters:
        collection - the collection to run over
        evaluator - the evaluator
        Returns:
        true for acyclic, false for cyclic
        Throws:
        VilException - in case that evaluation fails
      • closureOnElement

        private static boolean closureOnElement​(java.lang.Object value,
                                                java.util.Set<java.lang.Object> result,
                                                ExpressionEvaluator evaluator,
                                                boolean stopOnCycle)
                                         throws VilException
        Calculates the closure for value using evaluator and does not visit already visited elements in result again.
        Parameters:
        value - the value to calculate the closure on
        result - the result
        evaluator - the evaluator
        stopOnCycle - whether iteration/recursion shall stop immediately if a cycle is detected
        Returns:
        true if a cycle was detected, false else
        Throws:
        VilException - in case that evaluator fails
      • collect

        public static java.util.List<java.lang.Object> collect​(Collection<?> collection,
                                                               ExpressionEvaluator evaluator,
                                                               boolean flatten)
                                                        throws VilException
        Collects the application of evaluator to collection.
        Parameters:
        collection - the collection to select from
        evaluator - the evaluator instance
        flatten - flatten the result
        Returns:
        the application results
        Throws:
        VilException - in case that evaluation fails
      • collect

        protected static void collect​(Collection<?> collection,
                                      ExpressionEvaluator evaluator,
                                      java.util.Collection<java.lang.Object> result,
                                      boolean flatten)
                               throws VilException
        Collects the application of evaluator to collection.
        Parameters:
        collection - the collection to select from
        evaluator - the evaluator instance
        result - the elements of type type (modified as a side effect)
        flatten - flatten the result
        Throws:
        VilException - in case that evaluation fails
      • collect

        private static void collect​(java.lang.Object value,
                                    ExpressionEvaluator evaluator,
                                    java.util.Collection<java.lang.Object> result,
                                    boolean flatten)
                             throws VilException
        Performs a (non-)flattening collect operation on value.
        Parameters:
        value - the value to collect
        evaluator - the evaluator to apply on value
        result - the result collection to fill as a side effect
        flatten - whether the result shall be flattened or nesting shall be kept
        Throws:
        VilException - in case that evaluation fails
      • createSubCollection

        private static java.util.Collection<java.lang.Object> createSubCollection​(java.util.Collection<java.lang.Object> parent,
                                                                                  java.lang.Object template,
                                                                                  boolean flatten)
        Creates a sub-collection for non-flattened collect operations.
        Parameters:
        parent - the parent collection the sub-collection shall be added to
        template - the template defining the type (set or sequence)
        flatten - whether the result shall be flattened or nesting shall be kept
        Returns:
        the sub-collection or parent if no sub-collection can be created
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Collection
        Returns whether the collection is empty.
        Specified by:
        isEmpty in interface Collection<T>
        Returns:
        true if it is empty, false else
      • isNotEmpty

        public boolean isNotEmpty()
        Description copied from interface: Collection
        Returns whether the collection is not empty (inverse of Collection.isEmpty().
        Specified by:
        isNotEmpty in interface Collection<T>
        Returns:
        false if it is empty, true else
      • includes

        public boolean includes​(T element)
        Description copied from interface: Collection
        Returns whether this collection contains a certain element.
        Specified by:
        includes in interface Collection<T>
        Parameters:
        element - the element to look for
        Returns:
        true if this collection contains element, false else
      • excludes

        public boolean excludes​(T element)
        Description copied from interface: Collection
        Returns whether this collection does not contain a certain element.
        Specified by:
        excludes in interface Collection<T>
        Parameters:
        element - the element to look for
        Returns:
        true if this collection does not contain element, true else
      • count

        public int count​(T element)
        Description copied from interface: Collection
        Returns the number of elements in this collection which are equal to element.
        Specified by:
        count in interface Collection<T>
        Parameters:
        element - the element to look for
        Returns:
        the number of equal elements in this collection
      • sortAlphaImpl

        protected java.util.List<T> sortAlphaImpl()
        Implements the sortAlpha function.
        Returns:
        a sorted (internal) list
      • getList

        private static <K,​V> java.util.List<V> getList​(java.util.Map<K,​java.util.List<V>> map,
                                                             K key)
        Returns a list indicated by key from the multi-entry map. Creates a new list if it does not exist.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        map - the map to be modified as a side effect
        key - the key
        Returns:
        the list containing entries assigned to key, potentially a new list
      • toEntryList

        private static <K,​V> java.util.List<V> toEntryList​(java.util.Map<K,​java.util.List<V>> map)
        Turns the multi-entry map into a list of single elements, preserving the sequence of the elements in the individual lists in map.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        map - the map to be modified as a side effect
        Returns:
        the list of elements
      • sortImpl

        protected java.util.List<T> sortImpl​(ExpressionEvaluator evaluator)
                                      throws VilException
        Implements the more generic sort function (take numbers if the evaluator returns numbers, else lexicographic sort).
        Parameters:
        evaluator - the evaluator
        Returns:
        a sorted sequence
        Throws:
        VilException - in case of evaluation problems
      • sortImpl

        public static <T> java.util.List<T> sortImpl​(java.util.Iterator<T> iter,
                                                     ExpressionEvaluator evaluator)
                                              throws VilException
        Sorts the elements in iter (take numbers if the evaluator returns numbers, else lexicographic sort).
        Type Parameters:
        T - the data type
        Parameters:
        iter - the iterator holding the data
        evaluator - the evaluator
        Returns:
        the sorted sequence from iter
        Throws:
        VilException - in case of evaluation problems
      • revertImpl

        protected java.util.List<T> revertImpl()
        Implements the revert operation.
        Returns:
        the reverted list
      • constructType

        protected static TypeDescriptor<?> constructType​(TypeDescriptor<?>[] param,
                                                         boolean set)
        Constructs a collection type.
        Parameters:
        param - the parameter
        set - whether the result shall represent a set or a sequence
        Returns:
        the constructed type
      • sum

        public T sum()
        Description copied from interface: Collection
        Returns the sum of all elements.
        Specified by:
        sum in interface Collection<T>
        Returns:
        the sum of all elements or null if the elements do not define addition
      • avg

        public java.lang.Object avg()
        Description copied from interface: Collection
        Returns the average of all elements.
        Specified by:
        avg in interface Collection<T>
        Returns:
        the average of all elements or null if the elements do not define addition or division
      • product

        public T product()
        Description copied from interface: Collection
        Returns the product of all elements.
        Specified by:
        product in interface Collection<T>
        Returns:
        the product of all elements or null if the elements do not define multiplication
      • min

        public T min()
        Description copied from interface: Collection
        Returns the minimum of all elements.
        Specified by:
        min in interface Collection<T>
        Returns:
        the minimum of all elements or null if the elements do not define the minimum operation
      • max

        public T max()
        Description copied from interface: Collection
        Returns the maximum of all elements.
        Specified by:
        max in interface Collection<T>
        Returns:
        the maximum of all elements or null if the elements do not define the maximum operation
      • getElementType

        private static TypeDescriptor<?> getElementType​(Collection<?> collection)
        Returns the element type of collection.
        Parameters:
        collection - the collection
        Returns:
        the element type
      • aggregate

        public static <T> T aggregate​(Collection<T> collection,
                                      java.lang.String opName)
        Aggregates elements over collection by resolving the given operation over the element type of the collection.
        Type Parameters:
        T - the element type of the collection
        Parameters:
        collection - the collection
        opName - denotes an operation on the elements of this collection. The operation must be binary (2 parameters) on the element type of this collection and return a type that is assignable to the element type of this collection
        Returns:
        the aggregated result or null if undefined/aggregation not possible
      • includesAll

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

        public boolean excludesAll​(Collection<?> elements)
        Description copied from interface: Collection
        Returns whether this collection contains no elements from elements.
        Specified by:
        excludesAll in interface Collection<T>
        Parameters:
        elements - the elements to look for
        Returns:
        true if this collection contains none from elements, false else
      • containsAll

        public static boolean containsAll​(Collection<?> base,
                                          Collection<?> elements,
                                          boolean negate)
        Returns whether all elements in elements are also in base collection.
        Parameters:
        base - the base collection
        elements - the elements to check for
        negate - whether the result shall be negated, i.e., it shall be checked for not being member of this collection
        Returns:
        true if (non-)containment holds for all elements