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;

/* JADX INFO: loaded from: classes.dex */
public class GuardedWrapper implements Wrapper {
    protected static final GuardException guardException;
    protected final Guard[] guards;
    private int hashCode;

    static {
        GuardException guardException2 = new GuardException();
        guardException = guardException2;
        guardException2.setStackTrace(new StackTraceElement[0]);
    }

    public GuardedWrapper(Guard[] guardArr) {
        this.guards = guardArr;
    }

    @Override // com.github.mustachejava.util.Wrapper
    public Object call(List<Object> list) throws GuardException {
        guardCall(list);
        return null;
    }

    protected void guardCall(List<Object> list) throws GuardException {
        for (Guard guard : this.guards) {
            if (!guard.apply(list)) {
                throw guardException;
            }
        }
    }

    public int hashCode() {
        if (this.hashCode == 0) {
            for (Guard guard : this.guards) {
                int i = this.hashCode;
                this.hashCode = i + (i * 43) + guard.hashCode();
            }
            if (this.hashCode == 0) {
                this.hashCode = 1;
            }
        }
        return this.hashCode;
    }

    public boolean equals(Object obj) {
        if (!(obj instanceof GuardedWrapper)) {
            return false;
        }
        GuardedWrapper guardedWrapper = (GuardedWrapper) obj;
        Guard[] guardArr = this.guards;
        return (guardArr == null && guardedWrapper.guards == null) || Arrays.equals(guardedWrapper.guards, guardArr);
    }

    public Guard[] getGuards() {
        return this.guards;
    }

    public String toString() {
        return "[GuardedWrapper: " + Arrays.asList(this.guards) + "]";
    }
}
