public class DefaultInstances extends Object implements InstanceProvider
| Modifier and Type | Field and Description |
|---|---|
static DefaultInstances |
DEFAULT
Standard default instance provider.
|
| Constructor and Description |
|---|
DefaultInstances(DefaultInstances other)
Copy a given instance provider.
|
DefaultInstances(com.google.common.collect.ImmutableList<InstanceProvider> registered)
Construct a default instance generator using the given instance providers.
|
DefaultInstances(InstanceProvider... instaceProviders)
Construct a default instance generator using the given instance providers.
|
| Modifier and Type | Method and Description |
|---|---|
protected <T> boolean |
contains(T[] elements,
T elementToFind) |
Object |
create(Class<?> type)
Create an instance given a type, if possible.
|
protected <T> T |
createInstance(Class<T> type,
Constructor<T> constructor,
Class<?>[] types,
Object[] params)
Used by the default instance provider to create a class from a given constructor.
|
DefaultInstances |
forEnhancer(net.sf.cglib.proxy.Enhancer enhancer)
Construct default instances using the CGLIB enhancer object instead.
|
static DefaultInstances |
fromArray(InstanceProvider... instanceProviders)
Construct a default instance generator using the given instance providers.
|
static DefaultInstances |
fromCollection(Collection<InstanceProvider> instanceProviders)
Construct a default instance generator using the given instance providers.
|
<T> T |
getDefault(Class<T> type)
Retrieves a default instance or value that is assignable to this type.
|
<T> T |
getDefault(Class<T> type,
List<InstanceProvider> providers)
Retrieves a default instance or value that is assignable to this type.
|
int |
getMaximumRecursion()
Retrieve the the maximum height of the hierachy of creates types.
|
<T> Constructor<T> |
getMinimumConstructor(Class<T> type)
Retrieve the constructor with the fewest number of parameters.
|
com.google.common.collect.ImmutableList<InstanceProvider> |
getRegistered()
Retrieves a immutable list of every default object providers that generates instances.
|
boolean |
isNonNull()
Retrieve whether or not the constructor's parameters must be non-null.
|
void |
setMaximumRecursion(int maximumRecursion)
Set the maximum height of the hierachy of creates types.
|
void |
setNonNull(boolean nonNull)
Set whether or not the constructor's parameters must be non-null.
|
public static final DefaultInstances DEFAULT
public DefaultInstances(com.google.common.collect.ImmutableList<InstanceProvider> registered)
registered - - list of instance providers.public DefaultInstances(DefaultInstances other)
other - - instance provider to copy.public DefaultInstances(InstanceProvider... instaceProviders)
instaceProviders - - array of instance providers.public static DefaultInstances fromArray(InstanceProvider... instanceProviders)
instanceProviders - - array of instance providers.public static DefaultInstances fromCollection(Collection<InstanceProvider> instanceProviders)
instanceProviders - - collection of instance providers.public com.google.common.collect.ImmutableList<InstanceProvider> getRegistered()
public boolean isNonNull()
public void setNonNull(boolean nonNull)
nonNull - - TRUE if they must be non-null, FALSE otherwise.public int getMaximumRecursion()
public void setMaximumRecursion(int maximumRecursion)
maximumRecursion - - maximum recursion height.public <T> T getDefault(Class<T> type)
This includes, but isn't limited too:
T - Typetype - - the type to construct a default value.public <T> Constructor<T> getMinimumConstructor(Class<T> type)
T - Typetype - - type to construct.public <T> T getDefault(Class<T> type, List<InstanceProvider> providers)
This includes, but isn't limited too:
T - Typetype - - the type to construct a default value.providers - - instance providers used during the construction.public DefaultInstances forEnhancer(net.sf.cglib.proxy.Enhancer enhancer)
enhancer - - a CGLIB enhancer to use.protected <T> T createInstance(Class<T> type, Constructor<T> constructor, Class<?>[] types, Object[] params)
T - Typetype - - the type to create.constructor - - the constructor to use.types - - type of each parameter in order.params - - value of each parameter in order.protected <T> boolean contains(T[] elements,
T elementToFind)
public Object create(@Nullable Class<?> type)
InstanceProvidercreate in interface InstanceProvidertype - - type to create.Copyright © 2012–2017 Comphenix and dmulloy2. Licensed under the GNU GPL v2.