Skip to content

Commit

Permalink
Some fixes and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipseisoffline committed Jan 19, 2025
1 parent 0ae556c commit 3fff601
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ public static <T> void readIfPresent(JsonElement node, String name, Consumer<T>
}
}

// TODO don't use this method but throw an error in the above reading methods
public static void requireObject(JsonNode node, String task, String... context) throws InvalidCustomMappingsFileException {
if (node == null || !node.isObject()) {
throw new InvalidCustomMappingsFileException(task, "expected an object", context);
}
}

private static JsonElement getJsonElement(JsonElement element, String name, String... context) throws InvalidCustomMappingsFileException {
if (!element.isJsonObject()) {
throw new InvalidCustomMappingsFileException(formatTask(name), OBJECT_ERROR, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
public interface NodeReader<T> {

NodeReader<Integer> INT = node -> {
if (node.getAsNumber() instanceof Integer i) {
return i;
double i = node.getAsDouble();
if (i == (int) i) { // Make sure the number is round
return (int) i;
}
throw new InvalidCustomMappingsFileException("expected node to be an integer");
};
Expand Down

0 comments on commit 3fff601

Please sign in to comment.