diff --git a/core/pom.xml b/core/pom.xml
index c6008c0f..6e52169e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -38,6 +38,19 @@
+
+ io.github.sebastian-toepfer.common
+ condition4j-api
+
+
+ io.github.sebastian-toepfer.common
+ condition4j-core
+
+
+ io.github.sebastian-toepfer.common
+ condition4j-json-p
+
+
org.junit.jupiter
junit-jupiter-api
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultValidator.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultValidator.java
index 2f7c4c03..2ce19b9d 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultValidator.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/DefaultValidator.java
@@ -23,16 +23,16 @@
*/
package io.github.sebastiantoepfer.jsonschema.core;
+import io.github.sebastiantoepfer.common.condition4j.Fulfilable;
import io.github.sebastiantoepfer.jsonschema.Validator;
-import io.github.sebastiantoepfer.jsonschema.core.codition.Condition;
import jakarta.json.JsonValue;
import java.util.Objects;
final class DefaultValidator implements Validator {
- private final Condition super JsonValue> contraint;
+ private final Fulfilable super JsonValue> contraint;
- public DefaultValidator(final Condition super JsonValue> contraint) {
+ public DefaultValidator(final Fulfilable super JsonValue> contraint) {
this.contraint = Objects.requireNonNull(contraint);
}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/EmptyJsonSchema.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/EmptyJsonSchema.java
index 8e21cbcc..8252d265 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/EmptyJsonSchema.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/EmptyJsonSchema.java
@@ -23,10 +23,10 @@
*/
package io.github.sebastiantoepfer.jsonschema.core;
+import io.github.sebastiantoepfer.common.condition4j.core.NoCondition;
import io.github.sebastiantoepfer.ddd.common.Media;
import io.github.sebastiantoepfer.jsonschema.JsonSubSchema;
import io.github.sebastiantoepfer.jsonschema.Validator;
-import io.github.sebastiantoepfer.jsonschema.core.codition.NoCondition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import jakarta.json.JsonValue;
import java.util.Optional;
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/FalseJsonSchema.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/FalseJsonSchema.java
index 0297576b..291a0c71 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/FalseJsonSchema.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/FalseJsonSchema.java
@@ -23,10 +23,10 @@
*/
package io.github.sebastiantoepfer.jsonschema.core;
+import io.github.sebastiantoepfer.common.condition4j.core.UnfulfillableCondition;
import io.github.sebastiantoepfer.ddd.common.Media;
import io.github.sebastiantoepfer.jsonschema.JsonSubSchema;
import io.github.sebastiantoepfer.jsonschema.Validator;
-import io.github.sebastiantoepfer.jsonschema.core.codition.UnfulfillableCondition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import jakarta.json.JsonValue;
import java.util.Optional;
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordBasedValidator.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordBasedValidator.java
index 974d09b7..7e7f4b0e 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordBasedValidator.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/KeywordBasedValidator.java
@@ -26,11 +26,10 @@
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;
+import io.github.sebastiantoepfer.common.condition4j.Fulfilable;
+import io.github.sebastiantoepfer.common.condition4j.core.AllOf;
+import io.github.sebastiantoepfer.common.condition4j.core.PredicateCondition;
import io.github.sebastiantoepfer.jsonschema.Validator;
-import io.github.sebastiantoepfer.jsonschema.core.codition.AllOfCondition;
-import io.github.sebastiantoepfer.jsonschema.core.codition.ApplicatorBasedCondtion;
-import io.github.sebastiantoepfer.jsonschema.core.codition.AssertionBasedCondition;
-import io.github.sebastiantoepfer.jsonschema.core.codition.Condition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import jakarta.json.JsonValue;
import java.util.Collection;
@@ -46,9 +45,7 @@ public KeywordBasedValidator(final Collection keywords) {
.stream()
.map(KeywordBasedValidator::asContraint)
.flatMap(Optional::stream)
- .collect(
- collectingAndThen(toList(), constraints -> new DefaultValidator(new AllOfCondition<>(constraints)))
- );
+ .collect(collectingAndThen(toList(), constraints -> new DefaultValidator(new AllOf<>(constraints))));
}
@Override
@@ -56,12 +53,12 @@ public boolean isValid(final JsonValue data) {
return validator.isValid(data);
}
- private static Optional> asContraint(final Keyword keyword) {
- final Condition result;
+ private static Optional> asContraint(final Keyword keyword) {
+ final Fulfilable result;
if (keyword.hasCategory(Keyword.KeywordCategory.ASSERTION)) {
- result = new AssertionBasedCondition(keyword.asAssertion());
+ result = new PredicateCondition<>(json -> keyword.asAssertion().isValidFor(json));
} else if (keyword.hasCategory(Keyword.KeywordCategory.APPLICATOR)) {
- result = new ApplicatorBasedCondtion(keyword.asApplicator());
+ result = new PredicateCondition<>(json -> keyword.asApplicator().applyTo(json));
} else {
result = null;
}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/TrueJsonSchema.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/TrueJsonSchema.java
index e22f0e8e..d0244e1a 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/TrueJsonSchema.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/TrueJsonSchema.java
@@ -23,10 +23,10 @@
*/
package io.github.sebastiantoepfer.jsonschema.core;
+import io.github.sebastiantoepfer.common.condition4j.core.NoCondition;
import io.github.sebastiantoepfer.ddd.common.Media;
import io.github.sebastiantoepfer.jsonschema.JsonSubSchema;
import io.github.sebastiantoepfer.jsonschema.Validator;
-import io.github.sebastiantoepfer.jsonschema.core.codition.NoCondition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import jakarta.json.JsonValue;
import java.util.Optional;
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/AllOfCondition.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/AllOfCondition.java
deleted file mode 100644
index 3350866f..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/AllOfCondition.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2023 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-import static java.util.Arrays.asList;
-
-import java.util.Collection;
-import java.util.List;
-
-public final class AllOfCondition implements Condition {
-
- private final List> contraints;
-
- public AllOfCondition(final Condition super T>... constraints) {
- this(asList(constraints));
- }
-
- public AllOfCondition(final Collection extends Condition super T>> contraints) {
- this.contraints = List.copyOf(contraints);
- }
-
- @Override
- public boolean isFulfilledBy(final T value) {
- return contraints.stream().allMatch(c -> c.isFulfilledBy(value));
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/ApplicatorBasedCondtion.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/ApplicatorBasedCondtion.java
deleted file mode 100644
index a8794c67..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/ApplicatorBasedCondtion.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2023 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-import io.github.sebastiantoepfer.jsonschema.keyword.Applicator;
-import jakarta.json.JsonValue;
-import java.util.Objects;
-
-public final class ApplicatorBasedCondtion implements Condition {
-
- private final Applicator applicator;
-
- public ApplicatorBasedCondtion(final Applicator applicator) {
- this.applicator = Objects.requireNonNull(applicator);
- }
-
- @Override
- public boolean isFulfilledBy(final JsonValue value) {
- return applicator.applyTo(value);
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/AssertionBasedCondition.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/AssertionBasedCondition.java
deleted file mode 100644
index f9efa858..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/AssertionBasedCondition.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2023 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-import io.github.sebastiantoepfer.jsonschema.keyword.Assertion;
-import jakarta.json.JsonValue;
-import java.util.Objects;
-
-public final class AssertionBasedCondition implements Condition {
-
- private final Assertion assertion;
-
- public AssertionBasedCondition(final Assertion assertion) {
- this.assertion = Objects.requireNonNull(assertion);
- }
-
- @Override
- public boolean isFulfilledBy(final JsonValue value) {
- return assertion.isValidFor(value);
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/CollectionElementsCondtion.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/CollectionElementsCondtion.java
deleted file mode 100644
index c6ec5a2d..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/CollectionElementsCondtion.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2024 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-import java.util.Collection;
-import java.util.Objects;
-
-public final class CollectionElementsCondtion implements Condition> {
-
- private final Condition elementsCondition;
-
- public CollectionElementsCondtion(final Condition elementsCondition) {
- this.elementsCondition = Objects.requireNonNull(elementsCondition);
- }
-
- @Override
- public boolean isFulfilledBy(final Collection value) {
- return value.stream().allMatch(elementsCondition::isFulfilledBy);
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/Condition.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/Condition.java
deleted file mode 100644
index 293895eb..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/Condition.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2023 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-public interface Condition {
- boolean isFulfilledBy(T value);
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/JsonPropertyCondition.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/JsonPropertyCondition.java
deleted file mode 100644
index 27f91bd3..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/JsonPropertyCondition.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2024 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import jakarta.json.JsonObject;
-import jakarta.json.JsonPointer;
-import jakarta.json.JsonValue;
-import java.util.Objects;
-
-public final class JsonPropertyCondition implements Condition {
-
- private final JsonPointer pointer;
- private final Condition condition;
-
- @SuppressFBWarnings("EI_EXPOSE_REP2")
- public JsonPropertyCondition(final JsonPointer pointer, final Condition condition) {
- this.pointer = Objects.requireNonNull(pointer);
- this.condition = Objects.requireNonNull(condition);
- }
-
- @Override
- public boolean isFulfilledBy(final JsonObject value) {
- final boolean result;
- if (pointer.containsValue(value)) {
- result = condition.isFulfilledBy(pointer.getValue(value));
- } else {
- result = condition.isFulfilledBy(JsonValue.NULL);
- }
- return result;
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/MappingConditionAdapter.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/MappingConditionAdapter.java
deleted file mode 100644
index 22b86f24..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/MappingConditionAdapter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2024 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-import java.util.Objects;
-import java.util.function.Function;
-
-public final class MappingConditionAdapter implements Condition {
-
- private final Function check;
-
- public MappingConditionAdapter(final Condition condition, final Function map) {
- this.check = Objects.requireNonNull(map).andThen(condition::isFulfilledBy);
- }
-
- @Override
- public boolean isFulfilledBy(final T value) {
- return check.apply(value);
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/NoCondition.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/NoCondition.java
deleted file mode 100644
index dd935fc4..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/NoCondition.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2023 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-public final class NoCondition implements Condition {
-
- @Override
- public boolean isFulfilledBy(final T value) {
- return true;
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/OfTypeCondition.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/OfTypeCondition.java
deleted file mode 100644
index d9fa0c99..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/OfTypeCondition.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2024 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-import io.github.sebastiantoepfer.jsonschema.InstanceType;
-import jakarta.json.JsonValue;
-
-public final class OfTypeCondition implements Condition {
-
- private final InstanceType type;
-
- public OfTypeCondition(final InstanceType type) {
- this.type = type;
- }
-
- @Override
- public boolean isFulfilledBy(final JsonValue value) {
- return type.isInstance(value);
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/UnfulfillableCondition.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/UnfulfillableCondition.java
deleted file mode 100644
index 38163878..00000000
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/codition/UnfulfillableCondition.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2023 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-public final class UnfulfillableCondition implements Condition {
-
- @Override
- public boolean isFulfilledBy(final T value) {
- return false;
- }
-}
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordType.java
index 59c9c616..52c59a60 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordType.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/BooleanKeywordType.java
@@ -23,10 +23,10 @@
*/
package io.github.sebastiantoepfer.jsonschema.core.keyword.type;
+import io.github.sebastiantoepfer.common.condition4j.core.PredicateCondition;
+import io.github.sebastiantoepfer.common.condition4j.json.JsonPropertyWhichFulfilThe;
import io.github.sebastiantoepfer.jsonschema.InstanceType;
import io.github.sebastiantoepfer.jsonschema.JsonSchema;
-import io.github.sebastiantoepfer.jsonschema.core.codition.JsonPropertyCondition;
-import io.github.sebastiantoepfer.jsonschema.core.codition.OfTypeCondition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType;
import jakarta.json.JsonObject;
@@ -62,9 +62,9 @@ public Keyword createKeyword(final JsonSchema schema) {
private Keyword createKeyword(final JsonObject schema) {
if (
- new JsonPropertyCondition(
+ new JsonPropertyWhichFulfilThe(
jsonContext.createPointer(String.format("/%s", name)),
- new OfTypeCondition(InstanceType.BOOLEAN)
+ new PredicateCondition<>(InstanceType.BOOLEAN::isInstance)
)
.isFulfilledBy(schema)
) {
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordType.java
index 5019729f..47df5e5a 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordType.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/IntegerKeywordType.java
@@ -23,10 +23,10 @@
*/
package io.github.sebastiantoepfer.jsonschema.core.keyword.type;
+import io.github.sebastiantoepfer.common.condition4j.core.PredicateCondition;
+import io.github.sebastiantoepfer.common.condition4j.json.JsonPropertyWhichFulfilThe;
import io.github.sebastiantoepfer.jsonschema.InstanceType;
import io.github.sebastiantoepfer.jsonschema.JsonSchema;
-import io.github.sebastiantoepfer.jsonschema.core.codition.JsonPropertyCondition;
-import io.github.sebastiantoepfer.jsonschema.core.codition.OfTypeCondition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType;
import jakarta.json.JsonObject;
@@ -64,7 +64,10 @@ public Keyword createKeyword(final JsonSchema schema) {
private Keyword createKeyword(final JsonObject asJsonObject) {
if (
- new JsonPropertyCondition(createJsonPointer(), new OfTypeCondition(InstanceType.INTEGER))
+ new JsonPropertyWhichFulfilThe(
+ createJsonPointer(),
+ new PredicateCondition<>(InstanceType.INTEGER::isInstance)
+ )
.isFulfilledBy(asJsonObject)
) {
return keywordCreator.apply(asJsonObject.getJsonNumber(name).bigIntegerValueExact());
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordType.java
index 18f863a4..03a1d477 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordType.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/NumberKeywordType.java
@@ -23,10 +23,10 @@
*/
package io.github.sebastiantoepfer.jsonschema.core.keyword.type;
+import io.github.sebastiantoepfer.common.condition4j.core.PredicateCondition;
+import io.github.sebastiantoepfer.common.condition4j.json.JsonPropertyWhichFulfilThe;
import io.github.sebastiantoepfer.jsonschema.InstanceType;
import io.github.sebastiantoepfer.jsonschema.JsonSchema;
-import io.github.sebastiantoepfer.jsonschema.core.codition.JsonPropertyCondition;
-import io.github.sebastiantoepfer.jsonschema.core.codition.OfTypeCondition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType;
import jakarta.json.JsonObject;
@@ -63,9 +63,9 @@ public Keyword createKeyword(final JsonSchema schema) {
private Keyword createKeyword(final JsonObject schema) {
if (
- new JsonPropertyCondition(
+ new JsonPropertyWhichFulfilThe(
jsonContext.createPointer(String.format("/%s", name)),
- new OfTypeCondition(InstanceType.NUMBER)
+ new PredicateCondition<>(InstanceType.NUMBER::isInstance)
)
.isFulfilledBy(schema)
) {
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordType.java
index e70da5f6..97c0a2e1 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordType.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringArrayKeywordType.java
@@ -26,13 +26,13 @@
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;
+import io.github.sebastiantoepfer.common.condition4j.core.AllOf;
+import io.github.sebastiantoepfer.common.condition4j.core.ContainsOnlyItemsWhichFulfilThe;
+import io.github.sebastiantoepfer.common.condition4j.core.MappedToFullfillThe;
+import io.github.sebastiantoepfer.common.condition4j.core.PredicateCondition;
+import io.github.sebastiantoepfer.common.condition4j.json.JsonPropertyWhichFulfilThe;
import io.github.sebastiantoepfer.jsonschema.InstanceType;
import io.github.sebastiantoepfer.jsonschema.JsonSchema;
-import io.github.sebastiantoepfer.jsonschema.core.codition.AllOfCondition;
-import io.github.sebastiantoepfer.jsonschema.core.codition.CollectionElementsCondtion;
-import io.github.sebastiantoepfer.jsonschema.core.codition.JsonPropertyCondition;
-import io.github.sebastiantoepfer.jsonschema.core.codition.MappingConditionAdapter;
-import io.github.sebastiantoepfer.jsonschema.core.codition.OfTypeCondition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType;
import jakarta.json.JsonObject;
@@ -71,12 +71,14 @@ public Keyword createKeyword(final JsonSchema schema) {
private Keyword createKeyword(final JsonObject schema) {
if (
- new JsonPropertyCondition(
+ new JsonPropertyWhichFulfilThe(
jsonContext.createPointer(String.format("/%s", name)),
- new AllOfCondition<>(
- new OfTypeCondition(InstanceType.ARRAY),
- new MappingConditionAdapter<>(
- new CollectionElementsCondtion<>(new OfTypeCondition(InstanceType.STRING)),
+ new AllOf<>(
+ new PredicateCondition<>(InstanceType.ARRAY::isInstance),
+ new MappedToFullfillThe<>(
+ new ContainsOnlyItemsWhichFulfilThe<>(
+ new PredicateCondition<>(InstanceType.STRING::isInstance)
+ ),
JsonValue::asJsonArray
)
)
diff --git a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordType.java b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordType.java
index db7d2058..ad79bc9a 100644
--- a/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordType.java
+++ b/core/src/main/java/io/github/sebastiantoepfer/jsonschema/core/keyword/type/StringKeywordType.java
@@ -23,10 +23,10 @@
*/
package io.github.sebastiantoepfer.jsonschema.core.keyword.type;
+import io.github.sebastiantoepfer.common.condition4j.core.PredicateCondition;
+import io.github.sebastiantoepfer.common.condition4j.json.JsonPropertyWhichFulfilThe;
import io.github.sebastiantoepfer.jsonschema.InstanceType;
import io.github.sebastiantoepfer.jsonschema.JsonSchema;
-import io.github.sebastiantoepfer.jsonschema.core.codition.JsonPropertyCondition;
-import io.github.sebastiantoepfer.jsonschema.core.codition.OfTypeCondition;
import io.github.sebastiantoepfer.jsonschema.keyword.Keyword;
import io.github.sebastiantoepfer.jsonschema.keyword.KeywordType;
import jakarta.json.JsonObject;
@@ -63,7 +63,11 @@ public Keyword createKeyword(final JsonSchema schema) {
private Keyword createKeyword(final JsonObject obj) {
if (
- new JsonPropertyCondition(createJsonPointer(), new OfTypeCondition(InstanceType.STRING)).isFulfilledBy(obj)
+ new JsonPropertyWhichFulfilThe(
+ createJsonPointer(),
+ new PredicateCondition<>(InstanceType.STRING::isInstance)
+ )
+ .isFulfilledBy(obj)
) {
return keywordCreator.apply(obj.getString(name()));
} else {
diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java
index dd9d2ca6..a1d1c754 100644
--- a/core/src/main/java/module-info.java
+++ b/core/src/main/java/module-info.java
@@ -26,6 +26,9 @@
requires io.github.sebastiantoepfer.jsonschema.vocabulary.spi;
requires io.github.sebastiantoepfer.ddd.common;
requires io.github.sebastiantoepfer.ddd.media.json;
+ requires io.github.sebastiantoepfer.common.condition4j;
+ requires io.github.sebastiantoepfer.common.condition4j.core;
+ requires io.github.sebastiantoepfer.common.condition4j.json;
requires jakarta.json;
requires com.github.spotbugs.annotations;
diff --git a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/codition/CollectionElementsCondtionTest.java b/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/codition/CollectionElementsCondtionTest.java
deleted file mode 100644
index 7da4761e..00000000
--- a/core/src/test/java/io/github/sebastiantoepfer/jsonschema/core/codition/CollectionElementsCondtionTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2024 sebastian.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package io.github.sebastiantoepfer.jsonschema.core.codition;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import java.util.List;
-import org.junit.jupiter.api.Test;
-
-class CollectionElementsCondtionTest {
-
- @Test
- void should_be_valid_if_all_elements_match_given_conditon() {
- assertThat(
- new CollectionElementsCondtion(v -> v.startsWith("w"))
- .isFulfilledBy(List.of("world", "whale", "word")),
- is(true)
- );
- }
-
- @Test
- void should_be_invalid_if_all_elements_not_match_given_conditon() {
- assertThat(
- new CollectionElementsCondtion(v -> v.startsWith("a"))
- .isFulfilledBy(List.of("world", "whale", "word")),
- is(false)
- );
- }
-
- @Test
- void should_be_invalid_if_one_elements_not_match_given_conditon() {
- assertThat(
- new CollectionElementsCondtion(v -> v.contains("o"))
- .isFulfilledBy(List.of("world", "whale", "word")),
- is(false)
- );
- }
-}
diff --git a/core/src/test/java/module-info.java b/core/src/test/java/module-info.java
index ad6a3a0e..01c80646 100644
--- a/core/src/test/java/module-info.java
+++ b/core/src/test/java/module-info.java
@@ -27,6 +27,9 @@
requires io.github.sebastiantoepfer.ddd.common;
requires io.github.sebastiantoepfer.ddd.media.json;
requires io.github.sebastiantoepfer.ddd.media.core;
+ requires io.github.sebastiantoepfer.common.condition4j;
+ requires io.github.sebastiantoepfer.common.condition4j.core;
+ requires io.github.sebastiantoepfer.common.condition4j.json;
requires jakarta.json;
uses io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies;
diff --git a/pom.xml b/pom.xml
index 271f26a3..af58b120 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,6 +50,7 @@
17
0.6.0
+ 0.1.0
@@ -76,6 +77,22 @@
${ddd.version}
+
+ io.github.sebastian-toepfer.common
+ condition4j-api
+ ${condition.version}
+
+
+ io.github.sebastian-toepfer.common
+ condition4j-core
+ ${condition.version}
+
+
+ io.github.sebastian-toepfer.common
+ condition4j-json-p
+ ${condition.version}
+
+
org.eclipse.parsson
parsson