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

org.dmg.pmml.rule_set.RuleSet Maven / Gradle / Ivy


package org.dmg.pmml.rule_set;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.dmg.pmml.Extension;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.ScoreDistribution;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.NumberAdapter;
import org.jpmml.model.annotations.ValueConstructor;

@XmlRootElement(name = "RuleSet", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
    "extensions",
    "ruleSelectionMethods",
    "scoreDistributions",
    "rules"
})
@JsonRootName("RuleSet")
@JsonPropertyOrder({
    "recordCount",
    "nbCorrect",
    "defaultScore",
    "defaultConfidence",
    "extensions",
    "ruleSelectionMethods",
    "scoreDistributions",
    "rules"
})
public class RuleSet
    extends org.dmg.pmml.PMMLObject
    implements HasExtensions
{

    @XmlAttribute(name = "recordCount")
    @XmlJavaTypeAdapter(NumberAdapter.class)
    @JsonProperty("recordCount")
    private Number recordCount;
    @XmlAttribute(name = "nbCorrect")
    @XmlJavaTypeAdapter(NumberAdapter.class)
    @JsonProperty("nbCorrect")
    private Number nbCorrect;
    @XmlAttribute(name = "defaultScore")
    @JsonProperty("defaultScore")
    private String defaultScore;
    @XmlAttribute(name = "defaultConfidence")
    @XmlJavaTypeAdapter(NumberAdapter.class)
    @JsonProperty("defaultConfidence")
    private Number defaultConfidence;
    @XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("Extension")
    private List extensions;
    @XmlElement(name = "RuleSelectionMethod", namespace = "http://www.dmg.org/PMML-4_4", required = true)
    @JsonProperty("RuleSelectionMethod")
    private List ruleSelectionMethods;
    @XmlElement(name = "ScoreDistribution", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("ScoreDistribution")
    private List scoreDistributions;
    @XmlElements({
        @XmlElement(name = "SimpleRule", namespace = "http://www.dmg.org/PMML-4_4", type = org.dmg.pmml.rule_set.SimpleRule.class),
        @XmlElement(name = "CompoundRule", namespace = "http://www.dmg.org/PMML-4_4", type = org.dmg.pmml.rule_set.CompoundRule.class)
    })
    @JsonProperty("Rule")
    @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
    @JsonSubTypes({
        @JsonSubTypes.Type(name = "SimpleRule", value = org.dmg.pmml.rule_set.SimpleRule.class),
        @JsonSubTypes.Type(name = "CompoundRule", value = org.dmg.pmml.rule_set.CompoundRule.class)
    })
    private List rules;
    private final static long serialVersionUID = 67371009L;

    public RuleSet() {
    }

    @ValueConstructor
    public RuleSet(
        @org.jpmml.model.annotations.Property("ruleSelectionMethods")
        List ruleSelectionMethods) {
        this.ruleSelectionMethods = ruleSelectionMethods;
    }

    public Number getRecordCount() {
        return recordCount;
    }

    public RuleSet setRecordCount(
        @org.jpmml.model.annotations.Property("recordCount")
        Number recordCount) {
        this.recordCount = recordCount;
        return this;
    }

    public Number getNbCorrect() {
        return nbCorrect;
    }

    public RuleSet setNbCorrect(
        @org.jpmml.model.annotations.Property("nbCorrect")
        Number nbCorrect) {
        this.nbCorrect = nbCorrect;
        return this;
    }

    public String getDefaultScore() {
        return defaultScore;
    }

    public RuleSet setDefaultScore(
        @org.jpmml.model.annotations.Property("defaultScore")
        String defaultScore) {
        this.defaultScore = defaultScore;
        return this;
    }

    public Number getDefaultConfidence() {
        return defaultConfidence;
    }

    public RuleSet setDefaultConfidence(
        @org.jpmml.model.annotations.Property("defaultConfidence")
        Number defaultConfidence) {
        this.defaultConfidence = defaultConfidence;
        return this;
    }

    @Override
    public boolean hasExtensions() {
        return ((this.extensions!= null)&&(this.extensions.size()> 0));
    }

    @Override
    public List getExtensions() {
        if (extensions == null) {
            extensions = new ArrayList();
        }
        return this.extensions;
    }

    @Override
    public RuleSet addExtensions(Extension... extensions) {
        getExtensions().addAll(Arrays.asList(extensions));
        return this;
    }

    public boolean hasRuleSelectionMethods() {
        return ((this.ruleSelectionMethods!= null)&&(this.ruleSelectionMethods.size()> 0));
    }

    public List getRuleSelectionMethods() {
        if (ruleSelectionMethods == null) {
            ruleSelectionMethods = new ArrayList();
        }
        return this.ruleSelectionMethods;
    }

    public RuleSet addRuleSelectionMethods(RuleSelectionMethod... ruleSelectionMethods) {
        getRuleSelectionMethods().addAll(Arrays.asList(ruleSelectionMethods));
        return this;
    }

    public boolean hasScoreDistributions() {
        return ((this.scoreDistributions!= null)&&(this.scoreDistributions.size()> 0));
    }

    public List getScoreDistributions() {
        if (scoreDistributions == null) {
            scoreDistributions = new ArrayList();
        }
        return this.scoreDistributions;
    }

    public RuleSet addScoreDistributions(ScoreDistribution... scoreDistributions) {
        getScoreDistributions().addAll(Arrays.asList(scoreDistributions));
        return this;
    }

    public boolean hasRules() {
        return ((this.rules!= null)&&(this.rules.size()> 0));
    }

    public List getRules() {
        if (rules == null) {
            rules = new ArrayList();
        }
        return this.rules;
    }

    public RuleSet addRules(Rule... rules) {
        getRules().addAll(Arrays.asList(rules));
        return this;
    }

    @Override
    public VisitorAction accept(Visitor visitor) {
        VisitorAction status = visitor.visit(this);
        if (status == VisitorAction.CONTINUE) {
            visitor.pushParent(this);
            if ((status == VisitorAction.CONTINUE)&&hasExtensions()) {
                status = org.dmg.pmml.PMMLObject.traverse(visitor, getExtensions());
            }
            if ((status == VisitorAction.CONTINUE)&&hasRuleSelectionMethods()) {
                status = org.dmg.pmml.PMMLObject.traverse(visitor, getRuleSelectionMethods());
            }
            if ((status == VisitorAction.CONTINUE)&&hasScoreDistributions()) {
                status = org.dmg.pmml.PMMLObject.traverse(visitor, getScoreDistributions());
            }
            if ((status == VisitorAction.CONTINUE)&&hasRules()) {
                status = org.dmg.pmml.PMMLObject.traverse(visitor, getRules());
            }
            visitor.popParent();
        }
        if (status == VisitorAction.TERMINATE) {
            return VisitorAction.TERMINATE;
        }
        return VisitorAction.CONTINUE;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy