Class Key1Set.Builder<E,K>

Enclosing class:
Key1Set<E,K>

public static class Key1Set.Builder<E,K> extends Key1Collection.Builder<E,K>
Builder to construct Key1Set instances.
  • Constructor Details

    • Builder

      public Builder()
      Default constructor.
    • Builder

      Builder(Key1Set<E,K> keySet)
      Private constructor used if extending KeySet.
      Parameters:
      keySet - key set
  • Method Details

    • build

      public Key1Set<E,K> build()
      Overrides:
      build in class Key1Collection.Builder<E,K>
      Returns:
      created collection
    • withSetBehavior

      public Key1Set.Builder<E,K> 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 Key1Set only supports set behavior, so an exception is thrown if the argument is false.

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

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

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

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

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

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

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

      public Key1Set.Builder<E,K> withNull(boolean allowNull)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specifies whether null elements are allowed or not. A null element will have null keys. This method does not implicitly create an element set, where as KeyCollectionImpl.BuilderImpl.withElemNull(boolean) does.
      Overrides:
      withNull in class Key1Collection.Builder<E,K>
      Parameters:
      allowNull - true to allow null elements (default), false to disallow
      Returns:
      this (fluent interfaces)
    • withConstraint

      public Key1Set.Builder<E,K> withConstraint(Predicate<E> constraint)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify element constraint.
      Overrides:
      withConstraint in class Key1Collection.Builder<E,K>
      Parameters:
      constraint - constraint element must satisfy, null for none (default)
      Returns:
      this (fluent interface)
    • withBeforeInsertTrigger

      public Key1Set.Builder<E,K> withBeforeInsertTrigger(Consumer<E> trigger)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify insert trigger.
      Overrides:
      withBeforeInsertTrigger in class Key1Collection.Builder<E,K>
      Parameters:
      trigger - insert trigger method, null for none (default)
      Returns:
      this (fluent interface)
    • withAfterInsertTrigger

      public Key1Set.Builder<E,K> withAfterInsertTrigger(Consumer<E> trigger)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify insert trigger.
      Overrides:
      withAfterInsertTrigger in class Key1Collection.Builder<E,K>
      Parameters:
      trigger - insert trigger method, null for none (default)
      Returns:
      this (fluent interface)
    • withBeforeDeleteTrigger

      public Key1Set.Builder<E,K> withBeforeDeleteTrigger(Consumer<E> trigger)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify delete trigger.
      Overrides:
      withBeforeDeleteTrigger in class Key1Collection.Builder<E,K>
      Parameters:
      trigger - delete trigger method, null for none (default)
      Returns:
      this (fluent interface)
    • withAfterDeleteTrigger

      public Key1Set.Builder<E,K> withAfterDeleteTrigger(Consumer<E> trigger)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify delete trigger.
      Overrides:
      withAfterDeleteTrigger in class Key1Collection.Builder<E,K>
      Parameters:
      trigger - delete trigger method, null for none (default)
      Returns:
      this (fluent interface)
    • withCapacity

      public Key1Set.Builder<E,K> withCapacity(int capacity)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify initial capacity.
      Overrides:
      withCapacity in class Key1Collection.Builder<E,K>
      Parameters:
      capacity - initial capacity
      Returns:
      this (fluent interface)
    • withContent

      public Key1Set.Builder<E,K> withContent(Collection<? extends E> elements)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify elements added to the collection upon creation.
      Overrides:
      withContent in class Key1Collection.Builder<E,K>
      Parameters:
      elements - initial elements
      Returns:
      this (fluent interface)
    • withContent

      public Key1Set.Builder<E,K> withContent(E... elements)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify elements added to the collection upon creation.
      Overrides:
      withContent in class Key1Collection.Builder<E,K>
      Parameters:
      elements - initial elements
      Returns:
      this (fluent interface)
    • withMaxSize

      public Key1Set.Builder<E,K> withMaxSize(int maxSize)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify maximum size of collection. If an attempt is made to add more elements, an exception is thrown.
      Overrides:
      withMaxSize in class Key1Collection.Builder<E,K>
      Parameters:
      maxSize - maximum size
      Returns:
      this (fluent interface)
    • withElemCount

      public Key1Set.Builder<E,K> 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 Key1Set does not support duplicates, so an exception is thrown if the argument is true.

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

      public Key1Set.Builder<E,K> withElemSet()
      Add element map (with ident mapper).

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

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

      public Key1Set.Builder<E,K> 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 Key1Collection.Builder<E,K>
      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)
    • withElemNull

      public Key1Set.Builder<E,K> withElemNull(boolean allowNull)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specifies whether null elements are allowed or not. A null element will have null keys. This method does implicitly create an element set, where as KeyCollectionImpl.BuilderImpl.withNull(boolean) does not.
      Overrides:
      withElemNull in class Key1Collection.Builder<E,K>
      Parameters:
      allowNull - true to allow null elements, false to disallow (default is true)
      Returns:
      this (fluent interfaces)
    • withElemSort

      public Key1Set.Builder<E,K> 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 Key1Collection.Builder<E,K>
      Parameters:
      sort - true to sorted, false for unsorted (default is false)
      Returns:
      this (fluent interface)
    • withElemSort

      public Key1Set.Builder<E,K> withElemSort(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 Key1Collection.Builder<E,K>
      Parameters:
      comparator - comparator to use for sorting (null for natural comparator)
      Returns:
      this (fluent interface)
    • withElemSort

      public Key1Set.Builder<E,K> withElemSort(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 Key1Collection.Builder<E,K>
      Parameters:
      comparator - comparator to use for sorting
      sortNullsFirst - true to sort null values first, false for last
      Returns:
      this (fluent interface)
    • withPrimaryElem

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

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

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

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

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

      Overrides:
      withUniqueElem in class Key1Collection.Builder<E,K>
      Returns:
      this (fluent interface)
    • withKey1Map

      public Key1Set.Builder<E,K> withKey1Map(Function<? super E,K> mapper)
      Add key map.
      Overrides:
      withKey1Map in class Key1Collection.Builder<E,K>
      Parameters:
      mapper - mapper to use
      Returns:
      this (fluent interface)
    • withPrimaryKey1Map

      public Key1Set.Builder<E,K> withPrimaryKey1Map(Function<? super E,K> mapper)
      Specify this key to be a primary key. This is identical to calling withKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false).
      Overrides:
      withPrimaryKey1Map in class Key1Collection.Builder<E,K>
      Parameters:
      mapper - mapper to use
      Returns:
      this (fluent interface)
    • withUniqueKey1Map

      public Key1Set.Builder<E,K> withUniqueKey1Map(Function<? super E,K> mapper)
      Specify this key to be a unique key. This is identical to calling withKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true).
      Overrides:
      withUniqueKey1Map in class Key1Collection.Builder<E,K>
      Parameters:
      mapper - mapper to use
      Returns:
      this (fluent interface)
    • withOrderByKey1

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

      public Key1Set.Builder<E,K> withKey1Null(boolean allowNull)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify whether null elements are allowed or not. A null element will have a null key.
      Overrides:
      withKey1Null in class Key1Collection.Builder<E,K>
      Parameters:
      allowNull - true to allow null elements, false to disallow
      Returns:
      this (fluent interfaces)
    • withKey1Duplicates

      public Key1Set.Builder<E,K> withKey1Duplicates(boolean allowDuplicates)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify whether duplicates are allowed or not.
      Overrides:
      withKey1Duplicates in class Key1Collection.Builder<E,K>
      Parameters:
      allowDuplicates - true to allow duplicates
      Returns:
      this (fluent interfaces)
    • withKey1Duplicates

      public Key1Set.Builder<E,K> withKey1Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify whether duplicates are allowed or not.
      Overrides:
      withKey1Duplicates in class Key1Collection.Builder<E,K>
      Parameters:
      allowDuplicates - true to allow duplicates
      allowDuplicatesNull - true to allow duplicate null values
      Returns:
      this (fluent interfaces)
    • withKey1Sort

      public Key1Set.Builder<E,K> withKey1Sort(boolean sort)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Set comparator to use for sorting the key map. Note that this does not automatically sort the list itself, call a withOrderBy method for this.
      Overrides:
      withKey1Sort in class Key1Collection.Builder<E,K>
      Parameters:
      sort - true to sort key map
      Returns:
      this (fluent interface)
    • withKey1Sort

      public Key1Set.Builder<E,K> withKey1Sort(Comparator<? super K> comparator)
      Set comparator to use for sorting the key map. Note that this does not automatically sort the collection itself, call a withOrderBy method for this.
      Overrides:
      withKey1Sort in class Key1Collection.Builder<E,K>
      Parameters:
      comparator - comparator to use for sorting
      Returns:
      this (fluent interface)
    • withKey1Sort

      public Key1Set.Builder<E,K> withKey1Sort(Comparator<? super K> comparator, boolean sortNullsFirst)
      Set comparator to use for sorting the key map. Note that this does not automatically sort the collection itself, call a withOrderBy method for this.
      Overrides:
      withKey1Sort in class Key1Collection.Builder<E,K>
      Parameters:
      comparator - comparator to use for sorting
      sortNullsFirst - true if null will be sorted first, false for last
      Returns:
      this (fluent interface)