Class BeanUtils


  • public class BeanUtils
    extends Object
    Methods for constructing beans and setting their parameters using value in the Config
    Author:
    David B. Bracewell
    • Constructor Detail

      • BeanUtils

        public BeanUtils()
    • 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 bean
        clazz - 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