package io.grpc; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import java.util.Collections; import java.util.IdentityHashMap; import java.util.Map; import java.util.Set; /* loaded from: classes6.dex */ public final class Attributes { static final boolean $assertionsDisabled = false; public static final Attributes EMPTY = new Attributes(Collections.emptyMap()); private final Map, Object> data; private Attributes(Map, Object> map) { this.data = map; } public final T get(Key key) { return (T) this.data.get(key); } @Deprecated public final Set> keys() { return Collections.unmodifiableSet(this.data.keySet()); } final Set> keysForTest() { return Collections.unmodifiableSet(this.data.keySet()); } @Deprecated public static Builder newBuilder(Attributes attributes) { Preconditions.checkNotNull(attributes, "base"); return new Builder(); } public static Builder newBuilder() { return new Builder(); } public final Builder toBuilder() { return new Builder(); } /* loaded from: classes6.dex */ public static final class Key { private final String debugString; private Key(String str) { this.debugString = str; } @Deprecated public static Key of(String str) { return new Key<>(str); } public static Key create(String str) { return new Key<>(str); } public final String toString() { return this.debugString; } } public final String toString() { return this.data.toString(); } public final boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } Attributes attributes = (Attributes) obj; if (this.data.size() != attributes.data.size()) { return false; } for (Map.Entry, Object> entry : this.data.entrySet()) { if (!attributes.data.containsKey(entry.getKey()) || !Objects.equal(entry.getValue(), attributes.data.get(entry.getKey()))) { return false; } } return true; } public final int hashCode() { int i = 0; for (Map.Entry, Object> entry : this.data.entrySet()) { i += Objects.hashCode(entry.getKey(), entry.getValue()); } return i; } /* loaded from: classes6.dex */ public static final class Builder { static final boolean $assertionsDisabled = false; private Attributes base; private Map, Object> newdata; private Builder(Attributes attributes) { this.base = attributes; } private Map, Object> data(int i) { if (this.newdata == null) { this.newdata = new IdentityHashMap(i); } return this.newdata; } /* JADX WARN: Multi-variable type inference failed */ public final Builder set(Key key, T t) { data(1).put(key, t); return this; } public final Builder discard(Key key) { if (this.base.data.containsKey(key)) { IdentityHashMap identityHashMap = new IdentityHashMap(this.base.data); identityHashMap.remove(key); this.base = new Attributes(identityHashMap); } Map, Object> map = this.newdata; if (map != null) { map.remove(key); } return this; } public final Builder setAll(Attributes attributes) { data(attributes.data.size()).putAll(attributes.data); return this; } public final Attributes build() { if (this.newdata != null) { for (Map.Entry entry : this.base.data.entrySet()) { if (!this.newdata.containsKey(entry.getKey())) { this.newdata.put((Key) entry.getKey(), entry.getValue()); } } this.base = new Attributes(this.newdata); this.newdata = null; } return this.base; } } }