diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index c94ea2fa..458d5ced 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -29,7 +29,7 @@ jobs: gpg --list-secret-keys --keyid-format LONG - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: java-version: ${{ matrix.java-version }} distribution: ${{ matrix.distribution }} diff --git a/.github/workflows/_publish-docs.yml b/.github/workflows/_publish-docs.yml index 8d0631ac..d03a3e92 100644 --- a/.github/workflows/_publish-docs.yml +++ b/.github/workflows/_publish-docs.yml @@ -14,7 +14,7 @@ jobs: submodules: recursive - name: Set up JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: java-version: "11" distribution: "temurin" @@ -46,7 +46,6 @@ jobs: exit 1 fi - - name: Copy Code Samples run: | mkdir -p ./target/site/apidocs diff --git a/.github/workflows/_test-integrations.yml b/.github/workflows/_test-integrations.yml index 6fefaa7b..fe4bed41 100644 --- a/.github/workflows/_test-integrations.yml +++ b/.github/workflows/_test-integrations.yml @@ -23,7 +23,7 @@ jobs: submodules: recursive - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: java-version: ${{ matrix.java-version }} distribution: ${{ matrix.distribution }} diff --git a/src/main/java/com/mindee/parsing/v2/field/FieldConfidence.java b/src/main/java/com/mindee/parsing/v2/field/FieldConfidence.java index 8651f02f..01daa01f 100644 --- a/src/main/java/com/mindee/parsing/v2/field/FieldConfidence.java +++ b/src/main/java/com/mindee/parsing/v2/field/FieldConfidence.java @@ -7,10 +7,10 @@ * Confidence level of a field as returned by the V2 API. */ public enum FieldConfidence { - Certain("Certain"), - High("High"), + Low("Low"), Medium("Medium"), - Low("Low"); + High("High"), + Certain("Certain"); private final String json; @@ -35,4 +35,52 @@ public static FieldConfidence fromJson(String value) { } throw new IllegalArgumentException("Unknown confidence level '" + value + "'."); } + + /** + * Compares the current FieldConfidence level with another FieldConfidence level + * to determine if the current level is greater. + * + * @param other the other FieldConfidence level to compare against + * @return true if the current FieldConfidence level is greater than the specified level, + * false otherwise + */ + public boolean greaterThan(FieldConfidence other) { + return this.compareTo(other) > 0; + } + + /** + * Compares the current FieldConfidence level with another FieldConfidence level + * to determine if the current level is greater than or equal to the specified level. + * + * @param other the other FieldConfidence level to compare against + * @return true if the current FieldConfidence level is greater than or equal to the specified level, + * false otherwise + */ + public boolean greaterThanOrEqual(FieldConfidence other) { + return this.compareTo(other) >= 0; + } + + /** + * Compares the current FieldConfidence level with another FieldConfidence level + * to determine if the current level is less than the specified level. + * + * @param other the other FieldConfidence level to compare against + * @return true if the current FieldConfidence level is less than the specified level, + * false otherwise + */ + public boolean lessThan(FieldConfidence other) { + return this.compareTo(other) < 0; + } + + /** + * Compares the current FieldConfidence level with another FieldConfidence level + * to determine if the current level is less than or equal to the specified level. + * + * @param other the other FieldConfidence level to compare against + * @return true if the current FieldConfidence level is less than or equal to the specified level, + * false otherwise + */ + public boolean lessThanOrEqual(FieldConfidence other) { + return this.compareTo(other) <= 0; + } } diff --git a/src/test/java/com/mindee/parsing/v2/InferenceTest.java b/src/test/java/com/mindee/parsing/v2/InferenceTest.java index 983fe40c..456239d2 100644 --- a/src/test/java/com/mindee/parsing/v2/InferenceTest.java +++ b/src/test/java/com/mindee/parsing/v2/InferenceTest.java @@ -426,6 +426,11 @@ void standardFieldTypes_confidenceAndLocations() throws IOException { FieldConfidence confidence = fieldSimpleString.getConfidence(); boolean isCertain = confidence == FieldConfidence.Certain; assertTrue(isCertain); + assertEquals(3, confidence.ordinal()); + assertTrue(confidence.greaterThanOrEqual(FieldConfidence.Certain)); + assertTrue(confidence.greaterThan(FieldConfidence.Medium)); + assertTrue(confidence.lessThanOrEqual(FieldConfidence.Certain)); + assertFalse(confidence.lessThan(FieldConfidence.Certain)); List locations = fieldSimpleString.getLocations(); assertEquals(1, locations.size());