Class Key2List.Builder<E,K1,K2>

java.lang.Object
org.magicwerk.brownies.collections.KeyCollectionImpl.BuilderImpl<E>
org.magicwerk.brownies.collections.Key2List.Builder<E,K1,K2>
Enclosing class:
Key2List<E,K1,K2>

public static class Key2List.Builder<E,K1,K2> extends KeyCollectionImpl.BuilderImpl<E>
Builder to construct Key2List instances.
  • Constructor Details

    • Builder

      public Builder()
      Default constructor.
    • Builder

      Builder(Key2List<E,K1,K2> keyList)
      Private constructor used if extending Key2List.
      Parameters:
      keyList - key list
  • Method Details

    • withNull

      public Key2List.Builder<E,K1,K2> 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 KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      allowNull - true to allow null elements (default), false to disallow
      Returns:
      this (fluent interfaces)
    • withConstraint

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

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

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

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

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

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

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

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

      public Key2List.Builder<E,K1,K2> 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 KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      maxSize - maximum size
      Returns:
      this (fluent interface)
    • withWindowSize

      public Key2List.Builder<E,K1,K2> withWindowSize(int maxSize)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify maximum window size of collection. If an attempt is made to add and additional element, the first element is removed.
      Overrides:
      withWindowSize in class KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      maxSize - maximum window size
      Returns:
      this (fluent interface)
    • withListBig

      public Key2List.Builder<E,K1,K2> withListBig(boolean bigList)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify whether list should be stored in an instance of BigList or GapList.
      Overrides:
      withListBig in class KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      bigList - true to store list content in an instance of BigList, false for GapList
      Returns:
      this (fluent interface)
    • withElemSet

      public Key2List.Builder<E,K1,K2> withElemSet()
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Add element map (with ident mapper).
      Overrides:
      withElemSet in class KeyCollectionImpl.BuilderImpl<E>
      Returns:
      this (fluent interface)
    • withOrderByElem

      public Key2List.Builder<E,K1,K2> 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 KeyCollectionImpl.BuilderImpl<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)
    • withElemNull

      public Key2List.Builder<E,K1,K2> 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 KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      allowNull - true to allow null elements, false to disallow (default is true)
      Returns:
      this (fluent interfaces)
    • withElemDuplicates

      public Key2List.Builder<E,K1,K2> withElemDuplicates(boolean allowDuplicates)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify whether duplicates are allowed or not. This method does implicitly create an element set.
      Overrides:
      withElemDuplicates in class KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      allowDuplicates - true to allow duplicates (default is true)
      Returns:
      this (fluent interfaces)
    • withElemDuplicates

      public Key2List.Builder<E,K1,K2> withElemDuplicates(boolean allowDuplicates, boolean allowDuplicatesNull)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify whether duplicates are allowed or not. This method does implicitly create an element set.
      Overrides:
      withElemDuplicates in class KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      allowDuplicates - true to allow duplicates (default is true)
      allowDuplicatesNull - true to allow duplicate null values (default is true)
      Returns:
      this (fluent interfaces)
    • withElemSort

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

      public Key2List.Builder<E,K1,K2> 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 KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      comparator - comparator to use for sorting (null for natural comparator)
      Returns:
      this (fluent interface)
    • withElemSort

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

      public Key2List.Builder<E,K1,K2> withPrimaryElem()
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify the element to be a primary key. This is identical to calling withElemNull(false) and withElemDuplicates(false).
      Overrides:
      withPrimaryElem in class KeyCollectionImpl.BuilderImpl<E>
      Returns:
      this (fluent interface)
    • withUniqueElem

      public Key2List.Builder<E,K1,K2> withUniqueElem()
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specify the element to be a unique key. This is identical to calling withElemNull(true) and withElemDuplicates(false, true).
      Overrides:
      withUniqueElem in class KeyCollectionImpl.BuilderImpl<E>
      Returns:
      this (fluent interface)
    • withKey1Map

      public Key2List.Builder<E,K1,K2> withKey1Map(Function<? super E,K1> mapper)
      Add key map.
      Parameters:
      mapper - mapper to use
      Returns:
      this (fluent interface)
    • withPrimaryKey1Map

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

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

      public Key2List.Builder<E,K1,K2> 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 KeyCollectionImpl.BuilderImpl<E>
      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)
    • withOrderByKey1

      public Key2List.Builder<E,K1,K2> withOrderByKey1(Class<?> type)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specifies that the list will have the order of the key map. The key map will store values of the primitive type specified like int. The key map will be sorted using the natural comparator and no null values are allowed.
      Overrides:
      withOrderByKey1 in class KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      type - primitive type to use for key map (only one key map or the element set can have the order by option set)
      Returns:
      this (fluent interface)
    • withKey1Null

      public Key2List.Builder<E,K1,K2> 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 KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      allowNull - true to allow null elements, false to disallow
      Returns:
      this (fluent interfaces)
    • withKey1Duplicates

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

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

      public Key2List.Builder<E,K1,K2> 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 KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      sort - true to sort key map
      Returns:
      this (fluent interface)
    • withKey1Sort

      public Key2List.Builder<E,K1,K2> withKey1Sort(Comparator<? super K1> comparator)
      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.
      Parameters:
      comparator - comparator to use for sorting
      Returns:
      this (fluent interface)
    • withKey1Sort

      public Key2List.Builder<E,K1,K2> withKey1Sort(Comparator<? super K1> comparator, boolean sortNullsFirst)
      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.
      Parameters:
      comparator - comparator to use for sorting
      sortNullsFirst - true if null will be sorted first, false for last
      Returns:
      this (fluent interface)
    • withKey2Map

      public Key2List.Builder<E,K1,K2> withKey2Map(Function<? super E,K2> mapper)
      Add key map.
      Parameters:
      mapper - mapper to use
      Returns:
      this (fluent interface)
    • withPrimaryKey2Map

      public Key2List.Builder<E,K1,K2> withPrimaryKey2Map(Function<? super E,K2> mapper)
      Specify this key to be a primary key. This is identical to calling withKey2Map(mapper), withKey2Null(false), and withKey2Duplicates(false).
      Parameters:
      mapper - mapper to use
      Returns:
      this (fluent interface)
    • withUniqueKey2Map

      public Key2List.Builder<E,K1,K2> withUniqueKey2Map(Function<? super E,K2> mapper)
      Specify this key to be a unique key. This is identical to calling withKey2Map(mapper), withKey2Null(true), and withKey2Duplicates(false, true).
      Parameters:
      mapper - mapper to use
      Returns:
      this (fluent interface)
    • withOrderByKey2

      public Key2List.Builder<E,K1,K2> withOrderByKey2(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:
      withOrderByKey2 in class KeyCollectionImpl.BuilderImpl<E>
      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)
    • withOrderByKey2

      public Key2List.Builder<E,K1,K2> withOrderByKey2(Class<?> type)
      Description copied from class: KeyCollectionImpl.BuilderImpl
      Specifies that the list will have the order of the key map. The key map will store values of the primitive type specified like int. The key map will be sorted using the natural comparator and no null values are allowed.
      Overrides:
      withOrderByKey2 in class KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      type - primitive type to use for key map (only one key map or the element set can have the order by option set)
      Returns:
      this (fluent interface)
    • withKey2Null

      public Key2List.Builder<E,K1,K2> withKey2Null(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:
      withKey2Null in class KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      allowNull - true to allow null elements, false to disallow
      Returns:
      this (fluent interfaces)
    • withKey2Duplicates

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

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

      public Key2List.Builder<E,K1,K2> withKey2Sort(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:
      withKey2Sort in class KeyCollectionImpl.BuilderImpl<E>
      Parameters:
      sort - true to sort key map
      Returns:
      this (fluent interface)
    • withKey2Sort

      public Key2List.Builder<E,K1,K2> withKey2Sort(Comparator<? super K2> comparator)
      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.
      Parameters:
      comparator - comparator to use for sorting
      Returns:
      this (fluent interface)
    • withKey2Sort

      public Key2List.Builder<E,K1,K2> withKey2Sort(Comparator<? super K2> comparator, boolean sortNullsFirst)
      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.
      Parameters:
      comparator - comparator to use for sorting
      sortNullsFirst - true if null will be sorted first, false for last
      Returns:
      this (fluent interface)
    • build

      public Key2List<E,K1,K2> build()
      Returns:
      created list