package lombok.core; import com.discord.models.domain.ModelAuditLogEntry; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /* loaded from: com.discord-118107.apk:lombok/core/TypeLibrary.SCL.lombok */ public class TypeLibrary { private final Map unqualifiedToQualifiedMap; private final String unqualified; private final String qualified; private boolean locked; public TypeLibrary() { this.unqualifiedToQualifiedMap = new HashMap(); this.unqualified = null; this.qualified = null; } public TypeLibrary(TypeLibrary typeLibrary) { this.unqualifiedToQualifiedMap = new HashMap(); this.unqualified = null; this.qualified = null; } public void lock() { this.locked = true; } private TypeLibrary(String str) { if (str.indexOf("$") != -1) { this.unqualifiedToQualifiedMap = new HashMap(); this.unqualified = null; this.qualified = null; addType(str); } else { this.unqualifiedToQualifiedMap = null; this.qualified = str; int lastIndexOf = str.lastIndexOf(46); if (lastIndexOf == -1) { this.unqualified = str; } else { this.unqualified = str.substring(lastIndexOf + 1); } } this.locked = true; } public static TypeLibrary createLibraryForSingleType(String str) { if (!LombokInternalAliasing.REVERSE_ALIASES.containsKey(str)) { return new TypeLibrary(str); } TypeLibrary typeLibrary = new TypeLibrary(); typeLibrary.addType(str); typeLibrary.lock(); return typeLibrary; } public void addType(String str) { Collection collection = LombokInternalAliasing.REVERSE_ALIASES.get(str); if (collection != null) { Iterator it = collection.iterator(); while (it.hasNext()) { addType(it.next()); } } String replace = str.replace("$", "."); if (this.locked) { throw new IllegalStateException(ModelAuditLogEntry.CHANGE_KEY_LOCKED); } int lastIndexOf = str.lastIndexOf(46); if (lastIndexOf == -1) { throw new IllegalArgumentException("Only fully qualified types are allowed (types in the default package cannot be added here either)"); } String substring = str.substring(lastIndexOf + 1); if (this.unqualifiedToQualifiedMap == null) { throw new IllegalStateException("SingleType library"); } put(substring.replace("$", "."), replace); put(substring, replace); put(str, replace); put(replace, replace); int indexOf = str.indexOf(36, lastIndexOf + 1); while (indexOf != -1) { String substring2 = str.substring(indexOf + 1); put(substring2.replace("$", "."), replace); put(substring2, replace); indexOf = str.indexOf(36, indexOf + 1); } } public List toQualifieds(String str) { if (this.unqualifiedToQualifiedMap != null) { Object obj = this.unqualifiedToQualifiedMap.get(str); return obj == null ? Collections.emptyList() : obj instanceof String ? Collections.singletonList((String) obj) : Arrays.asList((String[]) obj); } else if (str.equals(this.unqualified) || str.equals(this.qualified)) { return Collections.singletonList(this.qualified); } else { return null; } } private void put(String str, String str2) { String[] strArr; Object put = this.unqualifiedToQualifiedMap.put(str, str2); if (put != null) { if (!(put instanceof String)) { String[] strArr2 = (String[]) put; strArr = new String[strArr2.length + 1]; System.arraycopy(strArr2, 0, strArr, 0, strArr2.length); strArr[strArr2.length] = str2; } else if (!put.equals(str2)) { strArr = new String[]{(String) put, str2}; } else { return; } this.unqualifiedToQualifiedMap.put(str, strArr); } } }