public interface RegistryBuilder extends RegistrySpec
registries.
For create single entry registries, see the factory methods on Registry.
A builder can be used for creating an registry with multiple entries.
Registry.builder()| Modifier and Type | Method and Description |
|---|---|
default <O> RegistryBuilder |
add(java.lang.Class<O> type,
O object)
Adds a registry entry that is available by the given type.
|
default RegistryBuilder |
add(java.lang.Object object)
Adds a registry entry.
|
default <O> RegistryBuilder |
add(com.google.common.reflect.TypeToken<O> type,
O object)
Adds a registry entry that is available by the given type.
|
default <O> RegistryBuilder |
addLazy(java.lang.Class<O> type,
java.util.function.Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.
|
<O> RegistryBuilder |
addLazy(com.google.common.reflect.TypeToken<O> type,
java.util.function.Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.
|
Registry |
build()
Builds the registry.
|
int |
size()
How many entries have been added so far.
|
default RegistryBuilder |
with(Action<? super RegistrySpec> action)
Executes the given action with
this. |
int size()
default RegistryBuilder add(java.lang.Object object)
add in interface RegistrySpecobject - the object to add to the registrydefault <O> RegistryBuilder add(java.lang.Class<O> type, O object)
add in interface RegistrySpecO - the public type of the registry entrytype - the public type of the registry entryobject - the actual registry entrydefault <O> RegistryBuilder add(com.google.common.reflect.TypeToken<O> type, O object)
add in interface RegistrySpecO - the public type of the registry entrytype - the public type of the registry entryobject - the actual registry entrydefault <O> RegistryBuilder addLazy(java.lang.Class<O> type, java.util.function.Supplier<? extends O> supplier)
The supplier will be invoked exactly once, when a query is made to the registry of a compatible type of the given type.
addLazy in interface RegistrySpecO - the public type of the registry entrytype - the public type of the registry entrysupplier - the supplier for creating the object when needed<O> RegistryBuilder addLazy(com.google.common.reflect.TypeToken<O> type, java.util.function.Supplier<? extends O> supplier)
The supplier will be invoked exactly once, when a query is made to the registry of a compatible type of the given type.
addLazy in interface RegistrySpecO - the public type of the registry entrytype - the public type of the registry entrysupplier - the supplier for creating the object when neededdefault RegistryBuilder with(Action<? super RegistrySpec> action) throws java.lang.Exception
RegistrySpecthis.with in interface RegistrySpecaction - the actionthisjava.lang.Exception - any thrown by actionRegistry build()