-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move interfaces back to Java to avoid -Xjvm-default compiler arg
- Loading branch information
Showing
19 changed files
with
154 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
jcv-core/src/main/java/com/ekino/oss/jcv/core/JsonContextMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2019 ekino (https://www.ekino.com/) | ||
*/ | ||
package com.ekino.oss.jcv.core; | ||
|
||
/** | ||
* Matcher used to identify a specific field. | ||
* | ||
* @author Leo Millon | ||
*/ | ||
@FunctionalInterface | ||
public interface JsonContextMatcher { | ||
|
||
/** | ||
* Evaluates the current json parsing context. | ||
* | ||
* @param prefix the current json field path | ||
* @param expectedValue the expected field value | ||
* @param actualValue the actual field value | ||
* | ||
* @return {@code true} if the context matches, otherwise {@code false} | ||
*/ | ||
boolean matches(String prefix, Object expectedValue, Object actualValue); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
jcv-core/src/main/java/com/ekino/oss/jcv/core/JsonValueComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2019 ekino (https://www.ekino.com/) | ||
*/ | ||
package com.ekino.oss.jcv.core; | ||
|
||
import org.skyscreamer.jsonassert.ValueMatcher; | ||
|
||
/** | ||
* A JSON value comparator. | ||
* | ||
* @param <T> the field value type | ||
* | ||
* @author Leo Millon | ||
*/ | ||
@FunctionalInterface | ||
public interface JsonValueComparator<T> extends ValueMatcher<T> { | ||
|
||
@Override | ||
default boolean equal(T o1, T o2) { | ||
return hasCorrectValue(o1, o2); | ||
} | ||
|
||
/** | ||
* Evaluates actual field value against the expected one. | ||
* | ||
* @param actual field actual value | ||
* @param expected field expected value | ||
* | ||
* @return {@code true} if the actual is valid against the expected one, otherwise {@code false} | ||
*/ | ||
boolean hasCorrectValue(T actual, T expected); | ||
} |
24 changes: 24 additions & 0 deletions
24
...re/src/main/java/com/ekino/oss/jcv/core/initializer/NoParameterComparatorInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2019 ekino (https://www.ekino.com/) | ||
*/ | ||
package com.ekino.oss.jcv.core.initializer; | ||
|
||
import org.skyscreamer.jsonassert.ValueMatcher; | ||
|
||
/** | ||
* Comparator intializer. | ||
* | ||
* @param <T> the field value type | ||
* | ||
* @author Leo Millon | ||
*/ | ||
@FunctionalInterface | ||
public interface NoParameterComparatorInitializer<T> { | ||
|
||
/** | ||
* Init a comparator without template parameter. | ||
* | ||
* @return the initalized comparator | ||
*/ | ||
ValueMatcher<T> initComparator(); | ||
} |
26 changes: 26 additions & 0 deletions
26
...e/src/main/java/com/ekino/oss/jcv/core/initializer/OneParameterComparatorInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2019 ekino (https://www.ekino.com/) | ||
*/ | ||
package com.ekino.oss.jcv.core.initializer; | ||
|
||
import org.skyscreamer.jsonassert.ValueMatcher; | ||
|
||
/** | ||
* Comparator intializer given tempated validator with 1 parameter information. | ||
* | ||
* @param <T> the field value type | ||
* | ||
* @author Leo Millon | ||
*/ | ||
@FunctionalInterface | ||
public interface OneParameterComparatorInitializer<T> { | ||
|
||
/** | ||
* Init a comparator using the current templated validator info. | ||
* | ||
* @param parameter the first parameter of the templated validator | ||
* | ||
* @return the initalized comparator | ||
*/ | ||
ValueMatcher<T> initComparator(String parameter); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/JsonContextMatcher.kt
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/JsonValueComparator.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.