com.groupbyinc.api.model.MatchStrategy Maven / Gradle / Ivy
package com.groupbyinc.api.model;
import com.groupbyinc.api.interfaces.MatchStrategyInterface;
import com.groupbyinc.api.interfaces.PartialMatchRuleInterface;
import com.groupbyinc.common.apache.commons.collections4.CollectionUtils;
import com.groupbyinc.common.jackson.annotation.JsonIgnore;
import com.groupbyinc.common.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
/**
* @author osman
* @internal
*/
public class MatchStrategy implements MatchStrategyInterface {
@JsonProperty private String name;
@JsonProperty private List rules = new ArrayList();
public List getRules() {
return rules;
}
@JsonIgnore
public MatchStrategy setRules(PartialMatchRule... rules) {
CollectionUtils.addAll(this.rules, rules);
return this;
}
public MatchStrategy setRules(List rules) {
this.rules = rules;
return this;
}
@Override
@JsonIgnore
public void addRule(PartialMatchRuleInterface rule) {
rules.add(new PartialMatchRule().setTerms(rule.getTerms())
.setTermsGreaterThan(rule.getTermsGreaterThan())
.setMustMatch(rule.getMustMatch())
.setPercentage(rule.getPercentage()));
}
public String getName() {
return name;
}
public MatchStrategy setName(String name) {
this.name = name;
return this;
}
}