package lombok.core.configuration; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; /* loaded from: com.discord-120110.apk:lombok/core/configuration/NullAnnotationLibrary.SCL.lombok */ public final class NullAnnotationLibrary implements ConfigurationValueType { private final String key; private final String nonNullAnnotation; private final String nullableAnnotation; private final boolean typeUse; public static final NullAnnotationLibrary NONE = new NullAnnotationLibrary("none", null, null, false); public static final NullAnnotationLibrary JAVAX = new NullAnnotationLibrary("javax", "javax.annotation.Nonnull", "javax.annotation.Nullable", false); public static final NullAnnotationLibrary ECLIPSE = new NullAnnotationLibrary("eclipse", "org.eclipse.jdt.annotation.NonNull", "org.eclipse.jdt.annotation.Nullable", true); public static final NullAnnotationLibrary JETBRAINS = new NullAnnotationLibrary("jetbrains", "org.jetbrains.annotations.NotNull", "org.jetbrains.annotations.Nullable", false); public static final NullAnnotationLibrary NETBEANS = new NullAnnotationLibrary("netbeans", "org.netbeans.api.annotations.common.NonNull", "org.netbeans.api.annotations.common.NullAllowed", false); public static final NullAnnotationLibrary ANDROIDX = new NullAnnotationLibrary("androidx", "androidx.annotation.NonNull", "androidx.annotation.Nullable", false); public static final NullAnnotationLibrary ANDROID_SUPPORT = new NullAnnotationLibrary("android.support", "android.support.annotation.NonNull", "android.support.annotation.Nullable", false); public static final NullAnnotationLibrary CHECKERFRAMEWORK = new NullAnnotationLibrary("checkerframework", "org.checkerframework.checker.nullness.qual.NonNull", "org.checkerframework.checker.nullness.qual.Nullable", true); public static final NullAnnotationLibrary FINDBUGS = new NullAnnotationLibrary("findbugs", "edu.umd.cs.findbugs.annotations.NonNull", "edu.umd.cs.findbugs.annotations.Nullable", false); public static final NullAnnotationLibrary SPRING = new NullAnnotationLibrary("spring", "org.springframework.lang.NonNull", "org.springframework.lang.Nullable", false); public static final NullAnnotationLibrary JML = new NullAnnotationLibrary("jml", "org.jmlspecs.annotation.NonNull", "org.jmlspecs.annotation.Nullable", false); private static final List ALL_AVAILABLE; private static final String EXAMPLE_VALUE; private static final String MSG = "Not an identifier (provide a fully qualified type for custom: nullity annotations): "; static { Field[] declaredFields; ArrayList arrayList = new ArrayList(); StringBuilder sb = new StringBuilder(); for (Field field : NullAnnotationLibrary.class.getDeclaredFields()) { if (field.getType() == NullAnnotationLibrary.class && Modifier.isStatic(field.getModifiers()) && Modifier.isPublic(field.getModifiers())) { try { NullAnnotationLibrary nullAnnotationLibrary = (NullAnnotationLibrary) field.get(null); arrayList.add(nullAnnotationLibrary); sb.append(nullAnnotationLibrary.key).append(" | "); } catch (IllegalAccessException unused) { } } } arrayList.trimToSize(); sb.append("CUSTOM:com.foo.my.nonnull.annotation:com.foo.my.nullable.annotation"); ALL_AVAILABLE = Collections.unmodifiableList(arrayList); EXAMPLE_VALUE = sb.toString(); } private NullAnnotationLibrary(String str, String str2, String str3, boolean z2) { this.key = str; this.nonNullAnnotation = str2; this.nullableAnnotation = str3; this.typeUse = z2; } public String getNonNullAnnotation() { return this.nonNullAnnotation; } public String getNullableAnnotation() { return this.nullableAnnotation; } public boolean isTypeUse() { return this.typeUse; } public static NullAnnotationLibrary custom(String str, String str2, boolean z2) { if (str == null && str2 == null) { return NONE; } String str3 = z2 ? "TYPE_USE:" : ""; return str2 == null ? new NullAnnotationLibrary("custom:" + str3 + str, str, null, z2) : str == null ? new NullAnnotationLibrary("custom::" + str3 + str2, null, str2, z2) : new NullAnnotationLibrary("custom:" + str3 + str + ":" + str2, str, str2, z2); } public static String description() { return "nullity-annotation-library"; } public static String exampleValue() { return EXAMPLE_VALUE; } public static NullAnnotationLibrary valueOf(String str) { String lowerCase = str == null ? "" : str.toLowerCase(); if (lowerCase.length() == 0) { return NONE; } Iterator it = ALL_AVAILABLE.iterator(); while (it.hasNext()) { NullAnnotationLibrary next = it.next(); if (next.key.equals(lowerCase)) { return next; } } if (!lowerCase.startsWith("custom:")) { StringBuilder sb = new StringBuilder("Invalid null annotation library. Valid options: "); Iterator it2 = ALL_AVAILABLE.iterator(); while (it2.hasNext()) { sb.append(it2.next().key).append(", "); } sb.setLength(sb.length() - 2); sb.append(" or CUSTOM:[TYPE_USE:]nonnull.annotation.type:nullable.annotation.type"); throw new IllegalArgumentException(sb.toString()); } boolean startsWith = lowerCase.startsWith("custom:type_use:"); int i = startsWith ? 16 : 7; int indexOf = lowerCase.indexOf(58, i); if (indexOf == -1) { return custom(verifyTypeName(str.substring(i)), null, startsWith); } return custom(verifyTypeName(str.substring(i, indexOf)), verifyTypeName(str.substring(indexOf + 1)), startsWith); } private static String verifyTypeName(String str) { boolean z2 = true; for (int i = 0; i < str.length(); i++) { char charAt = str.charAt(i); if (Character.isJavaIdentifierStart(charAt)) { z2 = false; } else if (z2) { throw new IllegalArgumentException(MSG + str); } else if (charAt == '.') { z2 = true; } else if (!Character.isJavaIdentifierPart(charAt)) { throw new IllegalArgumentException(MSG + str); } } if (!z2) { return str; } throw new IllegalArgumentException(MSG + str); } }