导航菜单

页面标题

页面副标题

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

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

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


package io.grpc;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import q.g;
import q.l;

public final class ServiceDescriptor {
    private final Collection<MethodDescriptor<?, ?>> methods;
    private final String name;
    private final Object schemaDescriptor;

    public static final class Builder {
        private List<MethodDescriptor<?, ?>> methods;
        private String name;
        private Object schemaDescriptor;

        public Builder addAllMethods(Collection<MethodDescriptor<?, ?>> collection) {
            this.methods.addAll(collection);
            return this;
        }

        public Builder addMethod(MethodDescriptor<?, ?> methodDescriptor) {
            this.methods.add((MethodDescriptor) l.o(methodDescriptor, "method"));
            return this;
        }

        public ServiceDescriptor build() {
            return new ServiceDescriptor(this);
        }

        @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2666")
        public Builder setName(String str) {
            this.name = (String) l.o(str, "name");
            return this;
        }

        public Builder setSchemaDescriptor(Object obj) {
            this.schemaDescriptor = obj;
            return this;
        }

        private Builder(String str) {
            this.methods = new ArrayList();
            setName(str);
        }
    }

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

    static void validateMethodNames(String str, Collection<MethodDescriptor<?, ?>> collection) {
        HashSet hashSet = new HashSet(collection.size());
        for (MethodDescriptor<?, ?> methodDescriptor : collection) {
            l.o(methodDescriptor, "method");
            String serviceName = methodDescriptor.getServiceName();
            l.k(str.equals(serviceName), "service names %s != %s", serviceName, str);
            l.j(hashSet.add(methodDescriptor.getFullMethodName()), "duplicate name %s", methodDescriptor.getFullMethodName());
        }
    }

    public Collection<MethodDescriptor<?, ?>> getMethods() {
        return this.methods;
    }

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

    @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222")
    public Object getSchemaDescriptor() {
        return this.schemaDescriptor;
    }

    public String toString() {
        return g.c(this).d("name", this.name).d("schemaDescriptor", this.schemaDescriptor).d("methods", this.methods).k().toString();
    }

    public ServiceDescriptor(String str, MethodDescriptor<?, ?>... methodDescriptorArr) {
        this(str, Arrays.asList(methodDescriptorArr));
    }

    public ServiceDescriptor(String str, Collection<MethodDescriptor<?, ?>> collection) {
        this(newBuilder(str).addAllMethods((Collection) l.o(collection, "methods")));
    }

    private ServiceDescriptor(Builder builder) {
        String str = builder.name;
        this.name = str;
        validateMethodNames(str, builder.methods);
        this.methods = Collections.unmodifiableList(new ArrayList(builder.methods));
        this.schemaDescriptor = builder.schemaDescriptor;
    }
}