io.honeybadger.com.github.mustachejava.reflect.GuardedWrapper Maven / Gradle / Ivy
package com.github.mustachejava.reflect;
import com.github.mustachejava.util.GuardException;
import com.github.mustachejava.util.Wrapper;
import java.util.Arrays;
import java.util.List;
import static java.util.Arrays.asList;
/**
* Wrapper that guards.
*/
public class GuardedWrapper implements Wrapper {
// We only need a single guard exception -- don't fill stack trace
// and don't reallocate it.
@SuppressWarnings("ThrowableInstanceNeverThrown")
protected static final GuardException guardException = new GuardException();
static {
guardException.setStackTrace(new StackTraceElement[0]);
}
// Array of guards that must be satisfied
protected final Guard[] guards;
// Hashcode cache
private int hashCode;
public GuardedWrapper(Guard[] guards) {
this.guards = guards;
}
@Override
public Object call(List