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> RegistryBuilderadd(com.google.common.reflect.TypeToken<O> type, O object)Adds a registry entry that is available by the given type.default <O> RegistryBuilderadd(Class<O> type, O object)Adds a registry entry that is available by the given type.default RegistryBuilderadd(Object object)Adds a registry entry.<O> RegistryBuilderaddLazy(com.google.common.reflect.TypeToken<O> type, Supplier<? extends O> supplier)Adds a lazily created entry to the registry.default <O> RegistryBuilderaddLazy(Class<O> type, Supplier<? extends O> supplier)Adds a lazily created entry to the registry.Registrybuild()Builds the registry.intsize()How many entries have been added so far.default RegistryBuilderwith(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:
addin 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:
addin 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:
addin 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:
addLazyin 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:
addLazyin 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:RegistrySpecExecutes the given action withthis.- Specified by:
within interfaceRegistrySpec- Parameters:
action- the action- Returns:
this- Throws:
Exception- any thrown byaction
-
build
Registry build()
Builds the registry.- Returns:
- a newly created registry
-
-