allow conversion of missing config types

This commit is contained in:
Jonathan Shook
2022-12-20 20:01:33 -06:00
parent 1321923229
commit ba42bfea47

View File

@@ -131,10 +131,20 @@ public class ConfigModel implements NBConfigModel {
return (T) Double.valueOf(string);
} else if (type == BigDecimal.class) {
return (T) BigDecimal.valueOf(Double.parseDouble(string));
} else if (type == boolean.class || type == Boolean.class) {
return (T) Boolean.valueOf(Boolean.parseBoolean(string));
} else {
throw new RuntimeException("CharSequence type " + type.getSimpleName() + " could " +
" not be converted from " + value.getClass().getSimpleName());
}
} else if (value instanceof Boolean bool) {
if (type == boolean.class) {
return (T) bool;
} else {
throw new RuntimeException("Boolean type " + type.getSimpleName() + " could " +
" not be converted from " + value.getClass().getSimpleName());
}
}
} catch (Exception e) {
@@ -318,11 +328,10 @@ public class ConfigModel implements NBConfigModel {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[").append(
params.stream().map(p -> p.getNames().get(0)).collect(Collectors.joining(",")))
.append("]");
String sb = "[" +
params.stream().map(p -> p.getNames().get(0)).collect(Collectors.joining(",")) +
"]";
return sb.toString();
return sb;
}
}