Rabbit-R1/android (non root)/java/sources/com/google/common/base/CaseFormat.java
2024-05-21 17:08:36 -04:00

212 lines
9 KiB
Java

package com.google.common.base;
import java.io.Serializable;
import javax.annotation.CheckForNull;
/* 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 */
@ElementTypesAreNonnullByDefault
/* 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
String normalizeWord(String str) {
return Ascii.toLowerCase(str);
}
@Override // com.google.common.base.CaseFormat
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 /* synthetic */ CaseFormat[] $VALUES = $values();
private static /* synthetic */ CaseFormat[] $values() {
return new CaseFormat[]{LOWER_HYPHEN, LOWER_UNDERSCORE, LOWER_CAMEL, UPPER_CAMEL, UPPER_UNDERSCORE};
}
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
String normalizeWord(String str2) {
return Ascii.toLowerCase(str2);
}
@Override // com.google.common.base.CaseFormat
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', 'Z'), str2) { // from class: com.google.common.base.CaseFormat.3
@Override // com.google.common.base.CaseFormat
String normalizeWord(String str3) {
return CaseFormat.firstCharOnlyToUpper(str3);
}
@Override // com.google.common.base.CaseFormat
String normalizeFirstWord(String str3) {
return Ascii.toLowerCase(str3);
}
};
UPPER_CAMEL = new CaseFormat("UPPER_CAMEL", 3, CharMatcher.inRange('A', 'Z'), str2) { // from class: com.google.common.base.CaseFormat.4
@Override // com.google.common.base.CaseFormat
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
String normalizeWord(String str3) {
return Ascii.toUpperCase(str3);
}
@Override // com.google.common.base.CaseFormat
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 ? str : convert(caseFormat, 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() * 4));
sb.append(caseFormat.normalizeFirstWord(str.substring(i, i2)));
} else {
((StringBuilder) java.util.Objects.requireNonNull(sb)).append(caseFormat.normalizeWord(str.substring(i, i2)));
}
sb.append(caseFormat.wordSeparator);
i = this.wordSeparator.length() + i2;
}
if (i == 0) {
return caseFormat.normalizeFirstWord(str);
}
return ((StringBuilder) java.util.Objects.requireNonNull(sb)).append(caseFormat.normalizeWord(str.substring(i))).toString();
}
public Converter<String, String> converterTo(CaseFormat caseFormat) {
return new StringConverter(this, caseFormat);
}
/* loaded from: classes2.dex */
private 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 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 String doBackward(String str) {
return this.targetFormat.to(this.sourceFormat, str);
}
@Override // com.google.common.base.Converter, com.google.common.base.Function
public boolean equals(@CheckForNull Object obj) {
if (!(obj instanceof StringConverter)) {
return false;
}
StringConverter stringConverter = (StringConverter) obj;
return this.sourceFormat.equals(stringConverter.sourceFormat) && this.targetFormat.equals(stringConverter.targetFormat);
}
public int hashCode() {
return this.targetFormat.hashCode() ^ this.sourceFormat.hashCode();
}
public String toString() {
String valueOf = String.valueOf(this.sourceFormat);
String valueOf2 = String.valueOf(this.targetFormat);
return new StringBuilder(String.valueOf(valueOf).length() + 14 + String.valueOf(valueOf2).length()).append(valueOf).append(".converterTo(").append(valueOf2).append(")").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));
return new StringBuilder(String.valueOf(lowerCase).length() + 1).append(upperCase).append(lowerCase).toString();
}
}