T
- the type to instantiatepublic class Instantiator<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Instantiator.AvailableParameters
Callback used to register available parameters.
|
static interface |
Instantiator.FailureHandler
Strategy for handling a failure that occurs when instantiating a type.
|
Constructor and Description |
---|
Instantiator(java.lang.Class<?> type,
java.util.function.Consumer<Instantiator.AvailableParameters> availableParameters)
Create a new
Instantiator instance for the given type. |
Instantiator(java.lang.Class<?> type,
java.util.function.Consumer<Instantiator.AvailableParameters> availableParameters,
Instantiator.FailureHandler failureHandler)
Create a new
Instantiator instance for the given type. |
Modifier and Type | Method and Description |
---|---|
java.util.List<T> |
instantiate(java.lang.ClassLoader classLoader,
java.util.Collection<java.lang.String> names)
Instantiate the given set of class name, injecting constructor arguments as
necessary.
|
java.util.List<T> |
instantiate(java.util.Collection<java.lang.String> names)
Instantiate the given set of class name, injecting constructor arguments as
necessary.
|
java.util.List<T> |
instantiateTypes(java.util.Collection<java.lang.Class<?>> types)
Instantiate the given set of classes, injecting constructor arguments as necessary.
|
public Instantiator(java.lang.Class<?> type, java.util.function.Consumer<Instantiator.AvailableParameters> availableParameters)
Instantiator
instance for the given type.type
- the type to instantiateavailableParameters
- consumer used to register available parameterspublic Instantiator(java.lang.Class<?> type, java.util.function.Consumer<Instantiator.AvailableParameters> availableParameters, Instantiator.FailureHandler failureHandler)
Instantiator
instance for the given type.type
- the type to instantiateavailableParameters
- consumer used to register available parametersfailureHandler
- a Instantiator.FailureHandler
that will be called in case of
failure when instantiating objectspublic java.util.List<T> instantiate(java.util.Collection<java.lang.String> names)
names
- the class names to instantiatepublic java.util.List<T> instantiate(java.lang.ClassLoader classLoader, java.util.Collection<java.lang.String> names)
classLoader
- the source classloadernames
- the class names to instantiatepublic java.util.List<T> instantiateTypes(java.util.Collection<java.lang.Class<?>> types)
types
- the types to instantiate