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 |
---|---|
<O> RegistryBuilder |
add(Class<? super O> type,
O object)
Adds a registry entry that is available by the given type.
|
<O> RegistryBuilder |
add(Class<O> type,
Factory<? extends O> factory)
Adds a lazily created entry to the registry.
|
RegistryBuilder |
add(Object object)
Adds a registry entry.
|
<O> RegistryBuilder |
add(TypeToken<? super O> type,
O object)
Adds a registry entry that is available by the given type.
|
<O> RegistryBuilder |
add(TypeToken<O> type,
Factory<? extends O> factory)
Adds a lazily created entry to the registry.
|
Registry |
build()
Builds the registry.
|
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()
<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 entryRegistryBuilder add(Object object)
add
in interface RegistrySpec
object
- the object to add to the registry<O> RegistryBuilder add(Class<O> type, Factory<? extends O> factory)
The factory will be invoked exactly once, when a query is made to the registry of a compatible type of the given type.
add
in interface RegistrySpec
O
- the public type of the registry entrytype
- the public type of the registry entryfactory
- the factory for creating the object when needed<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 entry<O> RegistryBuilder add(TypeToken<O> type, Factory<? extends O> factory)
The factory will be invoked exactly once, when a query is made to the registry of a compatible type of the given type.
add
in interface RegistrySpec
O
- the public type of the registry entrytype
- the public type of the registry entryfactory
- the factory for creating the object when neededRegistry build()
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)