diff --git a/src/main/java/de/assecutor/tasklisteditor/model/BlockTypeRegistry.java b/src/main/java/de/assecutor/tasklisteditor/model/BlockTypeRegistry.java index 42f5c73..d738290 100644 --- a/src/main/java/de/assecutor/tasklisteditor/model/BlockTypeRegistry.java +++ b/src/main/java/de/assecutor/tasklisteditor/model/BlockTypeRegistry.java @@ -307,7 +307,7 @@ public class BlockTypeRegistry { public synchronized int nextCustomTaskType(Collection reserved) { var occupied = new HashSet<>(reserved); types.values().forEach(type -> occupied.add(type.taskType())); - int highest = occupied.stream().mapToInt(Integer::intValue).max().orElse(CUSTOM_TYPE_START - 1); + int highest = occupied.stream().mapToInt(value -> value.intValue()).max().orElse(CUSTOM_TYPE_START - 1); int next = highest < Integer.MAX_VALUE - 1 ? Math.max(CUSTOM_TYPE_START, highest + 1) : CUSTOM_TYPE_START; while (occupied.contains(next)) next++; return next; diff --git a/src/main/java/de/assecutor/tasklisteditor/service/CustomTypeValidator.java b/src/main/java/de/assecutor/tasklisteditor/service/CustomTypeValidator.java index 1337de3..f72edf7 100644 --- a/src/main/java/de/assecutor/tasklisteditor/service/CustomTypeValidator.java +++ b/src/main/java/de/assecutor/tasklisteditor/service/CustomTypeValidator.java @@ -48,7 +48,9 @@ public final class CustomTypeValidator { } private static void validateProperties(JsonNode properties, BlockType base) { - require(properties != null && properties.isArray(), "properties must be an array"); + if (properties == null || !properties.isArray()) { + throw new IllegalArgumentException("properties must be an array"); + } require(properties.size() == base.properties().size(), "Properties must match the base type"); Set ids = new HashSet<>(); for (JsonNode property : properties) { @@ -65,7 +67,9 @@ public final class CustomTypeValidator { } private static void validateDefault(JsonNode value, PropertyType type) { - require(value != null, "defaultValue is required"); + if (value == null) { + throw new IllegalArgumentException("defaultValue is required"); + } // Leere Vorgaben sind erlaubt; die Eingabefelder behandeln sie wie einen leeren Wert. if (value.isNull()) { return; @@ -100,15 +104,17 @@ public final class CustomTypeValidator { private static String text(JsonNode object, String field, boolean allowBlank) { JsonNode value = object.get(field); - require(value != null && value.isTextual() && (allowBlank || !value.textValue().isBlank()), - field + " must be a string" + (allowBlank ? "" : " and not blank")); + if (value == null || !value.isTextual() || (!allowBlank && value.textValue().isBlank())) { + throw new IllegalArgumentException(field + " must be a string" + (allowBlank ? "" : " and not blank")); + } return value.textValue(); } private static int integer(JsonNode object, String field) { JsonNode value = object.get(field); - require(value != null && value.isIntegralNumber() && value.canConvertToInt(), - field + " must be an integer"); + if (value == null || !value.isIntegralNumber() || !value.canConvertToInt()) { + throw new IllegalArgumentException(field + " must be an integer"); + } return value.intValue(); }