package com.github.mustachejava.reflect.guards;

import com.github.mustachejava.ObjectHandler;
import com.github.mustachejava.reflect.Guard;
import com.github.mustachejava.reflect.ReflectionObjectHandler;
import com.github.mustachejava.util.Wrapper;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class WrappedGuard implements Guard {
    private static final Wrapper[] EMPTY_WRAPPERS = new Wrapper[0];
    protected final int index;
    protected final ObjectHandler oh;
    private final List<Guard> wrapperGuard;
    protected final Wrapper[] wrappers;

    public WrappedGuard(ObjectHandler objectHandler, int i, List<Wrapper> list, List<Guard> list2) {
        this.oh = objectHandler;
        this.index = i;
        this.wrappers = (Wrapper[]) list.toArray(EMPTY_WRAPPERS);
        this.wrapperGuard = list2;
    }

    @Override // com.github.mustachejava.reflect.Guard
    public boolean apply(List<Object> list) {
        Object objUnwrap = ReflectionObjectHandler.unwrap(this.oh, this.index, this.wrappers, list);
        Iterator<Guard> it = this.wrapperGuard.iterator();
        while (it.hasNext()) {
            if (!it.next().apply(ObjectHandler.makeList(objUnwrap))) {
                return false;
            }
        }
        return true;
    }

    public String toString() {
        return "[WrappedGuard: " + this.index + " " + this.wrapperGuard + "]";
    }
}
