Class Configurator<T>

    • Field Detail

      • delayedMethodCalls

        protected final Map<String,​List<Object[]>> delayedMethodCalls
        The methods to invoke on the to be configured object instance and their parameters. Since the same method could be called multiple times (with different parameters) we track a list per call
    • Constructor Detail

      • Configurator

        public Configurator​(Class<T> instanceType)
        Constructor
        Parameters:
        instanceType - the class type of the instance we are configuring
    • Method Detail

      • collectParameterTypes

        protected Class<?>[] collectParameterTypes​(Object... parameters)
                                            throws PlanItException
        collect the parameter types of the passed in object in their original order
        Parameters:
        parameters - the parameters
        Returns:
        parameterTypes array
        Throws:
        PlanItException - thrown if error
      • registerDelayedMethodCall

        protected void registerDelayedMethodCall​(String methodName,
                                                 Object... parameters)
        Register a method call to a setter that should be invoked on the to be configured object instance once it is available
        Parameters:
        methodName - the method name
        parameters - the parameters of the method
      • getFirstParameterOfDelayedMethodCall

        protected Object getFirstParameterOfDelayedMethodCall​(String methodName)
        Collect the first parameter submitted with (last) registered delayed method call of given signature. If not available null is returned. Useful to mimic getters for a given setter on configurator derived class.
        Parameters:
        methodName - that reflects the delayed call
        Returns:
        first parameter of delay method name call
      • getClassTypeToConfigure

        public Class<T> getClassTypeToConfigure()
        collect the class type we are configuring for
        Returns:
        class type
      • configure

        public void configure​(T toConfigureInstance)
                       throws PlanItException
        Configure the passed in instance with the registered method calls
        Parameters:
        toConfigureInstance - the instance to configure
        Throws:
        PlanItException - thrown if error