public class InstantiationUtils extends Object
| Constructor and Description |
|---|
InstantiationUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
instantiate(Class<T> type)
Instantiate the given class rethrowing any exceptions as
InstantiationException. |
static <T> T |
instantiate(String type,
Class<T> requiredType)
Instantiate the given class rethrowing any exceptions as
InstantiationException. |
static Object |
instantiate(String type,
ClassLoader classLoader)
Instantiate the given class rethrowing any exceptions as
InstantiationException. |
static <T> Optional<T> |
tryInstantiate(Class<T> type)
Try to instantiate the given class using the most optimal strategy first trying the
BeanIntrospector and
if no bean is present falling back to reflection. |
static <T> Optional<T> |
tryInstantiate(Class<T> type,
Map propertiesMap,
ConversionContext context)
Try to instantiate the given class using
BeanIntrospector. |
static <T> Optional<T> |
tryInstantiate(Constructor<T> type,
Object... args)
Try to instantiate the given class.
|
static Optional<?> |
tryInstantiate(String name,
ClassLoader classLoader)
Try to instantiate the given class.
|
public static Optional<?> tryInstantiate(String name, ClassLoader classLoader)
name - The class nameclassLoader - The class loader to useOptional.empty()@Nonnull public static <T> Optional<T> tryInstantiate(@Nonnull Class<T> type, Map propertiesMap, ConversionContext context)
BeanIntrospector.T - The generic typetype - The typepropertiesMap - The properties values Map of the instancecontext - The Conversion contextOptional.empty()InstantiationException - When an error occurs@Nonnull public static <T> Optional<T> tryInstantiate(@Nonnull Class<T> type)
BeanIntrospector and
if no bean is present falling back to reflection.T - The generic typetype - The typeOptional.empty()@Nonnull public static <T> Optional<T> tryInstantiate(@Nonnull Constructor<T> type, Object... args)
T - The generic typetype - The typeargs - The arguments to the constructorOptional.empty()public static <T> T instantiate(Class<T> type)
InstantiationException.T - The generic typetype - The typeInstantiationException - When an error occurspublic static Object instantiate(String type, ClassLoader classLoader)
InstantiationException.type - The typeclassLoader - The classloaderInstantiationException - When an error occurspublic static <T> T instantiate(String type, Class<T> requiredType)
InstantiationException.T - The typetype - The typerequiredType - The required typeInstantiationException - When an error occurs