Interface Set<T>

  • Type Parameters:
    T - the element type
    All Superinterfaces:
    Collection<T>, IStringValueProvider, java.lang.Iterable<T>, IVilGenericType, IVilType
    All Known Implementing Classes:
    ArraySet, FixedListSet, ListSet, OtherProjects, SetSet, UnmodifiableSet

    public interface Set<T>
    extends Collection<T>
    Defines the interface representing a set. The iterator is an internal type which is not registered in the TypeRegistry. Please note that iterator with one type parameter will be represented by the iterator itself, iterators over multiple types by an iterator over an object array of instances which can be cast into the given types. This interface and Sequence shall not be applied together in one class!
    Author:
    Holger Eichelberger
    • Field Detail

      • DEFAULT

        static final java.util.Set<?> DEFAULT
    • Method Detail

      • selectByType

        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>
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • selectByKind

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

        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>
        Parameters:
        type - the target type
        Returns:
        the selected elements (the type will be adjusted to the actual type for type)
      • excluding

        Set<T> excluding​(Collection<T> set)
        Exclude the elements in set.
        Parameters:
        set - the elements to be excluded
        Returns:
        this set without the elements in set
      • including

        Set<T> including​(Collection<T> set)
        Include the elements in set. Duplicates will not be included.
        Parameters:
        set - the elements to be excluded
        Returns:
        this set without the elements in set
      • union

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

        Set<T> intersection​(Set<T> set)
        Returns the intersection of this set with set.
        Parameters:
        set - the elements to be unified with this set
        Returns:
        the intersection of this set and set
      • add

        T add​(T element)
        Adds an element to this set.
        Parameters:
        element - the element to be added
        Returns:
        element
      • remove

        boolean remove​(T element)
        Removes the given element from this sequence.
        Parameters:
        element - the element to be removed
        Returns:
        true of the element was removed, false else
      • select

        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>
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the selected elements
        Throws:
        VilException - in case that evaluation fails
      • reject

        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>
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the rejected elements
        Throws:
        VilException - in case that evaluation fails
      • closure

        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>
        Parameters:
        evaluator - the evaluator providing the links/collections to follow
        Returns:
        the closure
        Throws:
        VilException - in case that evaluation fails
      • collect

        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>
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the application results
        Throws:
        VilException - in case that evaluation fails
      • collectNested

        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>
        Parameters:
        evaluator - the evaluator (results must evaluate to Boolean)
        Returns:
        the application results
        Throws:
        VilException - in case that evaluation fails
      • toSequence

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

        T projectSingle()
        In case that the sequence has exactly one element, this will be returned.
        Returns:
        the only element or null
      • toMappedSet

        java.util.Set<T> toMappedSet()
        Converts back to a set for utilizing this with external classes.
        Returns:
        the internal map
      • flatten

        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>
        Returns:
        the flattened collection
        Throws:
        VilException - in case of type incompatibilities
      • difference

        Set<T> difference​(Set<T> set)
        Calculates the difference between this and the given set.
        Parameters:
        set - the set to calculate the difference for
        Returns:
        the set difference
      • symmetricDifference

        Set<T> symmetricDifference​(Set<T> set)
        Calculates the symmetric difference between this and the given set.
        Parameters:
        set - the set to calculate the difference for
        Returns:
        the symmetric set difference
      • cloneCollection

        Set<T> cloneCollection()
        Description copied from interface: Collection
        Clones this collection. (QVT)
        Specified by:
        cloneCollection in interface Collection<T>
        Returns:
        a clone of this collection