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(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(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 RegistrySpec
object
- the object to add to the registrydefault <O> RegistryBuilder add(java.lang.Class<O> type, O object)
add
in interface RegistrySpec
O
- the public type of the registry entrytype
- the public type of the registry entryobject
- the actual registry entrydefault <O> RegistryBuilder add(TypeToken<O> type, O object)
add
in interface RegistrySpec
O
- 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 RegistrySpec
O
- 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(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 RegistrySpec
O
- 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
RegistrySpec
this
.with
in interface RegistrySpec
action
- the actionthis
java.lang.Exception
- any thrown by action
Registry build()