导航菜单

页面标题

页面副标题

⁣逼‌多​多⁣ v3.6.2 - Attributes.java 源代码

正在查看: ⁣逼‌多​多⁣ v3.6.2 应用的 Attributes.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package io.grpc;

import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
import q.i;
import q.l;

@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1764")
public final class Attributes {
    static final boolean $assertionsDisabled = false;
    public static final Attributes EMPTY;
    private static final IdentityHashMap<Key<?>, Object> EMPTY_MAP;
    private final IdentityHashMap<Key<?>, Object> data;

    public static final class Builder {
        static final boolean $assertionsDisabled = false;
        private Attributes base;
        private IdentityHashMap<Key<?>, Object> newdata;

        private IdentityHashMap<Key<?>, Object> data(int i) {
            if (this.newdata == null) {
                this.newdata = new IdentityHashMap<>(i);
            }
            return this.newdata;
        }

        public 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;
        }

        public <T> Builder discard(Key<T> key) {
            if (this.base.data.containsKey(key)) {
                IdentityHashMap identityHashMap = new IdentityHashMap(this.base.data);
                identityHashMap.remove(key);
                this.base = new Attributes(identityHashMap);
            }
            IdentityHashMap<Key<?>, Object> identityHashMap2 = this.newdata;
            if (identityHashMap2 != null) {
                identityHashMap2.remove(key);
            }
            return this;
        }

        public <T> Builder set(Key<T> key, T t) {
            data(1).put(key, t);
            return this;
        }

        public Builder setAll(Attributes attributes) {
            data(attributes.data.size()).putAll(attributes.data);
            return this;
        }

        private Builder(Attributes attributes) {
            this.base = attributes;
        }
    }

    public static final class Key<T> {
        private final String debugString;

        private Key(String str) {
            this.debugString = str;
        }

        public static <T> Key<T> create(String str) {
            return new Key<>(str);
        }

        @Deprecated
        public static <T> Key<T> of(String str) {
            return new Key<>(str);
        }

        public String toString() {
            return this.debugString;
        }
    }

    static {
        IdentityHashMap<Key<?>, Object> identityHashMap = new IdentityHashMap<>();
        EMPTY_MAP = identityHashMap;
        EMPTY = new Attributes(identityHashMap);
    }

    @Deprecated
    public static Builder newBuilder(Attributes attributes) {
        l.o(attributes, "base");
        return new Builder();
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || Attributes.class != obj.getClass()) {
            return false;
        }
        Attributes attributes = (Attributes) obj;
        if (this.data.size() != attributes.data.size()) {
            return false;
        }
        for (Map.Entry<Key<?>, Object> entry : this.data.entrySet()) {
            if (!attributes.data.containsKey(entry.getKey()) || !i.a(entry.getValue(), attributes.data.get(entry.getKey()))) {
                return false;
            }
        }
        return true;
    }

    public <T> T get(Key<T> key) {
        return (T) this.data.get(key);
    }

    public int hashCode() {
        int i = 0;
        for (Map.Entry<Key<?>, Object> entry : this.data.entrySet()) {
            i += i.b(new Object[]{entry.getKey(), entry.getValue()});
        }
        return i;
    }

    @Deprecated
    public Set<Key<?>> keys() {
        return Collections.unmodifiableSet(this.data.keySet());
    }

    Set<Key<?>> keysForTest() {
        return Collections.unmodifiableSet(this.data.keySet());
    }

    public Builder toBuilder() {
        return new Builder();
    }

    public String toString() {
        return this.data.toString();
    }

    private Attributes(IdentityHashMap<Key<?>, Object> identityHashMap) {
        this.data = identityHashMap;
    }

    public static Builder newBuilder() {
        return new Builder();
    }
}