package io.grpc; import com.airbnb.deeplinkdispatch.UrlTreeKt; import com.google.common.base.Preconditions; import java.util.concurrent.atomic.AtomicLong; /* loaded from: classes6.dex */ public final class InternalLogId { private static final AtomicLong idAlloc = new AtomicLong(); private final String details; private final long id; private final String typeName; public static InternalLogId allocate(Class cls, String str) { return allocate(getClassName(cls), str); } public static InternalLogId allocate(String str, String str2) { return new InternalLogId(str, str2, getNextId()); } static long getNextId() { return idAlloc.incrementAndGet(); } InternalLogId(String str, String str2, long j) { Preconditions.checkNotNull(str, "typeName"); Preconditions.checkArgument(!str.isEmpty(), "empty type"); this.typeName = str; this.details = str2; this.id = j; } public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(shortName()); if (this.details != null) { sb.append(": ("); sb.append(this.details); sb.append(')'); } return sb.toString(); } private static String getClassName(Class cls) { String simpleName = ((Class) Preconditions.checkNotNull(cls, "type")).getSimpleName(); return !simpleName.isEmpty() ? simpleName : cls.getName().substring(cls.getPackage().getName().length() + 1); } public final String shortName() { StringBuilder sb = new StringBuilder(); sb.append(this.typeName); sb.append(UrlTreeKt.configurablePathSegmentPrefix); sb.append(this.id); sb.append(UrlTreeKt.configurablePathSegmentSuffix); return sb.toString(); } public final String getTypeName() { return this.typeName; } public final long getId() { return this.id; } public final String getDetails() { return this.details; } }