Class KeyCollectionImpl.BuilderImpl<E>
java.lang.Object
org.magicwerk.brownies.collections.KeyCollectionImpl.BuilderImpl<E>
- Direct Known Subclasses:
Key1Collection.Builder
,Key1List.Builder
,Key2Collection.Builder
,Key2List.Builder
,KeyCollection.Builder
,KeyList.Builder
- Enclosing class:
KeyCollectionImpl<E>
Implementation of builder.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
(package private) E[]
(package private) int
(package private) Collection
<? extends E> (package private) boolean
True to count only number of occurrences of equal elements(package private) KeyCollectionImpl
<E> (package private) KeyListImpl
<E> (package private) GapList
<KeyCollectionImpl.BuilderImpl.KeyMapBuilder<E, Object>> (package private) int
(package private) Boolean
(package private) boolean
True to specify that the collection behaves like aSet
on adding elements, i.e.(package private) boolean
True to store list data in a BigList instance, false for a GapList instance (only used for KeyList, Key1List, Key2List) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
build
(KeyCollectionImpl keyColl, boolean list) Initialize KeyCollectionImpl.(package private) KeyCollectionImpl.KeyMap
buildKeyMap
(KeyCollectionImpl.BuilderImpl.KeyMapBuilder keyMapBuilder, boolean list) Initialize KeyMap.(package private) KeyCollectionImpl.BuilderImpl.KeyMapBuilder
<E, Object> getKeyMapBuilder
(int index) (package private) boolean
(package private) void
init
(KeyCollectionImpl keyColl) This method is called if a KeyCollection, Key1Collection, Key2Collection is initialized.(package private) void
init
(KeyCollectionImpl keyColl, KeyListImpl keyList) This method is called if a KeyList, Key1List, Key2List is initialized.(package private) void
initKeyMapBuilder
(int numKeys) (package private) IList
<?> initList()
(package private) boolean
(package private) boolean
protected KeyCollectionImpl.BuilderImpl
<E> withAfterDeleteTrigger
(Consumer<E> trigger) Specify delete trigger.protected KeyCollectionImpl.BuilderImpl
<E> withAfterInsertTrigger
(Consumer<E> trigger) Specify insert trigger.protected KeyCollectionImpl.BuilderImpl
<E> withBeforeDeleteTrigger
(Consumer<E> trigger) Specify delete trigger.protected KeyCollectionImpl.BuilderImpl
<E> withBeforeInsertTrigger
(Consumer<E> trigger) Specify insert trigger.protected KeyCollectionImpl.BuilderImpl
<E> withCapacity
(int capacity) Specify initial capacity.protected KeyCollectionImpl.BuilderImpl
<E> withConstraint
(Predicate<E> constraint) Specify element constraint.protected KeyCollectionImpl.BuilderImpl
<E> withContent
(E... elements) Specify elements added to the collection upon creation.protected KeyCollectionImpl.BuilderImpl
<E> withContent
(Collection<? extends E> elements) Specify elements added to the collection upon creation.protected KeyCollectionImpl.BuilderImpl
<E> withElemCount
(boolean count) Specifies that the collection only counts the number of occurrences of equal elements, but does not store the elements themselves.protected KeyCollectionImpl.BuilderImpl
<E> withElemDuplicates
(boolean allowDuplicates) Specify whether duplicates are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withElemDuplicates
(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withElemNull
(boolean allowNull) Specifies whether null elements are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> Add element map (with ident mapper).protected KeyCollectionImpl.BuilderImpl
<E> withElemSort
(boolean sort) Specify that the element set should be sorted using the natural comparator.protected KeyCollectionImpl.BuilderImpl
<E> withElemSort
(Comparator<? super E> comparator) Set comparator to use for sorting the element set.protected KeyCollectionImpl.BuilderImpl
<E> withElemSort
(Comparator<? super E> comparator, boolean sortNullsFirst) Set comparator to use for sorting the element set.protected KeyCollectionImpl.BuilderImpl
<E> withKey1Duplicates
(boolean allowDuplicates) Specify whether duplicates are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withKey1Duplicates
(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withKey1Null
(boolean allowNull) Specify whether null elements are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withKey1Sort
(boolean sort) Set comparator to use for sorting the key map.protected KeyCollectionImpl.BuilderImpl
<E> withKey2Duplicates
(boolean allowDuplicates) Specify whether duplicates are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withKey2Duplicates
(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withKey2Null
(boolean allowNull) Specify whether null elements are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withKey2Sort
(boolean sort) Set comparator to use for sorting the key map.protected KeyCollectionImpl.BuilderImpl
<E> withKeyDuplicates
(int keyIndex, boolean allowDuplicates, boolean allowDuplicatesNull) protected KeyCollectionImpl.BuilderImpl
<E> withKeyMap
(int keyIndex, Function mapper) protected KeyCollectionImpl.BuilderImpl
<E> withKeyNull
(int keyIndex, boolean allowNull) protected KeyCollectionImpl.BuilderImpl
<E> withKeySort
(int keyIndex, boolean sort) protected KeyCollectionImpl.BuilderImpl
<E> withKeySort
(int keyIndex, Comparator<?> comparator) protected KeyCollectionImpl.BuilderImpl
<E> withKeySort
(int keyIndex, Comparator<?> comparator, boolean sortNullsFirst) protected KeyCollectionImpl.BuilderImpl
<E> withListBig
(boolean big) Specify whether list should be stored in an instance of BigList or GapList.protected KeyCollectionImpl.BuilderImpl
<E> withListType
(Class<?> type) Specifies that the list will store its elements as primitive type.protected KeyCollectionImpl.BuilderImpl
<E> withMaxSize
(int maxSize) Specify maximum size of collection.protected KeyCollectionImpl.BuilderImpl
<E> withNull
(boolean allowNull) Specifies whether null elements are allowed or not.protected KeyCollectionImpl.BuilderImpl
<E> withOrderByElem
(boolean orderBy) Specifies that the collection will have the order of the element set.protected KeyCollectionImpl.BuilderImpl
<E> withOrderByElem
(Class<?> type) Specifies that the list will have the order of the element set.protected KeyCollectionImpl.BuilderImpl
<E> withOrderByKey
(int keyIndex, boolean orderBy) protected KeyCollectionImpl.BuilderImpl
<E> withOrderByKey
(int keyIndex, Class<?> type) protected KeyCollectionImpl.BuilderImpl
<E> withOrderByKey1
(boolean orderBy) Specifies that the collection will have the order of the key map.protected KeyCollectionImpl.BuilderImpl
<E> withOrderByKey1
(Class<?> type) Specifies that the list will have the order of the key map.protected KeyCollectionImpl.BuilderImpl
<E> withOrderByKey2
(boolean orderBy) Specifies that the collection will have the order of the key map.protected KeyCollectionImpl.BuilderImpl
<E> withOrderByKey2
(Class<?> type) Specifies that the list will have the order of the key map.protected KeyCollectionImpl.BuilderImpl
<E> Specify the element to be a primary key.protected KeyCollectionImpl.BuilderImpl
<E> withPrimaryKeyMap
(int keyIndex, Function mapper) protected KeyCollectionImpl.BuilderImpl
<E> withSetBehavior
(boolean setBehavior) Specifies that the collection behaves like aSet
on adding elements, i.e.protected KeyCollectionImpl.BuilderImpl
<E> Specify the element to be a unique key.protected KeyCollectionImpl.BuilderImpl
<E> withUniqueKeyMap
(int keyIndex, Function mapper) protected KeyCollectionImpl.BuilderImpl
<E> withWindowSize
(int maxSize) Specify maximum window size of collection.
-
Field Details
-
keyColl
KeyCollectionImpl<E> keyColl -
keyList
KeyListImpl<E> keyList -
allowNullElem
boolean allowNullElem -
constraint
-
beforeInsertTrigger
-
afterInsertTrigger
-
beforeDeleteTrigger
-
afterDeleteTrigger
-
keyMapBuilders
GapList<KeyCollectionImpl.BuilderImpl.KeyMapBuilder<E,Object>> keyMapBuilders -
collection
Collection<? extends E> collection -
array
E[] array -
capacity
int capacity -
maxSize
int maxSize -
movingWindow
Boolean movingWindow -
setBehavior
boolean setBehaviorTrue to specify that the collection behaves like aSet
on adding elements, i.e. if an element cannot be added due to duplicate or other constraints, no exception is thrown. -
count
boolean countTrue to count only number of occurrences of equal elements -
useBigList
boolean useBigListTrue to store list data in a BigList instance, false for a GapList instance (only used for KeyList, Key1List, Key2List)
-
-
Constructor Details
-
BuilderImpl
public BuilderImpl()
-
-
Method Details
-
withNull
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 aswithElemNull(boolean)
does.- Parameters:
allowNull
- true to allow null elements (default), false to disallow- Returns:
- this (fluent interfaces)
-
withConstraint
Specify element constraint.- Parameters:
constraint
- constraint element must satisfy, null for none (default)- Returns:
- this (fluent interface)
-
withBeforeInsertTrigger
Specify insert trigger.- Parameters:
trigger
- insert trigger method, null for none (default)- Returns:
- this (fluent interface)
-
withAfterInsertTrigger
Specify insert trigger.- Parameters:
trigger
- insert trigger method, null for none (default)- Returns:
- this (fluent interface)
-
withBeforeDeleteTrigger
Specify delete trigger.- Parameters:
trigger
- delete trigger method, null for none (default)- Returns:
- this (fluent interface)
-
withAfterDeleteTrigger
Specify delete trigger.- Parameters:
trigger
- delete trigger method, null for none (default)- Returns:
- this (fluent interface)
-
withCapacity
Specify initial capacity.- Parameters:
capacity
- initial capacity- Returns:
- this (fluent interface)
-
withContent
Specify elements added to the collection upon creation.- Parameters:
elements
- initial elements- Returns:
- this (fluent interface)
-
withContent
Specify elements added to the collection upon creation.- Parameters:
elements
- initial elements- Returns:
- this (fluent interface)
-
withMaxSize
Specify maximum size of collection. If an attempt is made to add more elements, an exception is thrown.- Parameters:
maxSize
- maximum size- Returns:
- this (fluent interface)
-
withWindowSize
Specify maximum window size of collection. If an attempt is made to add and additional element, the first element is removed.- Parameters:
maxSize
- maximum window size- Returns:
- this (fluent interface)
-
withSetBehavior
Specifies that the collection behaves like aSet
on adding elements, i.e. if an element cannot be added due to duplicate or other constraints, no exception is thrown.- Parameters:
setBehavior
- true to define set behavior (default is false)- Returns:
- this (fluent interface)
-
withElemCount
Specifies that the collection only counts the number of occurrences of equal elements, but does not store the elements themselves.- Parameters:
count
- true to count only number of occurrences (default is false)- Returns:
- this (fluent interface)
-
withElemSet
Add element map (with ident mapper).- Returns:
- this (fluent interface)
-
withOrderByElem
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.- 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)
-
withOrderByElem
Specifies that the list will have the order of the element set. The set will store values of the primitive type specified likeint
. The set will be sorted using the natural comparator and no null values are allowed.- 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)
-
withElemNull
Specifies whether null elements are allowed or not. A null element will have null keys. This method does implicitly create an element set, where aswithNull(boolean)
does not.- Parameters:
allowNull
- true to allow null elements, false to disallow (default is true)- Returns:
- this (fluent interfaces)
-
withElemDuplicates
Specify whether duplicates are allowed or not. This method does implicitly create an element set.- Parameters:
allowDuplicates
- true to allow duplicates (default is true)- Returns:
- this (fluent interfaces)
-
withElemDuplicates
protected KeyCollectionImpl.BuilderImpl<E> withElemDuplicates(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not. This method does implicitly create an element set.- Parameters:
allowDuplicates
- true to allow duplicates (default is true)allowDuplicatesNull
- true to allow duplicate null values (default is true)- Returns:
- this (fluent interfaces)
-
withElemSort
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.- Parameters:
sort
- true to sorted, false for unsorted (default is false)- Returns:
- this (fluent interface)
-
withElemSort
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.- Parameters:
comparator
- comparator to use for sorting (null for natural comparator)- Returns:
- this (fluent interface)
-
withElemSort
protected KeyCollectionImpl.BuilderImpl<E> withElemSort(Comparator<? super E> comparator, boolean sortNullsFirst) 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.- 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)
.- Returns:
- this (fluent interface)
-
withUniqueElem
Specify the element to be a unique key. This is identical to callingwithElemNull(true) and withElemDuplicates(false, true)
.- Returns:
- this (fluent interface)
-
withKeyMap
-
withOrderByKey
-
withOrderByKey
-
withListType
Specifies that the list will store its elements as primitive type.- Parameters:
type
- primitive type to use for list- Returns:
- this (fluent interface)
-
withListBig
Specify whether list should be stored in an instance of BigList or GapList.- Parameters:
big
- true to store list content in an instance of BigList, false for GapList- Returns:
- this (fluent interface)
-
withKeyNull
-
withKeyDuplicates
protected KeyCollectionImpl.BuilderImpl<E> withKeyDuplicates(int keyIndex, boolean allowDuplicates, boolean allowDuplicatesNull) -
withKeySort
-
withKeySort
-
withKeySort
protected KeyCollectionImpl.BuilderImpl<E> withKeySort(int keyIndex, Comparator<?> comparator, boolean sortNullsFirst) -
withPrimaryKeyMap
-
withUniqueKeyMap
-
withOrderByKey1
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.- 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
Specifies that the list will have the order of the key map. The key map will store values of the primitive type specified likeint
. The key map will be sorted using the natural comparator and no null values are allowed.- 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
Specify whether null elements are allowed or not. A null element will have a null key.- Parameters:
allowNull
- true to allow null elements, false to disallow- Returns:
- this (fluent interfaces)
-
withKey1Duplicates
Specify whether duplicates are allowed or not.- Parameters:
allowDuplicates
- true to allow duplicates- Returns:
- this (fluent interfaces)
-
withKey1Duplicates
protected KeyCollectionImpl.BuilderImpl<E> withKey1Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not.- Parameters:
allowDuplicates
- true to allow duplicatesallowDuplicatesNull
- true to allow duplicate null values- Returns:
- this (fluent interfaces)
-
withKey1Sort
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:
sort
- true to sort key map- Returns:
- this (fluent interface)
-
withOrderByKey2
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.- 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
Specifies that the list will have the order of the key map. The key map will store values of the primitive type specified likeint
. The key map will be sorted using the natural comparator and no null values are allowed.- 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
Specify whether null elements are allowed or not. A null element will have a null key.- Parameters:
allowNull
- true to allow null elements, false to disallow- Returns:
- this (fluent interfaces)
-
withKey2Duplicates
Specify whether duplicates are allowed or not.- Parameters:
allowDuplicates
- true to allow duplicates- Returns:
- this (fluent interfaces)
-
withKey2Duplicates
protected KeyCollectionImpl.BuilderImpl<E> withKey2Duplicates(boolean allowDuplicates, boolean allowDuplicatesNull) Specify whether duplicates are allowed or not.- Parameters:
allowDuplicates
- true to allow duplicatesallowDuplicatesNull
- true to allow duplicate null values- Returns:
- this (fluent interfaces)
-
withKey2Sort
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:
sort
- true to sort key map- Returns:
- this (fluent interface)
-
initKeyMapBuilder
void initKeyMapBuilder(int numKeys) - Parameters:
numKeys
- number of keys
-
hasElemMapBuilder
boolean hasElemMapBuilder() -
getKeyMapBuilder
-
isTrue
-
isFalse
-
buildKeyMap
KeyCollectionImpl.KeyMap buildKeyMap(KeyCollectionImpl.BuilderImpl.KeyMapBuilder keyMapBuilder, boolean list) Initialize KeyMap.- Parameters:
list
- true if a KeyListImpl is built up, false for KeyCollectionImplkeyMapBuild
- key map builder to use for initialization
-
build
Initialize KeyCollectionImpl.- Parameters:
keyColl
- collection to initializelist
- true if a KeyListImpl is built up, false for KeyCollectionImpl
-
init
This method is called if a KeyCollection, Key1Collection, Key2Collection is initialized.- Parameters:
keyColl
- KeyCollectionImpl which has already been initialized
-
init
This method is called if a KeyList, Key1List, Key2List is initialized.- Parameters:
keyColl
- KeyCollectionImpl which has already been initializedkeyList
- KeyListImpl to initialize
-
initList
IList<?> initList()
-