@Override public ConfigMethod newInstance(Class<?> configInterface, Method method) { return new ConfigSetter(configInterface, method); } };
/** * Set a configuration field value. * * @param persister The configuration source. * @param value The field value. */ public void setProperty(ConfigPersister persister, Object value) { String str; if (stringifier == null || value == null) str = (String) value; else str = stringifier.stringify(value); persister.setProperty(sourceType, getPropertyName(), str); }
/** * {@inheritDoc} * This implementation invokes {@link #setProperty} with the * filed value. */ @Override public Object invoke(ConfigHandler handler, Object[] args, Object proxy) { setProperty(handler.getPersister(), args[0]); return null; }
/** * Create a new ConfigSetter instance. * * @param configInterface The configuration interface. * @param method The method. */ public ConfigSetter(Class<?> configInterface, Method method) { super(configInterface, method); Method getMethod = ConfigUtil.getGetMethod(configInterface, method); Preconditions.checkNotNullArgument(getMethod, String.format("Cannot find getter for config \"%s\" property \"%s\"", configInterface.getSimpleName(), getPropertyName())); sourceType = ConfigUtil.getSourceType(configInterface, method); if (!String.class.equals(ConfigUtil.getMethodType(method))) stringifier = TypeStringify.getInstance(configInterface, method); }