Package ratpack.exec.registry
Interface RegistryBuilder
-
- All Superinterfaces:
RegistrySpec
public interface RegistryBuilder extends RegistrySpec
A builder ofregistries
.For create single entry registries, see the factory methods on
Registry
. A builder can be used for creating an registry with multiple entries.- See Also:
Registry.builder()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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
add(Class<O> type, O object)
Adds a registry entry that is available by the given type.default RegistryBuilder
add(Object object)
Adds a registry entry.<O> RegistryBuilder
addLazy(com.google.common.reflect.TypeToken<O> type, Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.default <O> RegistryBuilder
addLazy(Class<O> type, 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 withthis
.
-
-
-
Method Detail
-
size
int size()
How many entries have been added so far.- Returns:
- how many entries have been added so far.
-
add
default RegistryBuilder add(Object object)
Adds a registry entry.- Specified by:
add
in interfaceRegistrySpec
- Parameters:
object
- the object to add to the registry- Returns:
- this
-
add
default <O> RegistryBuilder add(Class<O> type, O object)
Adds a registry entry that is available by the given type.- Specified by:
add
in interfaceRegistrySpec
- Type Parameters:
O
- the public type of the registry entry- Parameters:
type
- the public type of the registry entryobject
- the actual registry entry- Returns:
- this
-
add
default <O> RegistryBuilder add(com.google.common.reflect.TypeToken<O> type, O object)
Adds a registry entry that is available by the given type.- Specified by:
add
in interfaceRegistrySpec
- Type Parameters:
O
- the public type of the registry entry- Parameters:
type
- the public type of the registry entryobject
- the actual registry entry- Returns:
- this
-
addLazy
default <O> RegistryBuilder addLazy(Class<O> type, Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.The supplier will be invoked exactly once, when a query is made to the registry of a compatible type of the given type.
- Specified by:
addLazy
in interfaceRegistrySpec
- Type Parameters:
O
- the public type of the registry entry- Parameters:
type
- the public type of the registry entrysupplier
- the supplier for creating the object when needed- Returns:
- this
-
addLazy
<O> RegistryBuilder addLazy(com.google.common.reflect.TypeToken<O> type, Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.The supplier will be invoked exactly once, when a query is made to the registry of a compatible type of the given type.
- Specified by:
addLazy
in interfaceRegistrySpec
- Type Parameters:
O
- the public type of the registry entry- Parameters:
type
- the public type of the registry entrysupplier
- the supplier for creating the object when needed- Returns:
- this
-
with
default RegistryBuilder with(Action<? super RegistrySpec> action) throws Exception
Description copied from interface:RegistrySpec
Executes the given action withthis
.- Specified by:
with
in interfaceRegistrySpec
- Parameters:
action
- the action- Returns:
this
- Throws:
Exception
- any thrown byaction
-
build
Registry build()
Builds the registry.- Returns:
- a newly created registry
-
-