Skip to content

Commit f20a2f7

Browse files
Mykola Mokhnachsaikrishna321
Mykola Mokhnach
authored andcommitted
Add threshold argument to OccurrenceMatchingOptions (#1060)
* Add threshold argument to OccurrenceMatchingOptions * Fix linter
1 parent f527be1 commit f20a2f7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/main/java/io/appium/java_client/imagecomparison/OccurrenceMatchingOptions.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,31 @@
1616

1717
package io.appium.java_client.imagecomparison;
1818

19+
import static java.util.Optional.ofNullable;
20+
21+
import com.google.common.collect.ImmutableMap;
22+
23+
import java.util.Map;
24+
1925
public class OccurrenceMatchingOptions extends BaseComparisonOptions<OccurrenceMatchingOptions> {
26+
private Double threshold;
27+
28+
/**
29+
* At what normalized threshold to reject an occurrence.
30+
*
31+
* @param threshold value in range 0..1. 0.5 is the default value.
32+
* @return self instance for chaining.
33+
*/
34+
public OccurrenceMatchingOptions withThreshold(double threshold) {
35+
this.threshold = threshold;
36+
return this;
37+
}
38+
39+
@Override
40+
public Map<String, Object> build() {
41+
final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
42+
builder.putAll(super.build());
43+
ofNullable(threshold).map(x -> builder.put("threshold", x));
44+
return builder.build();
45+
}
2046
}

0 commit comments

Comments
 (0)