Skip to content

Commit

Permalink
introduced ScalarType#STRING_PRESERVE_NULLS
Browse files Browse the repository at this point in the history
  • Loading branch information
BlvckBytes committed Oct 12, 2024
1 parent 0e58e3e commit cee8efa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/me/blvckbytes/bbconfigmapper/ScalarType.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public class ScalarType<T> {
public static final ScalarType<Double> DOUBLE = new ScalarType<>(double.class, (i, e) -> e.getValueInterpreter().asDouble(i));
public static final ScalarType<Boolean> BOOLEAN = new ScalarType<>(boolean.class, (i, e) -> e.getValueInterpreter().asBoolean(i));
public static final ScalarType<String> STRING = new ScalarType<>(String.class, (i, e) -> e.getValueInterpreter().asString(i));
public static final ScalarType<String> STRING_PRESERVE_NULLS = new ScalarType<>(String.class, (i, e) -> {
if (i == null)
return null;

return e.getValueInterpreter().asString(i);
});

private final Class<?> type;
private final BiFunction<@Nullable Object, IEvaluationEnvironment, Object> interpreter;
Expand Down

0 comments on commit cee8efa

Please sign in to comment.