Package org.planit.configurator
Class Configurator<T>
- java.lang.Object
-
- org.planit.configurator.Configurator<T>
-
public abstract class Configurator<T> extends Object
This is the base class for all configuration oriented proxy classes. Whenever we configure a traffic assignment component, or any other component with functionality that should not be exposed to the user, while at the same time this user must be able to configure this class by setting one or more configuration options, we must use this class to provide a convenient mapping mechanism that work for any such situation without having to manually implement all the configuration options that are already present on the class that contains the functionality. The aim of this configurator is to store all the function calls that should be delayed and deferred to the class that contains the actual functionality in a concise and general way.- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object[]>
delayedMethodCalls
the methods to invoke on the to be configured object instance and their parameters
-
Constructor Summary
Constructors Modifier Constructor Description protected
Configurator()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
callVoidMethod(T instance, String methodName, Object... parameters)
Call a void method on the toConfigure class instanceprotected Class<?>[]
collectParameterTypes(Object... parameters)
collect the parameter types of the passed in object in their original ordervoid
configure(T toConfigureInstance)
Configure the passed in instance with the registered method callsprotected void
registerDelayedSetter(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
-
-
-
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
-
callVoidMethod
protected void callVoidMethod(T instance, String methodName, Object... parameters) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, PlanItException, NoSuchMethodException, SecurityException
Call a void method on the toConfigure class instance- Parameters:
instance
- to call method onmethodName
- to callparameters
- to add to call- Throws:
IllegalAccessException
- thrown if errorIllegalArgumentException
- thrown if errorInvocationTargetException
- thrown if errorPlanItException
- thrown if instance or its class are unknownNoSuchMethodException
- thrown if errorSecurityException
- thrown if error
-
registerDelayedSetter
protected void registerDelayedSetter(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 nameparameters
- the parameters of the method
-
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
-
-