Class ListSet<T>

    • Constructor Detail

      • ListSet

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

        public ListSet​(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
      • ListSet

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

      • selectByType

        public Set<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 Set<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: Collection
        Does type selection of elements (including subtypes).
        Specified by:
        selectByKind in interface Collection<T>
        Specified by:
        selectByKind in interface Set<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: 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 Set<T>
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • excluding

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

        public Set<T> including​(Collection<T> set)
        Description copied from interface: Set
        Include the elements in set. Duplicates will not be included.
        Specified by:
        including in interface Set<T>
        Parameters:
        set - the elements to be excluded
        Returns:
        this set without the elements in set
      • flatten

        public Set<?> flatten()
                       throws VilException
        Description copied from interface: Collection
        Flattens this collection if needed, i.e., flatten sub-collections.
        Specified by:
        flatten in interface Collection<T>
        Specified by:
        flatten in interface Set<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: Collection
        Selects elements in this collection according to the given expression.
        Specified by:
        select in interface Collection<T>
        Specified by:
        select in interface Set<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: Collection
        Rejects elements in this collection according to the given expression.
        Specified by:
        reject in interface Collection<T>
        Specified by:
        reject in interface Set<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: 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 Set<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: Collection
        Collects the application of evaluator to each individual element and keeps nested structures.
        Specified by:
        collectNested in interface Collection<T>
        Specified by:
        collectNested in interface Set<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 Set<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
      • toSequence

        public Sequence<T> toSequence()
        Description copied from interface: Set
        Turns this set into a sequence.
        Specified by:
        toSequence in interface Set<T>
        Returns:
        the set containing the elements of this set
      • 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
      • 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)
      • projectSingle

        public T projectSingle()
        Description copied from interface: Set
        In case that the sequence has exactly one element, this will be returned.
        Specified by:
        projectSingle in interface Set<T>
        Returns:
        the only element or null
      • empty

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

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

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

        public Set<T> union​(Set<T> set)
        Compute the union of this set and set (without duplicates).
        Specified by:
        union in interface Set<T>
        Parameters:
        set - the elements to be unified with this set
        Returns:
        the union of this set and set
      • intersection

        public Set<T> intersection​(Set<T> set)
        Returns the intersection of this set with set.
        Specified by:
        intersection in interface Set<T>
        Parameters:
        set - the elements to be unified with this set
        Returns:
        the union of this set and set
      • difference

        public Set<T> difference​(Set<T> set)
        Description copied from interface: Set
        Calculates the difference between this and the given set.
        Specified by:
        difference in interface Set<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: Set
        Calculates the symmetric difference between this and the given set.
        Specified by:
        symmetricDifference in interface Set<T>
        Parameters:
        set - the set to calculate the difference for
        Returns:
        the symmetric set difference