Skip to content

Commit

Permalink
Add threshold argument to OccurrenceMatchingOptions (#1060)
Browse files Browse the repository at this point in the history
* Add threshold argument to OccurrenceMatchingOptions

* Fix linter
  • Loading branch information
Mykola Mokhnach authored and saikrishna321 committed Nov 19, 2018
1 parent f527be1 commit f20a2f7
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,31 @@

package io.appium.java_client.imagecomparison;

import static java.util.Optional.ofNullable;

import com.google.common.collect.ImmutableMap;

import java.util.Map;

public class OccurrenceMatchingOptions extends BaseComparisonOptions<OccurrenceMatchingOptions> {
private Double threshold;

/**
* At what normalized threshold to reject an occurrence.
*
* @param threshold value in range 0..1. 0.5 is the default value.
* @return self instance for chaining.
*/
public OccurrenceMatchingOptions withThreshold(double threshold) {
this.threshold = threshold;
return this;
}

@Override
public Map<String, Object> build() {
final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
builder.putAll(super.build());
ofNullable(threshold).map(x -> builder.put("threshold", x));
return builder.build();
}
}

0 comments on commit f20a2f7

Please sign in to comment.