Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/_publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -46,7 +46,6 @@ jobs:
exit 1
fi


- name: Copy Code Samples
run: |
mkdir -p ./target/site/apidocs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
54 changes: 51 additions & 3 deletions src/main/java/com/mindee/parsing/v2/field/FieldConfidence.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}
5 changes: 5 additions & 0 deletions src/test/java/com/mindee/parsing/v2/InferenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<FieldLocation> locations = fieldSimpleString.getLocations();
assertEquals(1, locations.size());
Expand Down
Loading