Object value = getValue();
if (null !=value && value instanceof Cloneable) {
try {
ELContext initialELContext = context.getELContext();
CapturingELResolver capturingELResolver = new CapturingELResolver(initialELContext.getELResolver());
Class<?> type = valueExpression.getType(new ELContextWrapper(initialELContext, capturingELResolver));
if(null != type) {
validatorState = new GraphValidatorState();
Method method = getCloneMethod(value.getClass());
if(!Modifier.isPublic(method.getModifiers())){
// Method Object#clone() is protected by default. Make it public
// unless developer did it.
method.setAccessible(true);
}
validatorState.cloned = method.invoke(value);
validatorState.base = capturingELResolver.getBase();
validatorState.property = capturingELResolver.getProperty();
validatorState.active = true;
context.getExternalContext().getRequestMap().put(getStateId(context), validatorState);
}
} catch (NoSuchMethodException e) {
// do nothing, that is really not possible.