Class SimpleParameterizedBuilderRegistry
- java.lang.Object
-
- com.tangosol.coherence.config.builder.SimpleParameterizedBuilderRegistry
-
- All Implemented Interfaces:
Disposable
,ParameterizedBuilderRegistry
,AutoCloseable
,Iterable<ParameterizedBuilderRegistry.Registration>
public class SimpleParameterizedBuilderRegistry extends Object implements ParameterizedBuilderRegistry
A basic implementation of aParameterizedBuilderRegistry
.- Since:
- Coherence 12.1.3
- Author:
- bo 2014.10.27
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
SimpleParameterizedBuilderRegistry.BuilderRegistration
An internalParameterizedBuilderRegistry.Registration
implementation.protected class
SimpleParameterizedBuilderRegistry.RegistryKey
Key class for a registered resource.protected class
SimpleParameterizedBuilderRegistry.RegistryValue
A holder for aParameterizedBuilder
.-
Nested classes/interfaces inherited from interface com.tangosol.coherence.config.builder.ParameterizedBuilderRegistry
ParameterizedBuilderRegistry.Registration<T>
-
-
Field Summary
-
Fields inherited from interface com.tangosol.coherence.config.builder.ParameterizedBuilderRegistry
DEFAULT_NAME
-
-
Constructor Summary
Constructors Constructor Description SimpleParameterizedBuilderRegistry()
Constructs aSimpleParameterizedBuilderRegistry
.SimpleParameterizedBuilderRegistry(ParameterizedBuilderRegistry registry)
Constructs aSimpleParameterizedBuilderRegistry
given another one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Invoked when all resources owned by the implementer can safely be released.<T> ParameterizedBuilder<T>
getBuilder(Class<T> clzInstance)
Attempts to retrieve the builder that was registered with the specified class.<T> ParameterizedBuilder<T>
getBuilder(Class<T> clzInstance, String sBuilderName)
Attempts to retrieve the builder that was registered with the specified class and name.boolean
isEmpty()
Determine if theParameterizedBuilderRegistry
is empty (contains no registrations).Iterator<ParameterizedBuilderRegistry.Registration>
iterator()
<T> String
registerBuilder(Class<T> clzInstance, ParameterizedBuilder<? extends T> builder)
Registers aParameterizedBuilder
for later retrieval withParameterizedBuilderRegistry.getBuilder(Class)
.<T> String
registerBuilder(Class<T> clzInstance, String sBuilderName, ParameterizedBuilder<? extends T> builder)
Registers aParameterizedBuilder
with the specified name for later retrieval withParameterizedBuilderRegistry.getBuilder(Class, String)
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.oracle.coherence.common.base.Disposable
close
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
SimpleParameterizedBuilderRegistry
public SimpleParameterizedBuilderRegistry()
Constructs aSimpleParameterizedBuilderRegistry
.
-
SimpleParameterizedBuilderRegistry
public SimpleParameterizedBuilderRegistry(ParameterizedBuilderRegistry registry)
Constructs aSimpleParameterizedBuilderRegistry
given another one.- Parameters:
registry
- the registry to copy
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Determine if theParameterizedBuilderRegistry
is empty (contains no registrations).- Returns:
- true if the registry contains no registrations
-
dispose
public void dispose()
Description copied from interface:Disposable
Invoked when all resources owned by the implementer can safely be released.Once disposed of the object should no longer be considered to be usable.
Note the Disposable interface is compatible with try-with-resources which will automatically invoke this method.
- Specified by:
dispose
in interfaceDisposable
-
getBuilder
public <T> ParameterizedBuilder<T> getBuilder(Class<T> clzInstance)
Description copied from interface:ParameterizedBuilderRegistry
Attempts to retrieve the builder that was registered with the specified class.- Specified by:
getBuilder
in interfaceParameterizedBuilderRegistry
- Type Parameters:
T
- the type of the instance that will be produced by the builder- Parameters:
clzInstance
- the class of the instance- Returns:
- the registered builder or
null
if the builder is unknown to theParameterizedBuilderRegistry
-
getBuilder
public <T> ParameterizedBuilder<T> getBuilder(Class<T> clzInstance, String sBuilderName)
Description copied from interface:ParameterizedBuilderRegistry
Attempts to retrieve the builder that was registered with the specified class and name.- Specified by:
getBuilder
in interfaceParameterizedBuilderRegistry
- Type Parameters:
T
- the type of the instance that will be produced by the builder- Parameters:
clzInstance
- the class of the instancesBuilderName
- the name of the builder- Returns:
- the registered builder or
null
if the builder is unknown to theParameterizedBuilderRegistry
-
registerBuilder
public <T> String registerBuilder(Class<T> clzInstance, ParameterizedBuilder<? extends T> builder) throws IllegalArgumentException
Description copied from interface:ParameterizedBuilderRegistry
Registers aParameterizedBuilder
for later retrieval withParameterizedBuilderRegistry.getBuilder(Class)
.Notes:
- Multiple builders for the same class can be registered if each
builder is registered with a unique name via
ParameterizedBuilderRegistry.registerBuilder(Class, String, ParameterizedBuilder)
- Registration of builders will occur in a thread-safe manner.
- Builders that are
Disposable
will be disposed when theParameterizedBuilderRegistry
is disposed.
- Specified by:
registerBuilder
in interfaceParameterizedBuilderRegistry
- Parameters:
clzInstance
- the class of instances produced by the builderbuilder
- the builder- Returns:
- the actual name used to register the builder
- Throws:
IllegalArgumentException
- if a builder of the same specified type is already registered
- Multiple builders for the same class can be registered if each
builder is registered with a unique name via
-
registerBuilder
public <T> String registerBuilder(Class<T> clzInstance, String sBuilderName, ParameterizedBuilder<? extends T> builder) throws IllegalArgumentException
Description copied from interface:ParameterizedBuilderRegistry
Registers aParameterizedBuilder
with the specified name for later retrieval withParameterizedBuilderRegistry.getBuilder(Class, String)
.Notes:
- Registration of builders will occur in a thread-safe manner.
- Builders that are
Disposable
will be disposed when theParameterizedBuilderRegistry
is disposed.
- Specified by:
registerBuilder
in interfaceParameterizedBuilderRegistry
- Parameters:
clzInstance
- the class of instances produced by the buildersBuilderName
- the proposed name of the builderbuilder
- the builder- Returns:
- the actual name used to register the builder
- Throws:
IllegalArgumentException
- if a builder of the same specified type and name is already registered
-
iterator
public Iterator<ParameterizedBuilderRegistry.Registration> iterator()
- Specified by:
iterator
in interfaceIterable<ParameterizedBuilderRegistry.Registration>
-
-