public class DefaultInstances
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static DefaultInstances |
DEFAULT
Standard default instance provider.
|
Constructor and Description |
---|
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) |
protected <T> T |
createInstance(java.lang.Class<T> type,
java.lang.reflect.Constructor<T> constructor,
java.lang.Class<?>[] types,
java.lang.Object[] params)
Used by the default instance provider to create a class from a given constructor.
|
static DefaultInstances |
fromArray(InstanceProvider... instaceProviders)
Construct a default instance generator using the given instance providers.
|
<T> T |
getDefault(java.lang.Class<T> type)
Retrieves a default instance or value that is assignable to this type.
|
<T> T |
getDefault(java.lang.Class<T> type,
java.util.List<InstanceProvider> providers)
Retrieves a default instance or value that is assignable to this type.
|
com.google.common.collect.ImmutableList<InstanceProvider> |
getRegistered()
Retrieves a immutable list of every default object providers that generates instances.
|
public static DefaultInstances DEFAULT
public DefaultInstances(com.google.common.collect.ImmutableList<InstanceProvider> registered)
registered
- - list of instance providers.public DefaultInstances(InstanceProvider... instaceProviders)
instaceProviders
- - array of instance providers.public static DefaultInstances fromArray(InstanceProvider... instaceProviders)
instaceProviders
- - array of instance providers.public com.google.common.collect.ImmutableList<InstanceProvider> getRegistered()
public <T> T getDefault(java.lang.Class<T> type)
This includes, but isn't limited too:
type
- - the type to construct a default value.public <T> T getDefault(java.lang.Class<T> type, java.util.List<InstanceProvider> providers)
This includes, but isn't limited too:
type
- - the type to construct a default value.providers
- - instance providers used during theprotected <T> T createInstance(java.lang.Class<T> type, java.lang.reflect.Constructor<T> constructor, java.lang.Class<?>[] types, java.lang.Object[] params)
type
- - 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)