what-the-bank/sources/com/google/common/base/CaseFormat.java

221 lines
9.1 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.base;
import java.io.Serializable;
import org.bouncycastle.pqc.math.linearalgebra.Matrix;
/* JADX WARN: Enum visitor error
jadx.core.utils.exceptions.JadxRuntimeException: Init of enum field 'LOWER_UNDERSCORE' uses external variables
at jadx.core.dex.visitors.EnumVisitor.createEnumFieldByConstructor(EnumVisitor.java:451)
at jadx.core.dex.visitors.EnumVisitor.processEnumFieldByField(EnumVisitor.java:372)
at jadx.core.dex.visitors.EnumVisitor.processEnumFieldByWrappedInsn(EnumVisitor.java:337)
at jadx.core.dex.visitors.EnumVisitor.extractEnumFieldsFromFilledArray(EnumVisitor.java:322)
at jadx.core.dex.visitors.EnumVisitor.extractEnumFieldsFromInsn(EnumVisitor.java:262)
at jadx.core.dex.visitors.EnumVisitor.extractEnumFieldsFromInvoke(EnumVisitor.java:293)
at jadx.core.dex.visitors.EnumVisitor.extractEnumFieldsFromInsn(EnumVisitor.java:266)
at jadx.core.dex.visitors.EnumVisitor.convertToEnum(EnumVisitor.java:151)
at jadx.core.dex.visitors.EnumVisitor.visit(EnumVisitor.java:100)
*/
/* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
/* loaded from: classes2.dex */
public abstract class CaseFormat {
public static final CaseFormat LOWER_CAMEL;
public static final CaseFormat LOWER_UNDERSCORE;
public static final CaseFormat UPPER_CAMEL;
public static final CaseFormat UPPER_UNDERSCORE;
private final CharMatcher wordBoundary;
private final String wordSeparator;
public static final CaseFormat LOWER_HYPHEN = new CaseFormat("LOWER_HYPHEN", 0, CharMatcher.is('-'), "-") { // from class: com.google.common.base.CaseFormat.1
@Override // com.google.common.base.CaseFormat
final String normalizeWord(String str) {
return Ascii.toLowerCase(str);
}
@Override // com.google.common.base.CaseFormat
final String convert(CaseFormat caseFormat, String str) {
if (caseFormat == LOWER_UNDERSCORE) {
return str.replace('-', '_');
}
if (caseFormat == UPPER_UNDERSCORE) {
return Ascii.toUpperCase(str.replace('-', '_'));
}
return super.convert(caseFormat, str);
}
};
private static final CaseFormat[] $VALUES = $values();
abstract String normalizeWord(String str);
public static CaseFormat valueOf(String str) {
return (CaseFormat) Enum.valueOf(CaseFormat.class, str);
}
public static CaseFormat[] values() {
return (CaseFormat[]) $VALUES.clone();
}
static {
String str = "_";
LOWER_UNDERSCORE = new CaseFormat("LOWER_UNDERSCORE", 1, CharMatcher.is('_'), str) { // from class: com.google.common.base.CaseFormat.2
@Override // com.google.common.base.CaseFormat
final String normalizeWord(String str2) {
return Ascii.toLowerCase(str2);
}
@Override // com.google.common.base.CaseFormat
final String convert(CaseFormat caseFormat, String str2) {
if (caseFormat == LOWER_HYPHEN) {
return str2.replace('_', '-');
}
if (caseFormat == UPPER_UNDERSCORE) {
return Ascii.toUpperCase(str2);
}
return super.convert(caseFormat, str2);
}
};
String str2 = "";
LOWER_CAMEL = new CaseFormat("LOWER_CAMEL", 2, CharMatcher.inRange('A', Matrix.MATRIX_TYPE_ZERO), str2) { // from class: com.google.common.base.CaseFormat.3
@Override // com.google.common.base.CaseFormat
final String normalizeWord(String str3) {
return CaseFormat.firstCharOnlyToUpper(str3);
}
@Override // com.google.common.base.CaseFormat
final String normalizeFirstWord(String str3) {
return Ascii.toLowerCase(str3);
}
};
UPPER_CAMEL = new CaseFormat("UPPER_CAMEL", 3, CharMatcher.inRange('A', Matrix.MATRIX_TYPE_ZERO), str2) { // from class: com.google.common.base.CaseFormat.4
@Override // com.google.common.base.CaseFormat
final String normalizeWord(String str3) {
return CaseFormat.firstCharOnlyToUpper(str3);
}
};
UPPER_UNDERSCORE = new CaseFormat("UPPER_UNDERSCORE", 4, CharMatcher.is('_'), str) { // from class: com.google.common.base.CaseFormat.5
@Override // com.google.common.base.CaseFormat
final String normalizeWord(String str3) {
return Ascii.toUpperCase(str3);
}
@Override // com.google.common.base.CaseFormat
final String convert(CaseFormat caseFormat, String str3) {
if (caseFormat == LOWER_HYPHEN) {
return Ascii.toLowerCase(str3.replace('_', '-'));
}
if (caseFormat == LOWER_UNDERSCORE) {
return Ascii.toLowerCase(str3);
}
return super.convert(caseFormat, str3);
}
};
}
private CaseFormat(String str, int i, CharMatcher charMatcher, String str2) {
this.wordBoundary = charMatcher;
this.wordSeparator = str2;
}
public final String to(CaseFormat caseFormat, String str) {
Preconditions.checkNotNull(caseFormat);
Preconditions.checkNotNull(str);
return caseFormat != this ? convert(caseFormat, str) : str;
}
String convert(CaseFormat caseFormat, String str) {
StringBuilder sb = null;
int i = 0;
int i2 = -1;
while (true) {
i2 = this.wordBoundary.indexIn(str, i2 + 1);
if (i2 == -1) {
break;
}
if (i == 0) {
sb = new StringBuilder(str.length() + (caseFormat.wordSeparator.length() << 2));
sb.append(caseFormat.normalizeFirstWord(str.substring(i, i2)));
} else {
sb.append(caseFormat.normalizeWord(str.substring(i, i2)));
}
sb.append(caseFormat.wordSeparator);
i = this.wordSeparator.length() + i2;
}
if (i == 0) {
return caseFormat.normalizeFirstWord(str);
}
sb.append(caseFormat.normalizeWord(str.substring(i)));
return sb.toString();
}
public Converter<String, String> converterTo(CaseFormat caseFormat) {
return new StringConverter(this, caseFormat);
}
/* loaded from: classes2.dex */
static final class StringConverter extends Converter<String, String> implements Serializable {
private static final long serialVersionUID = 0;
private final CaseFormat sourceFormat;
private final CaseFormat targetFormat;
StringConverter(CaseFormat caseFormat, CaseFormat caseFormat2) {
this.sourceFormat = (CaseFormat) Preconditions.checkNotNull(caseFormat);
this.targetFormat = (CaseFormat) Preconditions.checkNotNull(caseFormat2);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.base.Converter
public final String doForward(String str) {
return this.sourceFormat.to(this.targetFormat, str);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.base.Converter
public final String doBackward(String str) {
return this.targetFormat.to(this.sourceFormat, str);
}
@Override // com.google.common.base.Converter, com.google.common.base.Function
public final boolean equals(Object obj) {
if (!(obj instanceof StringConverter)) {
return false;
}
StringConverter stringConverter = (StringConverter) obj;
return this.sourceFormat.equals(stringConverter.sourceFormat) && this.targetFormat.equals(stringConverter.targetFormat);
}
public final int hashCode() {
return this.sourceFormat.hashCode() ^ this.targetFormat.hashCode();
}
public final String toString() {
String valueOf = String.valueOf(this.sourceFormat);
String valueOf2 = String.valueOf(this.targetFormat);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 14 + String.valueOf(valueOf2).length());
sb.append(valueOf);
sb.append(".converterTo(");
sb.append(valueOf2);
sb.append(")");
return sb.toString();
}
}
String normalizeFirstWord(String str) {
return normalizeWord(str);
}
/* JADX INFO: Access modifiers changed from: private */
public static String firstCharOnlyToUpper(String str) {
if (str.isEmpty()) {
return str;
}
char upperCase = Ascii.toUpperCase(str.charAt(0));
String lowerCase = Ascii.toLowerCase(str.substring(1));
StringBuilder sb = new StringBuilder(String.valueOf(lowerCase).length() + 1);
sb.append(upperCase);
sb.append(lowerCase);
return sb.toString();
}
private static /* synthetic */ CaseFormat[] $values() {
return new CaseFormat[]{LOWER_HYPHEN, LOWER_UNDERSCORE, LOWER_CAMEL, UPPER_CAMEL, UPPER_UNDERSCORE};
}
}