package net.gotev.uploadservice;

import android.os.Parcel;
import android.os.Parcelable;
/* loaded from: classes.dex */
public final class NameValue implements Parcelable {
    public static final Parcelable.Creator<NameValue> CREATOR = new Parcelable.Creator<NameValue>() { // from class: net.gotev.uploadservice.NameValue.1
        @Override // android.os.Parcelable.Creator
        public NameValue createFromParcel(Parcel parcel) {
            return new NameValue(parcel);
        }

        @Override // android.os.Parcelable.Creator
        public NameValue[] newArray(int i) {
            return new NameValue[i];
        }
    };
    private final String name;
    private final String value;

    @Override // android.os.Parcelable
    public int describeContents() {
        return 0;
    }

    public NameValue(String str, String str2, boolean z) {
        if (z && (!isAllASCII(str) || !isAllASCII(str2))) {
            throw new IllegalArgumentException("Header " + str + " must be ASCII only! Read http://stackoverflow.com/a/4410331");
        }
        this.name = str;
        this.value = str2;
    }

    public final String getName() {
        return this.name;
    }

    public final String getValue() {
        return this.value;
    }

    public boolean equals(Object obj) {
        if (obj instanceof NameValue) {
            NameValue nameValue = (NameValue) obj;
            return this.name.equals(nameValue.name) && this.value.equals(nameValue.value);
        }
        return false;
    }

    @Override // android.os.Parcelable
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(this.name);
        parcel.writeString(this.value);
    }

    private NameValue(Parcel parcel) {
        this.name = parcel.readString();
        this.value = parcel.readString();
    }

    private static boolean isAllASCII(String str) {
        if (str == null || str.isEmpty()) {
            return false;
        }
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) > 127) {
                return false;
            }
        }
        return true;
    }
}
