mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 01:22:33 -06:00
74 lines
2.7 KiB
Java
74 lines
2.7 KiB
Java
package com.google.gson;
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.util.Locale;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public enum FieldNamingPolicy implements FieldNamingStrategy {
|
|
IDENTITY { // from class: com.google.gson.FieldNamingPolicy.1
|
|
@Override // com.google.gson.FieldNamingStrategy
|
|
public String translateName(Field field) {
|
|
return field.getName();
|
|
}
|
|
},
|
|
UPPER_CAMEL_CASE { // from class: com.google.gson.FieldNamingPolicy.2
|
|
@Override // com.google.gson.FieldNamingStrategy
|
|
public String translateName(Field field) {
|
|
return upperCaseFirstLetter(field.getName());
|
|
}
|
|
},
|
|
UPPER_CAMEL_CASE_WITH_SPACES { // from class: com.google.gson.FieldNamingPolicy.3
|
|
@Override // com.google.gson.FieldNamingStrategy
|
|
public String translateName(Field field) {
|
|
return upperCaseFirstLetter(separateCamelCase(field.getName(), " "));
|
|
}
|
|
},
|
|
LOWER_CASE_WITH_UNDERSCORES { // from class: com.google.gson.FieldNamingPolicy.4
|
|
@Override // com.google.gson.FieldNamingStrategy
|
|
public String translateName(Field field) {
|
|
return separateCamelCase(field.getName(), "_").toLowerCase(Locale.ENGLISH);
|
|
}
|
|
},
|
|
LOWER_CASE_WITH_DASHES { // from class: com.google.gson.FieldNamingPolicy.5
|
|
@Override // com.google.gson.FieldNamingStrategy
|
|
public String translateName(Field field) {
|
|
return separateCamelCase(field.getName(), "-").toLowerCase(Locale.ENGLISH);
|
|
}
|
|
},
|
|
LOWER_CASE_WITH_DOTS { // from class: com.google.gson.FieldNamingPolicy.6
|
|
@Override // com.google.gson.FieldNamingStrategy
|
|
public String translateName(Field field) {
|
|
return separateCamelCase(field.getName(), ".").toLowerCase(Locale.ENGLISH);
|
|
}
|
|
};
|
|
|
|
static String separateCamelCase(String str, String str2) {
|
|
StringBuilder sb = new StringBuilder();
|
|
int length = str.length();
|
|
for (int i = 0; i < length; i++) {
|
|
char charAt = str.charAt(i);
|
|
if (Character.isUpperCase(charAt) && sb.length() != 0) {
|
|
sb.append(str2);
|
|
}
|
|
sb.append(charAt);
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
static String upperCaseFirstLetter(String str) {
|
|
int length = str.length() - 1;
|
|
int i = 0;
|
|
while (!Character.isLetter(str.charAt(i)) && i < length) {
|
|
i++;
|
|
}
|
|
char charAt = str.charAt(i);
|
|
if (Character.isUpperCase(charAt)) {
|
|
return str;
|
|
}
|
|
char upperCase = Character.toUpperCase(charAt);
|
|
if (i == 0) {
|
|
return upperCase + str.substring(1);
|
|
}
|
|
return str.substring(0, i) + upperCase + str.substring(i + 1);
|
|
}
|
|
}
|