Class Key2Set.Builder<E,K1,K2>
java.lang.Object
org.magicwerk.brownies.collections.KeyCollectionImpl.BuilderImpl<E>
org.magicwerk.brownies.collections.Key2Collection.Builder<E,K1,K2>
org.magicwerk.brownies.collections.Key2Set.Builder<E,K1,K2>
Builder to construct Key2Set instances.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.magicwerk.brownies.collections.KeyCollectionImpl.BuilderImpl
KeyCollectionImpl.BuilderImpl.KeyMapBuilder<E,K> -
Field Summary
Fields inherited from class org.magicwerk.brownies.collections.KeyCollectionImpl.BuilderImpl
afterDeleteTrigger, afterInsertTrigger, allowNullElem, array, beforeDeleteTrigger, beforeInsertTrigger, capacity, collection, constraint, count, keyColl, keyList, keyMapBuilders, maxSize, movingWindow, setBehavior, useBigList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()withAfterDeleteTrigger(Consumer<E> trigger) Specify delete trigger.withAfterInsertTrigger(Consumer<E> trigger) Specify insert trigger.withBeforeDeleteTrigger(Consumer<E> trigger) Specify delete trigger.withBeforeInsertTrigger(Consumer<E> trigger) Specify insert trigger.withCapacity(int capacity) Specify initial capacity.withConstraint(Predicate<E> constraint) Specify element constraint.withContent(E... elements) Specify elements added to the collection upon creation.withContent(Collection<? extends E> elements) Specify elements added to the collection upon creation.withElemCount(boolean count) Specifies that the collection only counts the number of occurrences of equal elements, but does not store the elements themselves.withElemDuplicates(boolean allowDuplicates) Specify whether duplicates are allowed or not.withElemDuplicates(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not.withElemNull(boolean allowNull) Specifies whether null elements are allowed or not.Add element map (with ident mapper).withElemSort(boolean sort) Specify that the element set should be sorted using the natural comparator.withElemSort(Comparator<? super E> comparator) Set comparator to use for sorting the element set.withElemSort(Comparator<? super E> comparator, boolean sortNullsFirst) Set comparator to use for sorting the element set.withKey1Duplicates(boolean allowDuplicates) Specify whether duplicates are allowed or not.withKey1Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not.withKey1Map(Function<? super E, K1> mapper) Add key map.withKey1Null(boolean allowNull) Specify whether null elements are allowed or not.withKey1Sort(boolean sort) Set comparator to use for sorting the key map.withKey1Sort(Comparator<? super K1> comparator) Set comparator to use for sorting the key map.withKey1Sort(Comparator<? super K1> comparator, boolean sortNullsFirst) Set comparator to use for sorting the key map.withKey2Duplicates(boolean allowDuplicates) Specify whether duplicates are allowed or not.withKey2Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not.withKey2Map(Function<? super E, K2> mapper) Add key map.withKey2Null(boolean allowNull) Specify whether null elements are allowed or not.withKey2Sort(boolean sort) Set comparator to use for sorting the key map.withKey2Sort(Comparator<? super K2> comparator) Set comparator to use for sorting the key map.withKey2Sort(Comparator<? super K2> comparator, boolean sortNullsFirst) Set comparator to use for sorting the key map.withMaxSize(int maxSize) Specify maximum size of collection.withNull(boolean allowNull) Specifies whether null elements are allowed or not.withOrderByElem(boolean orderBy) Specifies that the collection will have the order of the element set.withOrderByKey1(boolean orderBy) Specifies that the collection will have the order of the key map.withOrderByKey2(boolean orderBy) Specifies that the collection will have the order of the key map.Specify the element to be a primary key.withPrimaryKey1Map(Function<? super E, K1> mapper) Specify this key to be a primary key.withPrimaryKey2Map(Function<? super E, K2> mapper) Specify this key to be a primary key.withSetBehavior(boolean setBehavior) Specifies that the collection behaves like aSeton adding elements, i.e.Specify the element to be a unique key.withUniqueKey1Map(Function<? super E, K1> mapper) Specify this key to be a unique key.withUniqueKey2Map(Function<? super E, K2> mapper) Specify this key to be a unique key.Methods inherited from class org.magicwerk.brownies.collections.KeyCollectionImpl.BuilderImpl
build, buildKeyMap, getKeyMapBuilder, hasElemMapBuilder, init, init, initKeyMapBuilder, initList, isFalse, isTrue, withKeyDuplicates, withKeyMap, withKeyNull, withKeySort, withKeySort, withKeySort, withListBig, withListType, withOrderByElem, withOrderByKey, withOrderByKey, withOrderByKey1, withOrderByKey2, withPrimaryKeyMap, withUniqueKeyMap, withWindowSize
-
Constructor Details
-
Builder
public Builder()Default constructor. -
Builder
Private constructor used if extending KeySet.- Parameters:
keySet- key set
-
-
Method Details
-
build
- Overrides:
buildin classKey2Collection.Builder<E,K1, K2> - Returns:
- created collection
-
withSetBehavior
Specifies that the collection behaves like aSeton adding elements, i.e. if an element cannot be added due to duplicate or other constraints, no exception is thrown.Note that
Key2Setonly supports set behavior, so an exception is thrown if the argument is false.- Overrides:
withSetBehaviorin classKey2Collection.Builder<E,K1, K2> - Parameters:
setBehavior- true to define set behavior (default is false)- Returns:
- this (fluent interface)
-
withElemDuplicates
Specify whether duplicates are allowed or not. This method does implicitly create an element set.Note that
Key2Setdoes not support duplicates, so an exception is thrown if the argument is true.- Overrides:
withElemDuplicatesin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowDuplicates- true to allow duplicates (default is true)- Returns:
- this (fluent interfaces)
-
withElemDuplicates
public Key2Set.Builder<E,K1, withElemDuplicatesK2> (boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not. This method does implicitly create an element set.Note that
Key2Setdoes not support duplicates, so an exception is thrown if any argument is true.- Overrides:
withElemDuplicatesin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowDuplicates- true to allow duplicates (default is true)allowDuplicatesNull- true to allow duplicate null values (default is true)- Returns:
- this (fluent interfaces)
-
withNull
Description copied from class:KeyCollectionImpl.BuilderImplSpecifies whether null elements are allowed or not. A null element will have null keys. This method does not implicitly create an element set, where asKeyCollectionImpl.BuilderImpl.withElemNull(boolean)does.- Overrides:
withNullin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowNull- true to allow null elements (default), false to disallow- Returns:
- this (fluent interfaces)
-
withConstraint
Description copied from class:KeyCollectionImpl.BuilderImplSpecify element constraint.- Overrides:
withConstraintin classKey2Collection.Builder<E,K1, K2> - Parameters:
constraint- constraint element must satisfy, null for none (default)- Returns:
- this (fluent interface)
-
withBeforeInsertTrigger
Description copied from class:KeyCollectionImpl.BuilderImplSpecify insert trigger.- Overrides:
withBeforeInsertTriggerin classKey2Collection.Builder<E,K1, K2> - Parameters:
trigger- insert trigger method, null for none (default)- Returns:
- this (fluent interface)
-
withAfterInsertTrigger
Description copied from class:KeyCollectionImpl.BuilderImplSpecify insert trigger.- Overrides:
withAfterInsertTriggerin classKey2Collection.Builder<E,K1, K2> - Parameters:
trigger- insert trigger method, null for none (default)- Returns:
- this (fluent interface)
-
withBeforeDeleteTrigger
Description copied from class:KeyCollectionImpl.BuilderImplSpecify delete trigger.- Overrides:
withBeforeDeleteTriggerin classKey2Collection.Builder<E,K1, K2> - Parameters:
trigger- delete trigger method, null for none (default)- Returns:
- this (fluent interface)
-
withAfterDeleteTrigger
Description copied from class:KeyCollectionImpl.BuilderImplSpecify delete trigger.- Overrides:
withAfterDeleteTriggerin classKey2Collection.Builder<E,K1, K2> - Parameters:
trigger- delete trigger method, null for none (default)- Returns:
- this (fluent interface)
-
withCapacity
Description copied from class:KeyCollectionImpl.BuilderImplSpecify initial capacity.- Overrides:
withCapacityin classKey2Collection.Builder<E,K1, K2> - Parameters:
capacity- initial capacity- Returns:
- this (fluent interface)
-
withContent
Description copied from class:KeyCollectionImpl.BuilderImplSpecify elements added to the collection upon creation.- Overrides:
withContentin classKey2Collection.Builder<E,K1, K2> - Parameters:
elements- initial elements- Returns:
- this (fluent interface)
-
withContent
Description copied from class:KeyCollectionImpl.BuilderImplSpecify elements added to the collection upon creation.- Overrides:
withContentin classKey2Collection.Builder<E,K1, K2> - Parameters:
elements- initial elements- Returns:
- this (fluent interface)
-
withMaxSize
Description copied from class:KeyCollectionImpl.BuilderImplSpecify maximum size of collection. If an attempt is made to add more elements, an exception is thrown.- Overrides:
withMaxSizein classKey2Collection.Builder<E,K1, K2> - Parameters:
maxSize- maximum size- Returns:
- this (fluent interface)
-
withElemCount
Description copied from class:KeyCollectionImpl.BuilderImplSpecifies that the collection only counts the number of occurrences of equal elements, but does not store the elements themselves.- Overrides:
withElemCountin classKeyCollectionImpl.BuilderImpl<E>- Parameters:
count- true to count only number of occurrences (default is false)- Returns:
- this (fluent interface)
-
withElemSet
Add element map (with ident mapper).Note that a
Key2Setalways has an element set, so this call is not necessary.- Overrides:
withElemSetin classKey2Collection.Builder<E,K1, K2> - Returns:
- this (fluent interface)
-
withOrderByElem
Description copied from class:KeyCollectionImpl.BuilderImplSpecifies 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:
withOrderByElemin classKey2Collection.Builder<E,K1, K2> - 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
Description copied from class:KeyCollectionImpl.BuilderImplSpecifies whether null elements are allowed or not. A null element will have null keys. This method does implicitly create an element set, where asKeyCollectionImpl.BuilderImpl.withNull(boolean)does not.- Overrides:
withElemNullin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowNull- true to allow null elements, false to disallow (default is true)- Returns:
- this (fluent interfaces)
-
withElemSort
Description copied from class:KeyCollectionImpl.BuilderImplSpecify 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:
withElemSortin classKey2Collection.Builder<E,K1, K2> - Parameters:
sort- true to sorted, false for unsorted (default is false)- Returns:
- this (fluent interface)
-
withElemSort
Description copied from class:KeyCollectionImpl.BuilderImplSet 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:
withElemSortin classKey2Collection.Builder<E,K1, K2> - Parameters:
comparator- comparator to use for sorting (null for natural comparator)- Returns:
- this (fluent interface)
-
withElemSort
public Key2Set.Builder<E,K1, withElemSortK2> (Comparator<? super E> comparator, boolean sortNullsFirst) Description copied from class:KeyCollectionImpl.BuilderImplSet 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:
withElemSortin classKey2Collection.Builder<E,K1, K2> - Parameters:
comparator- comparator to use for sortingsortNullsFirst- true to sort null values first, false for last- Returns:
- this (fluent interface)
-
withPrimaryElem
Specify the element to be a primary key. This is identical to callingwithElemNull(false) and withElemDuplicates(false).Note that a
Key2Setalways has an element set, so this call is not necessary.- Overrides:
withPrimaryElemin classKey2Collection.Builder<E,K1, K2> - Returns:
- this (fluent interface)
-
withUniqueElem
Specify the element to be a unique key. This is identical to callingwithElemNull(true) and withElemDuplicates(false, true).Note that a
Key2Setalways has an element set, so an exception is thrown.- Overrides:
withUniqueElemin classKey2Collection.Builder<E,K1, K2> - Returns:
- this (fluent interface)
-
withKey1Map
Add key map.- Overrides:
withKey1Mapin classKey2Collection.Builder<E,K1, K2> - Parameters:
mapper- mapper to use- Returns:
- this (fluent interface)
-
withPrimaryKey1Map
Specify this key to be a primary key. This is identical to callingwithKey1Map(mapper), withKey1Null(false), and withKey1Duplicates(false).- Overrides:
withPrimaryKey1Mapin classKey2Collection.Builder<E,K1, K2> - Parameters:
mapper- mapper to use- Returns:
- this (fluent interface)
-
withUniqueKey1Map
Specify this key to be a unique key. This is identical to callingwithKey1Map(mapper), withKey1Null(true), and withKey1Duplicates(false, true).- Overrides:
withUniqueKey1Mapin classKey2Collection.Builder<E,K1, K2> - Parameters:
mapper- mapper to use- Returns:
- this (fluent interface)
-
withOrderByKey1
Description copied from class:KeyCollectionImpl.BuilderImplSpecifies 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:
withOrderByKey1in classKey2Collection.Builder<E,K1, K2> - 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
Description copied from class:KeyCollectionImpl.BuilderImplSpecify whether null elements are allowed or not. A null element will have a null key.- Overrides:
withKey1Nullin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowNull- true to allow null elements, false to disallow- Returns:
- this (fluent interfaces)
-
withKey1Duplicates
Description copied from class:KeyCollectionImpl.BuilderImplSpecify whether duplicates are allowed or not.- Overrides:
withKey1Duplicatesin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowDuplicates- true to allow duplicates- Returns:
- this (fluent interfaces)
-
withKey1Duplicates
public Key2Set.Builder<E,K1, withKey1DuplicatesK2> (boolean allowDuplicates, boolean allowDuplicatesNull) Description copied from class:KeyCollectionImpl.BuilderImplSpecify whether duplicates are allowed or not.- Overrides:
withKey1Duplicatesin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowDuplicates- true to allow duplicatesallowDuplicatesNull- true to allow duplicate null values- Returns:
- this (fluent interfaces)
-
withKey1Sort
Description copied from class:KeyCollectionImpl.BuilderImplSet 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:
withKey1Sortin classKey2Collection.Builder<E,K1, K2> - Parameters:
sort- true to sort key map- Returns:
- this (fluent interface)
-
withKey1Sort
Set comparator to use for sorting the key map. Note that this does not automatically sort the list collection, call a withOrderBy method for this.- Overrides:
withKey1Sortin classKey2Collection.Builder<E,K1, K2> - Parameters:
comparator- comparator to use for sorting- Returns:
- this (fluent interface)
-
withKey1Sort
public Key2Set.Builder<E,K1, withKey1SortK2> (Comparator<? super K1> comparator, boolean sortNullsFirst) Set comparator to use for sorting the key map. Note that this does not automatically sort the list collection, call a withOrderBy method for this.- Overrides:
withKey1Sortin classKey2Collection.Builder<E,K1, K2> - Parameters:
comparator- comparator to use for sortingsortNullsFirst- true if null will be sorted first, false for last- Returns:
- this (fluent interface)
-
withKey2Map
Add key map.- Overrides:
withKey2Mapin classKey2Collection.Builder<E,K1, K2> - Parameters:
mapper- mapper to use- Returns:
- this (fluent interface)
-
withPrimaryKey2Map
Specify this key to be a primary key. This is identical to callingwithKey2Map(mapper), withKey2Null(false), and withKey2Duplicates(false).- Overrides:
withPrimaryKey2Mapin classKey2Collection.Builder<E,K1, K2> - Parameters:
mapper- mapper to use- Returns:
- this (fluent interface)
-
withUniqueKey2Map
Specify this key to be a unique key. This is identical to callingwithKey2Map(mapper), withKey2Null(true), and withKey2Duplicates(false, true).- Overrides:
withUniqueKey2Mapin classKey2Collection.Builder<E,K1, K2> - Parameters:
mapper- mapper to use- Returns:
- this (fluent interface)
-
withOrderByKey2
Description copied from class:KeyCollectionImpl.BuilderImplSpecifies 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:
withOrderByKey2in classKey2Collection.Builder<E,K1, K2> - 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)
-
withKey2Null
Description copied from class:KeyCollectionImpl.BuilderImplSpecify whether null elements are allowed or not. A null element will have a null key.- Overrides:
withKey2Nullin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowNull- true to allow null elements, false to disallow- Returns:
- this (fluent interfaces)
-
withKey2Duplicates
Description copied from class:KeyCollectionImpl.BuilderImplSpecify whether duplicates are allowed or not.- Overrides:
withKey2Duplicatesin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowDuplicates- true to allow duplicates- Returns:
- this (fluent interfaces)
-
withKey2Duplicates
public Key2Set.Builder<E,K1, withKey2DuplicatesK2> (boolean allowDuplicates, boolean allowDuplicatesNull) Description copied from class:KeyCollectionImpl.BuilderImplSpecify whether duplicates are allowed or not.- Overrides:
withKey2Duplicatesin classKey2Collection.Builder<E,K1, K2> - Parameters:
allowDuplicates- true to allow duplicatesallowDuplicatesNull- true to allow duplicate null values- Returns:
- this (fluent interfaces)
-
withKey2Sort
Description copied from class:KeyCollectionImpl.BuilderImplSet 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:
withKey2Sortin classKey2Collection.Builder<E,K1, K2> - Parameters:
sort- true to sort key map- Returns:
- this (fluent interface)
-
withKey2Sort
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:
withKey2Sortin classKey2Collection.Builder<E,K1, K2> - Parameters:
comparator- comparator to use for sorting- Returns:
- this (fluent interface)
-
withKey2Sort
public Key2Set.Builder<E,K1, withKey2SortK2> (Comparator<? super K2> 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:
withKey2Sortin classKey2Collection.Builder<E,K1, K2> - Parameters:
comparator- comparator to use for sortingsortNullsFirst- true if null will be sorted first, false for last- Returns:
- this (fluent interface)
-