@Override public <T> Bindable<T> onStart(ConfigurationPropertyName name, Bindable<T> target, BindContext context) { return this.parent.onStart(name, target, context); }
@Override public Object onFailure(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Exception error) throws Exception { return this.parent.onFailure(name, target, context, error); }
@Override public void onFinish(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) throws Exception { this.parent.onFinish(name, target, context, result); }
private <T> T handleBindResult(ConfigurationPropertyName name, Bindable<T> target, BindHandler handler, Context context, Object result) throws Exception { if (result != null) { result = handler.onSuccess(name, target, context, result); result = context.getConverter().convert(result, target); } handler.onFinish(name, target, context, result); return context.getConverter().convert(result, target); }
@Override public Object onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) { return this.parent.onSuccess(name, target, context, result); }
protected final <T> T bind(ConfigurationPropertyName name, Bindable<T> target, BindHandler handler, Context context, boolean allowRecursiveBinding) { context.clearConfigurationProperty(); try { target = handler.onStart(name, target, context); if (target == null) { return null; } Object bound = bindObject(name, target, handler, context, allowRecursiveBinding); return handleBindResult(name, target, handler, context, bound); } catch (Exception ex) { return handleBindError(name, target, handler, context, ex); } }
private <T> T handleBindError(ConfigurationPropertyName name, Bindable<T> target, BindHandler handler, Context context, Exception error) { try { Object result = handler.onFailure(name, target, context, error); return context.getConverter().convert(result, target); } catch (Exception ex) { if (ex instanceof BindException) { throw (BindException) ex; } throw new BindException(name, target, context.getConfigurationProperty(), ex); } }
@Override public <T> Bindable<T> onStart(ConfigurationPropertyName name, Bindable<T> target, BindContext context) { ConfigurationPropertyName defaultName = getDefaultName(name); if (defaultName != null) { BindResult<T> result = context.getBinder().bind(defaultName, target); if (result.isBound()) { return target.withExistingValue(result.get()); } } return bindHandler.onStart(name, target, context); } };