Interface Key.Builder<E,V extends Value<E>>
-
- All Superinterfaces:
Buildable.Builder<Key<V>>
,Builder<Key<V>,Key.Builder<E,V>>
,ResettableBuilder<Key<V>,Key.Builder<E,V>>
,ResourceKeyedBuilder<Key<V>,Key.Builder<E,V>>
public static interface Key.Builder<E,V extends Value<E>> extends ResourceKeyedBuilder<Key<V>,Key.Builder<E,V>>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Key<V>
build()
Builds theKey
.Key.Builder<E,V>
comparator(Comparator<? super E> comparator)
Sets theComparator
that can be used to compare the elements.<T> Key.Builder<T,Value<T>>
elementType(io.leangen.geantyref.TypeToken<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<T> Key.Builder<T,Value<T>>
elementType(Class<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called.Key.Builder<E,V>
includesTester(BiPredicate<? super E,? super E> predicate)
Sets the includes testerBiPredicate
.<T> Key.Builder<List<T>,ListValue<T>>
listElementType(io.leangen.geantyref.TypeToken<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<T> Key.Builder<List<T>,ListValue<T>>
listElementType(Class<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<K,V>
Key.Builder<Map<K,V>,MapValue<K,V>>mapElementType(io.leangen.geantyref.TypeToken<K> keyType, io.leangen.geantyref.TypeToken<V> valueType)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<K,V>
Key.Builder<Map<K,V>,MapValue<K,V>>mapElementType(Class<K> keyType, Class<V> valueType)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<T> Key.Builder<Set<T>,SetValue<T>>
setElementType(io.leangen.geantyref.TypeToken<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<T> Key.Builder<Set<T>,SetValue<T>>
setElementType(Class<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<T,B extends Value<T>>
Key.Builder<T,B>type(io.leangen.geantyref.TypeToken<B> token)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<T> Key.Builder<WeightedTable<T>,WeightedCollectionValue<T>>
weightedCollectionElementType(io.leangen.geantyref.TypeToken<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called.<T> Key.Builder<WeightedTable<T>,WeightedCollectionValue<T>>
weightedCollectionElementType(Class<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called.-
Methods inherited from interface org.spongepowered.api.util.ResourceKeyedBuilder
key
-
-
-
-
Method Detail
-
type
<T,B extends Value<T>> Key.Builder<T,B> type(io.leangen.geantyref.TypeToken<B> token)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.For common cases, element types can be specified using one of the
*elementType(Class)
methods. If a newTypeToken
is to be created, it is recommended to create an anonymous class instance of a token, as described in the GeAnTyRef documentation- Type Parameters:
T
- The element type of the KeyB
- The base value type of the key- Parameters:
token
- The type token- Returns:
- This builder, generified
-
elementType
<T> Key.Builder<T,Value<T>> elementType(Class<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
Value
is used.- Type Parameters:
T
- The element type of the Key- Parameters:
type
- The element type- Returns:
- This builder, generified
-
elementType
<T> Key.Builder<T,Value<T>> elementType(io.leangen.geantyref.TypeToken<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
Value
is used.- Type Parameters:
T
- The element type of the Key- Parameters:
type
- The element type- Returns:
- This builder, generified
-
listElementType
<T> Key.Builder<List<T>,ListValue<T>> listElementType(Class<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
ListValue
is used.- Type Parameters:
T
- The element type of the Key- Parameters:
type
- The element type- Returns:
- This builder, generified
-
listElementType
<T> Key.Builder<List<T>,ListValue<T>> listElementType(io.leangen.geantyref.TypeToken<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
ListValue
is used.- Type Parameters:
T
- The element type of the Key- Parameters:
type
- The element type- Returns:
- This builder, generified
-
setElementType
<T> Key.Builder<Set<T>,SetValue<T>> setElementType(Class<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
SetValue
is used.- Type Parameters:
T
- The element type of the Key- Parameters:
type
- The element type- Returns:
- This builder, generified
-
setElementType
<T> Key.Builder<Set<T>,SetValue<T>> setElementType(io.leangen.geantyref.TypeToken<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
SetValue
is used.- Type Parameters:
T
- The element type of the Key- Parameters:
type
- The element type- Returns:
- This builder, generified
-
mapElementType
<K,V> Key.Builder<Map<K,V>,MapValue<K,V>> mapElementType(Class<K> keyType, Class<V> valueType)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
MapValue
is used.- Type Parameters:
K
- The element type of the Key's key typeV
- The element type of the Key's value type- Parameters:
keyType
- the key typevalueType
- the value type- Returns:
- This builder, generified
-
mapElementType
<K,V> Key.Builder<Map<K,V>,MapValue<K,V>> mapElementType(io.leangen.geantyref.TypeToken<K> keyType, io.leangen.geantyref.TypeToken<V> valueType)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
MapValue
is used.- Type Parameters:
K
- The element type of the Key's key typeV
- The element type of the Key's value type- Parameters:
keyType
- the key typevalueType
- the value type- Returns:
- This builder, generified
-
weightedCollectionElementType
<T> Key.Builder<WeightedTable<T>,WeightedCollectionValue<T>> weightedCollectionElementType(Class<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
WeightedCollectionValue
is used.- Type Parameters:
T
- The element type of the Key- Parameters:
type
- The element type- Returns:
- This builder, generified
-
weightedCollectionElementType
<T> Key.Builder<WeightedTable<T>,WeightedCollectionValue<T>> weightedCollectionElementType(io.leangen.geantyref.TypeToken<T> type)
Starter method for the builder, to be used immediately afterKey.builder()
is called. This defines the generics for the builder itself to provide the properly generifiedKey
.This overload is provided for simple cases where a plain
WeightedCollectionValue
is used.- Type Parameters:
T
- The element type of the Key- Parameters:
type
- The element type- Returns:
- This builder, generified
-
comparator
Key.Builder<E,V> comparator(Comparator<? super E> comparator)
Sets theComparator
that can be used to compare the elements.Setting the comparator is a requirement if the element type isn't
Comparable
.- Parameters:
comparator
- The comparator- Returns:
- This builder, for chaining
-
includesTester
Key.Builder<E,V> includesTester(BiPredicate<? super E,? super E> predicate)
Sets the includes testerBiPredicate
. This predicate should returntrue
when the second parameter is included in the first one.The default tester will always return
false
.- Parameters:
predicate
- The tester bi predicate- Returns:
- This builder, for chaining
- See Also:
KeyValueMatcher.Operator.INCLUDES
,KeyValueMatcher.Operator.EXCLUDES
-
build
Key<V> build()
Builds theKey
.- Specified by:
build
in interfaceBuildable.Builder<E>
- Returns:
- The built key
- Throws:
IllegalStateException
- If not all required options were specified;type(TypeToken)
.
-
-