Skip to content
This repository was archived by the owner on Dec 22, 2019. It is now read-only.

Commit b2a65d5

Browse files
committed
Ignore underscores when matching enums
1 parent cc66d75 commit b2a65d5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/com/therandomlabs/randomlib/config/TRLProperty.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,13 @@ Property deserialize(Configuration config) throws IllegalAccessException {
487487
return property;
488488
}
489489

490+
//Ignore underscores when matching enums
491+
//Hopefully this will never cause issues
490492
if(!isArray) {
493+
final String value = StringUtils.remove(property.getString(), '_');
494+
491495
for(Enum element : enumConstants) {
492-
if(element.name().equalsIgnoreCase(property.getString())) {
496+
if(StringUtils.remove(element.name(), '_').equalsIgnoreCase(value)) {
493497
field.set(null, element);
494498
return property;
495499
}
@@ -503,8 +507,10 @@ Property deserialize(Configuration config) throws IllegalAccessException {
503507
final List<Object> enumValues = new ArrayList<>(values.length);
504508

505509
for(String value : values) {
510+
value = StringUtils.remove(value, '_');
511+
506512
for(Enum element : enumConstants) {
507-
if(element.name().equalsIgnoreCase(value)) {
513+
if(StringUtils.remove(element.name(), '_').equalsIgnoreCase(value)) {
508514
enumValues.add(element);
509515
break;
510516
}

0 commit comments

Comments
 (0)