io.honeybadger.com.github.mustachejava.reflect.ReflectionWrapper Maven / Gradle / Ivy
package com.github.mustachejava.reflect;
import com.github.mustachejava.MustacheException;
import com.github.mustachejava.ObjectHandler;
import com.github.mustachejava.util.GuardException;
import com.github.mustachejava.util.Wrapper;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
/**
* Used for evaluating values at a callsite
*/
public class ReflectionWrapper extends GuardedWrapper {
// Context
protected final int scopeIndex;
protected final Wrapper[] wrappers;
protected final ObjectHandler oh;
// Dispatch
protected final Method method;
protected final Field field;
protected final Object[] arguments;
public ReflectionWrapper(int scopeIndex, Wrapper[] wrappers, Guard[] guard, AccessibleObject method, Object[] arguments, ObjectHandler oh) {
super(guard);
this.wrappers = wrappers;
this.oh = oh;
if (method instanceof Field) {
this.method = null;
this.field = (Field) method;
} else {
this.method = (Method) method;
this.field = null;
}
this.arguments = arguments;
this.scopeIndex = scopeIndex;
}
protected Object unwrap(List