Package com.gengoai.reflection
Class BeanUtils
- java.lang.Object
-
- com.gengoai.reflection.BeanUtils
-
-
Constructor Summary
Constructors Constructor Description BeanUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
getBean(@NonNull Class<T> clazz)
Constructs a new instance of the given class and then sets it properties using configuration.static <T> T
getNamedBean(@NonNull String name, @NonNull Class<T> clazz)
Instantiates a named bean (defined via the Config)static <T> T
parameterizeObject(T object)
Sets properties on an object using the values defined in the Config.
-
-
-
Method Detail
-
getBean
public static <T> T getBean(@NonNull @NonNull Class<T> clazz) throws ReflectionException
Constructs a new instance of the given class and then sets it properties using configuration.- Parameters:
clazz
- The class that we want to instantiate- Returns:
- A new instance of the given class
- Throws:
ReflectionException
-
getNamedBean
public static <T> T getNamedBean(@NonNull @NonNull String name, @NonNull @NonNull Class<T> clazz) throws ReflectionException
Instantiates a named bean (defined via the Config)- Parameters:
name
- The name of the beanclazz
- The class type of the bean- Returns:
- The named bean
- Throws:
ReflectionException
-
parameterizeObject
public static <T> T parameterizeObject(T object)
Sets properties on an object using the values defined in the Config. Will set properties defined in the Config for all of this object's super classes as well.- Parameters:
object
- The object to parameterize- Returns:
- The object
-
-