@Override
@SuppressWarnings("unchecked")
public Object nullPropertyValue(Map context, Object target, Object property) {
OgnlContext ctx = (OgnlContext) context;
EmptyElementsRemoval removal = (EmptyElementsRemoval) ctx.get("removal");
GenericNullHandler generic = new GenericNullHandler(removal);
ListNullHandler list = new ListNullHandler(removal);
if (target == ctx.getRoot() && target instanceof List) {
return list.instantiate(target, property, (Type) context.get("rootType"));
}
int indexInParent = ctx.getCurrentEvaluation().getNode().getIndexInParent();
int maxIndex = ctx.getRootEvaluation().getNode().jjtGetNumChildren() - 1;
if (!(indexInParent != -1 && indexInParent < maxIndex)) {
return null;
}
if (target instanceof List) {
return list.instantiate(target, property, list.getListType(target, ctx.getCurrentEvaluation().getPrevious()));
}
String propertyCapitalized = Info.capitalize((String) property);
Method getter = findMethod(target.getClass(), "get" + propertyCapitalized, target.getClass(), null);
Type returnType = getter.getGenericReturnType();