package io.grpc; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; /* loaded from: classes6.dex */ public final class ServiceDescriptor { private final Collection> methods; private final String name; private final Object schemaDescriptor; public ServiceDescriptor(String str, MethodDescriptor... methodDescriptorArr) { this(str, Arrays.asList(methodDescriptorArr)); } public ServiceDescriptor(String str, Collection> collection) { this(newBuilder(str).addAllMethods((Collection) Preconditions.checkNotNull(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; } static void validateMethodNames(String str, Collection> collection) { HashSet hashSet = new HashSet(collection.size()); for (MethodDescriptor methodDescriptor : collection) { Preconditions.checkNotNull(methodDescriptor, "method"); String serviceName = methodDescriptor.getServiceName(); Preconditions.checkArgument(str.equals(serviceName), "service names %s != %s", serviceName, str); Preconditions.checkArgument(hashSet.add(methodDescriptor.getFullMethodName()), "duplicate name %s", methodDescriptor.getFullMethodName()); } } public static Builder newBuilder(String str) { return new Builder(str); } /* loaded from: classes6.dex */ public static final class Builder { private List> methods; private String name; private Object schemaDescriptor; private Builder(String str) { this.methods = new ArrayList(); setName(str); } public final Builder setName(String str) { this.name = (String) Preconditions.checkNotNull(str, "name"); return this; } public final Builder addMethod(MethodDescriptor methodDescriptor) { this.methods.add((MethodDescriptor) Preconditions.checkNotNull(methodDescriptor, "method")); return this; } /* JADX INFO: Access modifiers changed from: private */ public Builder addAllMethods(Collection> collection) { this.methods.addAll(collection); return this; } public final ServiceDescriptor build() { return new ServiceDescriptor(this); } public final Builder setSchemaDescriptor(Object obj) { this.schemaDescriptor = obj; return this; } } public final String toString() { return MoreObjects.toStringHelper(this).add("name", this.name).add("schemaDescriptor", this.schemaDescriptor).add("methods", this.methods).omitNullValues().toString(); } public final Object getSchemaDescriptor() { return this.schemaDescriptor; } public final String getName() { return this.name; } public final Collection> getMethods() { return this.methods; } }