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.List;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public class MapGuard implements Guard {
    protected final boolean contains;
    protected final String name;
    protected final ObjectHandler oh;
    protected final int scopeIndex;
    protected final Wrapper[] wrappers;

    public MapGuard(ObjectHandler objectHandler, int i, String str, boolean z, Wrapper[] wrapperArr) {
        this.oh = objectHandler;
        this.scopeIndex = i;
        this.name = str;
        this.contains = z;
        this.wrappers = wrapperArr;
    }

    @Override // com.github.mustachejava.reflect.Guard
    public boolean apply(List<Object> list) {
        Object objUnwrap = ReflectionObjectHandler.unwrap(this.oh, this.scopeIndex, this.wrappers, list);
        if (!(objUnwrap instanceof Map)) {
            return false;
        }
        Map map = (Map) objUnwrap;
        if (this.contains) {
            return map.containsKey(this.name);
        }
        return !map.containsKey(this.name);
    }

    public String toString() {
        return "[MapGuard: " + this.scopeIndex + " " + this.name + " " + this.contains + "]";
    }
}
