package vg;

import java.util.regex.Pattern;
import vg.q;

/* loaded from: classes4.dex */
public class b implements f {

    /* renamed from: a, reason: collision with root package name */
    private final a f39680a;

    /* loaded from: classes4.dex */
    public enum a {
        DEFAULT,
        CASE_INSENSITIVE
    }

    public b(a aVar) {
        this.f39680a = aVar;
    }

    private boolean c(Object obj, Object obj2) {
        return ((obj instanceof String) && (obj2 instanceof String) && this.f39680a == a.CASE_INSENSITIVE) ? obj.toString().equalsIgnoreCase(obj2.toString()) : obj.equals(obj2);
    }

    private boolean d(Object obj, Object obj2) {
        if (!(obj instanceof String) || !(obj2 instanceof String)) {
            return false;
        }
        String obj3 = obj.toString();
        String obj4 = obj2.toString();
        if (this.f39680a == a.CASE_INSENSITIVE) {
            obj3 = obj3.toLowerCase();
            obj4 = obj4.toLowerCase();
        }
        return obj3.contains(obj4);
    }

    private boolean e(Object obj, Object obj2) {
        if (!(obj instanceof String) || !(obj2 instanceof String)) {
            return false;
        }
        String obj3 = obj.toString();
        String obj4 = obj2.toString();
        return obj3.matches((this.f39680a == a.CASE_INSENSITIVE ? "(?i)" : "") + ".*" + Pattern.quote(obj4));
    }

    private boolean f(Object obj) {
        return obj != null;
    }

    private boolean g(Object obj, Object obj2) {
        Double o10 = o(obj);
        Double o11 = o(obj2);
        return (o10 == null || o11 == null || o10.doubleValue() <= o11.doubleValue()) ? false : true;
    }

    private boolean h(Object obj, Object obj2) {
        Double o10 = o(obj);
        Double o11 = o(obj2);
        return (o10 == null || o11 == null || o10.doubleValue() < o11.doubleValue()) ? false : true;
    }

    private boolean i(Object obj, Object obj2) {
        Double o10 = o(obj);
        Double o11 = o(obj2);
        return (o10 == null || o11 == null || o10.doubleValue() >= o11.doubleValue()) ? false : true;
    }

    private boolean j(Object obj, Object obj2) {
        Double o10 = o(obj);
        Double o11 = o(obj2);
        return (o10 == null || o11 == null || o10.doubleValue() > o11.doubleValue()) ? false : true;
    }

    private boolean k(Object obj, Object obj2) {
        return !d(obj, obj2);
    }

    private boolean l(Object obj, Object obj2) {
        return !c(obj, obj2);
    }

    private boolean m(Object obj) {
        return obj == null;
    }

    private boolean n(Object obj, Object obj2) {
        if (!(obj instanceof String) || !(obj2 instanceof String)) {
            return false;
        }
        String obj3 = obj.toString();
        String obj4 = obj2.toString();
        return obj3.matches((this.f39680a == a.CASE_INSENSITIVE ? "(?i)" : "") + Pattern.quote(obj4) + ".*");
    }

    private Double o(Object obj) {
        try {
            return Double.valueOf(obj.toString());
        } catch (Exception unused) {
            return null;
        }
    }

    @Override // vg.f
    public q a(String str, Object obj) {
        boolean f10;
        str.hashCode();
        if (str.equals("exists")) {
            f10 = f(obj);
        } else {
            if (!str.equals("notExist")) {
                return new q(q.a.MISSING_OPERATOR, String.format("Operator is invalid \"%s\"", str));
            }
            f10 = m(obj);
        }
        return f10 ? q.f39705d : new q(q.a.CONDITION_FAILED, String.format("Condition not matched for operation \"%s\"", str));
    }

    @Override // vg.f
    public q b(Object obj, String str, Object obj2) {
        boolean n10;
        str.hashCode();
        char c10 = 65535;
        switch (str.hashCode()) {
            case -1555538761:
                if (str.equals("startsWith")) {
                    c10 = 0;
                    break;
                }
                break;
            case -1398769830:
                if (str.equals("greaterEqual")) {
                    c10 = 1;
                    break;
                }
                break;
            case -1295482945:
                if (str.equals("equals")) {
                    c10 = 2;
                    break;
                }
                break;
            case -567445985:
                if (str.equals("contains")) {
                    c10 = 3;
                    break;
                }
                break;
            case -148438510:
                if (str.equals("notContains")) {
                    c10 = 4;
                    break;
                }
                break;
            case 341896475:
                if (str.equals("lessEqual")) {
                    c10 = 5;
                    break;
                }
                break;
            case 881486962:
                if (str.equals("notEquals")) {
                    c10 = 6;
                    break;
                }
                break;
            case 925147323:
                if (str.equals("greaterThan")) {
                    c10 = 7;
                    break;
                }
                break;
            case 1743158238:
                if (str.equals("endsWith")) {
                    c10 = '\b';
                    break;
                }
                break;
            case 2089676506:
                if (str.equals("lessThan")) {
                    c10 = '\t';
                    break;
                }
                break;
        }
        switch (c10) {
            case 0:
                n10 = n(obj, obj2);
                break;
            case 1:
                n10 = h(obj, obj2);
                break;
            case 2:
                n10 = c(obj, obj2);
                break;
            case 3:
                n10 = d(obj, obj2);
                break;
            case 4:
                n10 = k(obj, obj2);
                break;
            case 5:
                n10 = j(obj, obj2);
                break;
            case 6:
                n10 = l(obj, obj2);
                break;
            case 7:
                n10 = g(obj, obj2);
                break;
            case '\b':
                n10 = e(obj, obj2);
                break;
            case '\t':
                n10 = i(obj, obj2);
                break;
            default:
                return new q(q.a.MISSING_OPERATOR, String.format("Operator is invalid \"%s\"", str));
        }
        return n10 ? q.f39705d : new q(q.a.CONDITION_FAILED, String.format("Condition not matched for operation \"%s\"", str));
    }
}
