package org.snmp4j.agent.util;

import org.snmp4j.smi.Counter64;
import org.snmp4j.smi.Integer32;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.UnsignedInteger32;
import org.snmp4j.smi.Variable;

/* JADX INFO: loaded from: classes.dex */
public class IndexGenerator {
    private boolean impliedLength;
    private Variable seedSubIndex;

    public IndexGenerator(Variable variable) {
        if ((variable instanceof Integer32) || (variable instanceof UnsignedInteger32) || (variable instanceof Counter64)) {
            this.seedSubIndex = variable;
            return;
        }
        throw new IllegalArgumentException("A seed subindex of type " + variable.getSyntaxString() + "is not supported");
    }

    public synchronized OID getNextSubIndex() {
        if (this.seedSubIndex instanceof Integer32) {
            Integer32 integer32 = (Integer32) this.seedSubIndex;
            integer32.setValue(integer32.getValue() + 1);
        } else if (this.seedSubIndex instanceof UnsignedInteger32) {
            UnsignedInteger32 unsignedInteger32 = (UnsignedInteger32) this.seedSubIndex;
            unsignedInteger32.setValue(unsignedInteger32.getValue() + 1);
        } else if (this.seedSubIndex instanceof Counter64) {
            Counter64 counter64 = (Counter64) this.seedSubIndex;
            counter64.setValue(counter64.getValue() + 1);
        }
        return this.seedSubIndex.toSubIndex(this.impliedLength);
    }

    public IndexGenerator(Variable variable, boolean z) {
        this(variable);
        this.impliedLength = z;
    }
}
