Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
public enum ConfigMode {
DEFAULT,
PATH_BY_UNDERSCORE,
PATH_BY_CAMEL_CASE,
FIELD_IS_KEY
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ private void internalSave(Class clazz) throws InvalidConfigurationException {
case FIELD_IS_KEY:
path = field.getName();
break;
case PATH_BY_CAMEL_CASE:
path = getCamelCasePath(field.getName());
break;
case DEFAULT:
default:
String fieldName = field.getName();
Expand Down Expand Up @@ -214,4 +217,26 @@ public void load(File file) throws InvalidConfigurationException {
CONFIG_FILE = file;
load();
}

/**
* Converts the name of a field to a YAML Path, e.g. databaseUsername --> database.Username
* by GitGraf
* @param fieldName The name of the field that needs to be converted
* @return A dot seperated yaml path
*/
private String getCamelCasePath(String fieldName)
{
StringBuffer pathBuffer = new StringBuffer();
char[] fieldArray = fieldName.toCharArray();
for(int i = 0; i < fieldArray.length; i++) {

if(Character.isUpperCase(fieldArray[i])) {
pathBuffer.append(".");
}

pathBuffer.append(fieldArray[i]);

}
return pathBuffer.toString();
}
}