导航菜单

页面标题

页面副标题

SpeedCash v6.5.1482 - Attributes.java 源代码

正在查看: SpeedCash v6.5.1482 应用的 Attributes.java JAVA 源代码文件

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


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;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1764")
@Immutable
public final class Attributes {
    public static final Attributes EMPTY;
    public static final IdentityHashMap<Key<?>, Object> b;
    public final IdentityHashMap<Key<?>, Object> a;

    public static final class Builder {
        public Attributes a;
        public IdentityHashMap<Key<?>, Object> b;

        public final IdentityHashMap<Key<?>, Object> a(int i) {
            if (this.b == null) {
                this.b = new IdentityHashMap<>(i);
            }
            return this.b;
        }

        public Attributes build() {
            if (this.b != null) {
                for (Map.Entry entry : this.a.a.entrySet()) {
                    if (!this.b.containsKey(entry.getKey())) {
                        this.b.put((Key) entry.getKey(), entry.getValue());
                    }
                }
                this.a = new Attributes(this.b);
                this.b = null;
            }
            return this.a;
        }

        @ExperimentalApi("https://github.com/grpc/grpc-java/issues/5777")
        public <T> Builder discard(Key<T> key) {
            if (this.a.a.containsKey(key)) {
                IdentityHashMap identityHashMap = new IdentityHashMap(this.a.a);
                identityHashMap.remove(key);
                this.a = new Attributes(identityHashMap);
            }
            IdentityHashMap<Key<?>, Object> identityHashMap2 = this.b;
            if (identityHashMap2 != null) {
                identityHashMap2.remove(key);
            }
            return this;
        }

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

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

        public Builder(Attributes attributes) {
            this.a = attributes;
        }
    }

    @Immutable
    public static final class Key<T> {
        public final String a;

        public Key(String str) {
            this.a = 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.a;
        }
    }

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

    @Deprecated
    public static Builder newBuilder(Attributes attributes) {
        Preconditions.checkNotNull(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.a.size() != attributes.a.size()) {
            return false;
        }
        for (Map.Entry<Key<?>, Object> entry : this.a.entrySet()) {
            if (!attributes.a.containsKey(entry.getKey()) || !Objects.equal(entry.getValue(), attributes.a.get(entry.getKey()))) {
                return false;
            }
        }
        return true;
    }

    @Nullable
    public <T> T get(Key<T> key) {
        return (T) this.a.get(key);
    }

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

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

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

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

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

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