All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.groupbyinc.api.model.MatchStrategy Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
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;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy