public interface RegistryBuilder extends RegistrySpec
registries
.
For create single entry registries, see the factory methods on Registries
.
A builder can be used for creating an registry with multiple entries.
Registries.registry()
Modifier and Type | Method and Description |
---|---|
default <O> RegistryBuilder |
add(Class<? super O> type,
O object)
Adds a registry entry that is available by the given type.
|
default RegistryBuilder |
add(Object object)
Adds a registry entry.
|
default <O> RegistryBuilder |
add(TypeToken<? super O> type,
O object)
Adds a registry entry that is available by the given type.
|
default <O> RegistryBuilder |
addLazy(Class<O> type,
Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.
|
<O> RegistryBuilder |
addLazy(TypeToken<O> type,
Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.
|
Registry |
build()
Builds the registry.
|
default Registry |
build(Registry parent)
Builds a registry containing the entries specified by this builder and the given “parent” registry.
|
int |
size()
How many entries have been added so far.
|
int size()
default RegistryBuilder add(Object object)
add
in interface RegistrySpec
object
- the object to add to the registrydefault <O> RegistryBuilder add(Class<? super 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<? super 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(Class<O> type, 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, 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 neededRegistry build()
default Registry build(Registry parent)
This method uses Registries.join(Registry, Registry)
, with this registry as the child argument.
parent
- the parent of the registry to createRegistries.join(Registry, Registry)