/** * Registers the specified {@code DefaultParametersHandler} object for the * given parameters class. This is a convenience method which just delegates * to the associated {@code DefaultParametersManager}. * * @param <T> the type of the parameters supported by this handler * @param paramsClass the parameters class supported by this handler (must * not be <b>null</b>) * @param handler the {@code DefaultParametersHandler} to be registered * (must not be <b>null</b>) * @throws IllegalArgumentException if a required parameter is missing * @see DefaultParametersManager */ public <T> void registerDefaultsHandler(final Class<T> paramsClass, final DefaultParametersHandler<? super T> handler) { getDefaultParametersManager().registerDefaultsHandler(paramsClass, handler); }
/** * Registers the specified {@code DefaultParametersHandler} object for the * given parameters class and start class in the inheritance hierarchy. This * is a convenience method which just delegates to the associated * {@code DefaultParametersManager}. * * @param <T> the type of the parameters supported by this handler * @param paramsClass the parameters class supported by this handler (must * not be <b>null</b>) * @param handler the {@code DefaultParametersHandler} to be registered * (must not be <b>null</b>) * @param startClass an optional start class in the hierarchy of parameter * objects for which this handler should be applied * @throws IllegalArgumentException if a required parameter is missing */ public <T> void registerDefaultsHandler(final Class<T> paramsClass, final DefaultParametersHandler<? super T> handler, final Class<?> startClass) { getDefaultParametersManager().registerDefaultsHandler(paramsClass, handler, startClass); }
/** * Creates a proxy object for a given parameters interface based on the * given implementation object. The newly created object is initialized * with default values if there are matching {@link DefaultParametersHandler} * objects. * * @param <T> the type of the parameters interface * @param target the implementing target object * @param ifcClass the interface class * @param superIfcs an array with additional interface classes to be * implemented * @return the proxy object */ private <T> T createParametersProxy(final Object target, final Class<T> ifcClass, final Class<?>... superIfcs) { final Class<?>[] ifcClasses = new Class<?>[1 + superIfcs.length]; ifcClasses[0] = ifcClass; System.arraycopy(superIfcs, 0, ifcClasses, 1, superIfcs.length); final Object obj = Proxy.newProxyInstance(Parameters.class.getClassLoader(), ifcClasses, new ParametersIfcInvocationHandler(target)); getDefaultParametersManager().initializeParameters( (BuilderParameters) obj); return ifcClass.cast(obj); }