package org.eclipse.paho.mqttv5.common;

/* JADX INFO: loaded from: classes2.dex */
public class MqttSubscription {
    private int messageId;
    private String topic;
    private boolean mutable = true;
    private int qos = 1;
    private boolean noLocal = false;
    private boolean retainAsPublished = false;
    private int retainHandling = 0;

    public MqttSubscription(String str) {
        setTopic(str);
    }

    public MqttSubscription(String str, int i) {
        setTopic(str);
        setQos(i);
    }

    public static void validateQos(int i) {
        if (i < 0 || i > 2) {
            throw new IllegalArgumentException();
        }
    }

    public static void validateRetainHandling(int i) {
        if (i < 0 || i > 2) {
            throw new IllegalArgumentException();
        }
    }

    protected void setMutable(boolean z) {
        this.mutable = z;
    }

    protected void checkMutable() throws IllegalStateException {
        if (!this.mutable) {
            throw new IllegalStateException();
        }
    }

    public String getTopic() {
        return this.topic;
    }

    public void setTopic(String str) {
        checkMutable();
        str.getClass();
        this.topic = str;
    }

    public int getQos() {
        return this.qos;
    }

    public void setQos(int i) {
        checkMutable();
        validateQos(i);
        this.qos = i;
    }

    public boolean isNoLocal() {
        return this.noLocal;
    }

    public void setNoLocal(boolean z) {
        checkMutable();
        this.noLocal = z;
    }

    public boolean isRetainAsPublished() {
        return this.retainAsPublished;
    }

    public void setRetainAsPublished(boolean z) {
        checkMutable();
        this.retainAsPublished = z;
    }

    public int getRetainHandling() {
        return this.retainHandling;
    }

    public void setRetainHandling(int i) {
        checkMutable();
        validateRetainHandling(i);
        this.retainHandling = i;
    }

    public String toString() {
        return "MqttSubscription [mutable=" + this.mutable + ", topic=" + this.topic + ", qos=" + this.qos + ", noLocal=" + this.noLocal + ", retainAsPublished=" + this.retainAsPublished + ", retainHandling=" + this.retainHandling + "]";
    }

    public void setId(int i) {
        this.messageId = i;
    }

    public int getId() {
        return this.messageId;
    }
}
