Class KeySet.Builder<E>

    • Constructor Detail

      • Builder

        public Builder()
        Default constructor.
      • Builder

        Builder​(KeySet<E> keySet)
        Private constructor used if extending KeySet.
        Parameters:
        keySet - key set
    • Method Detail

      • withSetBehavior

        public KeySet.Builder<E> withSetBehavior​(boolean setBehavior)
        Specifies that the collection behaves like a Set on adding elements, i.e. if an element cannot be added due to duplicate or other constraints, no exception is thrown.

        Note that KeySet only supports set behavior, so an exception is thrown if the argument is false.

        Overrides:
        withSetBehavior in class KeyCollection.Builder<E>
        Parameters:
        setBehavior - true to define set behavior (default is false)
        Returns:
        this (fluent interface)
      • withElemDuplicates

        public KeySet.Builder<E> withElemDuplicates​(boolean allowDuplicates)
        Specify whether duplicates are allowed or not. This method does implicitly create an element set.

        Note that KeySet does not support duplicates, so an exception is thrown if the argument is true.

        Overrides:
        withElemDuplicates in class KeyCollection.Builder<E>
        Parameters:
        allowDuplicates - true to allow duplicates (default is true)
        Returns:
        this (fluent interfaces)
      • withElemDuplicates

        public KeySet.Builder<E> withElemDuplicates​(boolean allowDuplicates,
                                                    boolean allowDuplicatesNull)
        Specify whether duplicates are allowed or not. This method does implicitly create an element set.

        Note that KeySet does not support duplicates, so an exception is thrown if any argument is true.

        Overrides:
        withElemDuplicates in class KeyCollection.Builder<E>
        Parameters:
        allowDuplicates - true to allow duplicates (default is true)
        allowDuplicatesNull - true to allow duplicate null values (default is true)
        Returns:
        this (fluent interfaces)
      • withElemCount

        public KeySet.Builder<E> withElemCount​(boolean count)
        Specifies that the collection only counts the number of occurrences of equal elements, but does not store the elements themselves.

        Note that KeySet does not support duplicates, so an exception is thrown if the argument is true.

        Overrides:
        withElemCount in class KeyCollection.Builder<E>
        Parameters:
        count - true to count only number of occurrences (default is false)
        Returns:
        this (fluent interface)
      • withElemSet

        public KeySet.Builder<E> withElemSet()
        Add element map (with ident mapper).

        Note that a KeyCollection always has an element set, so this call is not necessary.

        Note that a KeySet always has an element set, so this call is not necessary.

        Overrides:
        withElemSet in class KeyCollection.Builder<E>
        Returns:
        this (fluent interface)
      • withOrderByElem

        public KeySet.Builder<E> withOrderByElem​(boolean orderBy)
        Description copied from class: KeyCollectionImpl.BuilderImpl
        Specifies that the collection will have the order of the element set. The element set must be sorted, if no sort order has been defined, the natural comparator will be used. If the set allows null values, the used comparator will sort them last.
        Overrides:
        withOrderByElem in class KeyCollection.Builder<E>
        Parameters:
        orderBy - if true the collection will have the order of the element set (default is false, only one key map or the element set can have the order by option set)
        Returns:
        this (fluent interface)
      • withElemSort

        public KeySet.Builder<E> withElemSort​(boolean sort)
        Description copied from class: KeyCollectionImpl.BuilderImpl
        Specify that the element set should be sorted using the natural comparator. If the collection supports null values, they are sorted last. This method does implicitly create an element set. Note that this does not automatically sort the collection itself, call a withOrderBy method for this.
        Overrides:
        withElemSort in class KeyCollection.Builder<E>
        Parameters:
        sort - true to sorted, false for unsorted (default is false)
        Returns:
        this (fluent interface)
      • withElemSort

        public KeySet.Builder<E> withElemSort​(java.util.Comparator<? super E> comparator)
        Description copied from class: KeyCollectionImpl.BuilderImpl
        Set comparator to use for sorting the element set. If the collection allows null values, the comparator must be able to compare null values. If the comparator does not support null values, use withElemSort(Comparator, boolean) to explicitly specify how null values should be sorted. This method does implicitly create an element set. Note that this does not automatically sort the collection itself, call a withOrderBy method for this.
        Overrides:
        withElemSort in class KeyCollection.Builder<E>
        Parameters:
        comparator - comparator to use for sorting (null for natural comparator)
        Returns:
        this (fluent interface)
      • withElemSort

        public KeySet.Builder<E> withElemSort​(java.util.Comparator<? super E> comparator,
                                              boolean sortNullsFirst)
        Description copied from class: KeyCollectionImpl.BuilderImpl
        Set comparator to use for sorting the element set. This method should be used if the collection can contain null values, but the comparator is not able to handle them. The parameter sortNullsFirst determine how the null values should be sorted. This method does implicitly create an element set.
        Overrides:
        withElemSort in class KeyCollection.Builder<E>
        Parameters:
        comparator - comparator to use for sorting
        sortNullsFirst - true to sort null values first, false for last
        Returns:
        this (fluent interface)
      • withPrimaryElem

        public KeySet.Builder<E> withPrimaryElem()
        Specify the element to be a primary key. This is identical to calling withElemNull(false) and withElemDuplicates(false).

        Note that a Key2Set always has an element set, so this call is not necessary.

        Overrides:
        withPrimaryElem in class KeyCollection.Builder<E>
        Returns:
        this (fluent interface)
      • withUniqueElem

        public KeySet.Builder<E> withUniqueElem()
        Specify the element to be a unique key. This is identical to calling withElemNull(true) and withElemDuplicates(false, true).

        Note that a KeySet always has an element set, so an exception is thrown.

        Overrides:
        withUniqueElem in class KeyCollection.Builder<E>
        Returns:
        this (fluent interface)