package org.snmp4j.agent;

import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;

/* JADX INFO: loaded from: classes.dex */
public class DefaultMOContextScope extends DefaultMOScope implements MOContextScope {
    private OctetString context;

    public DefaultMOContextScope(OctetString octetString, OID oid, boolean z, OID oid2, boolean z2) {
        super(oid, z, oid2, z2);
        this.context = octetString;
    }

    public static boolean isContextMatching(MOScope mOScope, MOScope mOScope2) {
        if (!(mOScope instanceof MOContextScope)) {
            return true;
        }
        OctetString context = ((MOContextScope) mOScope).getContext();
        if (mOScope2 instanceof MOContextScope) {
            return context == null || context.equals(((MOContextScope) mOScope2).getContext());
        }
        return true;
    }

    @Override // org.snmp4j.agent.DefaultMOScope
    public boolean equals(Object obj) {
        return (obj instanceof MOContextScope) && this.context.equals(((MOContextScope) obj).getContext()) && super.equals(obj);
    }

    @Override // org.snmp4j.agent.MOContextScope
    public OctetString getContext() {
        return this.context;
    }

    @Override // org.snmp4j.agent.DefaultMOScope
    public int hashCode() {
        if (this.context == null) {
            return super.hashCode();
        }
        int iHashCode = super.hashCode();
        for (int i2 = 0; i2 < this.context.length(); i2++) {
            int i3 = iHashCode + this.context.get(i2);
            int i4 = i3 + (i3 << 10);
            iHashCode = i4 ^ (i4 >> 6);
        }
        int i5 = iHashCode + (iHashCode << 3);
        int i6 = i5 ^ (i5 >> 11);
        return i6 + (i6 << 15);
    }

    @Override // org.snmp4j.agent.DefaultMOScope, org.snmp4j.agent.MOScope
    public boolean isCovered(MOScope mOScope) {
        OctetString octetString = this.context;
        if (octetString == null || !(mOScope instanceof MOContextScope) || octetString.equals(((MOContextScope) mOScope).getContext())) {
            return DefaultMOScope.covers(this, mOScope);
        }
        return false;
    }

    @Override // org.snmp4j.agent.DefaultMOScope, org.snmp4j.agent.MOScope
    public boolean isOverlapping(MOScope mOScope) {
        if (isContextMatching(this, mOScope)) {
            return super.isOverlapping(mOScope);
        }
        return false;
    }

    public void setContext(OctetString octetString) {
        this.context = octetString;
    }

    @Override // org.snmp4j.agent.DefaultMOScope
    public String toString() {
        return DefaultMOContextScope.class.getName() + "[context=" + this.context + ",lowerBound=" + this.lowerBound + ",lowerIncluded=" + this.lowerIncluded + ",upperBound=" + this.upperBound + ",upperIncluded=" + this.upperIncluded + "]";
    }

    public DefaultMOContextScope(MOContextScope mOContextScope) {
        super(mOContextScope.getLowerBound(), mOContextScope.isLowerIncluded(), mOContextScope.getUpperBound(), mOContextScope.isUpperIncluded());
        this.context = mOContextScope.getContext();
    }

    public DefaultMOContextScope(OctetString octetString, MOScope mOScope) {
        super(mOScope);
        this.context = octetString;
    }
}
