59 lines
2.6 KiB
Java
59 lines
2.6 KiB
Java
package lombok.core.handlers;
|
|
|
|
import com.adjust.sdk.Constants;
|
|
import java.io.BufferedReader;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
/* loaded from: com.discord-120109.apk:lombok/core/handlers/Singulars.SCL.lombok */
|
|
public class Singulars {
|
|
private static final List<String> SINGULAR_STORE = new ArrayList();
|
|
|
|
static {
|
|
try {
|
|
InputStream resourceAsStream = Singulars.class.getResourceAsStream("singulars.txt");
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resourceAsStream, Constants.ENCODING));
|
|
for (String readLine = bufferedReader.readLine(); readLine != null; readLine = bufferedReader.readLine()) {
|
|
String trim = readLine.trim();
|
|
if (!trim.startsWith("#") && !trim.isEmpty()) {
|
|
if (trim.endsWith(" =")) {
|
|
SINGULAR_STORE.add(trim.substring(0, trim.length() - 2));
|
|
SINGULAR_STORE.add("");
|
|
} else {
|
|
int indexOf = trim.indexOf(" = ");
|
|
SINGULAR_STORE.add(trim.substring(0, indexOf));
|
|
SINGULAR_STORE.add(trim.substring(indexOf + 3));
|
|
}
|
|
}
|
|
}
|
|
try {
|
|
resourceAsStream.close();
|
|
} catch (Throwable unused) {
|
|
}
|
|
} catch (IOException unused2) {
|
|
SINGULAR_STORE.clear();
|
|
}
|
|
}
|
|
|
|
public static String autoSingularize(String str) {
|
|
int length = str.length();
|
|
for (int i = 0; i < SINGULAR_STORE.size(); i += 2) {
|
|
String str2 = SINGULAR_STORE.get(i);
|
|
boolean isUpperCase = Character.isUpperCase(str2.charAt(0));
|
|
int i2 = str2.charAt(0) == '-' ? 1 : 0;
|
|
int length2 = str2.length();
|
|
if (length >= length2 && str.regionMatches(true, (length - length2) + i2, str2, i2, length2 - i2) && (!isUpperCase || length == length2 || Character.isUpperCase(str.charAt(length - length2)))) {
|
|
String str3 = SINGULAR_STORE.get(i + 1);
|
|
if (str3.equals("!")) {
|
|
return null;
|
|
}
|
|
boolean z2 = !str3.isEmpty() && Character.isUpperCase(str.charAt((length - length2) + i2));
|
|
return String.valueOf(str.substring(0, (length - length2) + i2)) + (z2 ? String.valueOf(Character.toUpperCase(str3.charAt(0))) + str3.substring(1) : str3);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|