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

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

There is a newer version: 1.6.6
Show newest version

package org.dmg.pmml.rule_set;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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 com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElements;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSchemaType;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.dmg.pmml.Extension;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.HasRecordCount;
import org.dmg.pmml.ScoreDistribution;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.NumberAdapter;
import org.dmg.pmml.adapters.ObjectAdapter;
import org.jpmml.model.MissingAttributeException;
import org.jpmml.model.MissingElementException;
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 , HasRecordCount
{

    @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")
    @XmlJavaTypeAdapter(ObjectAdapter.class)
    @XmlSchemaType(name = "anySimpleType")
    @JsonProperty("defaultScore")
    private Object 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;
    @XmlElements({
        @XmlElement(name = "ScoreDistribution", namespace = "http://www.dmg.org/PMML-4_4", type = org.dmg.pmml.ComplexScoreDistribution.class)
    })
    @JsonProperty("ScoreDistribution")
    @JsonTypeInfo(use = JsonTypeInfo.Id.NONE, defaultImpl = org.dmg.pmml.ComplexScoreDistribution.class)
    @JsonDeserialize(contentAs = org.dmg.pmml.ComplexScoreDistribution.class)
    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 = 67371270L;

    public RuleSet() {
    }

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

    @Override
    public Number getRecordCount() {
        return recordCount;
    }

    @Override
    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 Object requireDefaultScore() {
        if (this.defaultScore == null) {
            throw new MissingAttributeException(this, PMMLAttributes.RULESET_DEFAULTSCORE);
        }
        return this.defaultScore;
    }

    public Object getDefaultScore() {
        return defaultScore;
    }

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

    public Number requireDefaultConfidence() {
        if (this.defaultConfidence == null) {
            throw new MissingAttributeException(this, PMMLAttributes.RULESET_DEFAULTCONFIDENCE);
        }
        return this.defaultConfidence;
    }

    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.isEmpty()));
    }

    @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.isEmpty()));
    }

    public List requireRuleSelectionMethods() {
        if ((this.ruleSelectionMethods == null)||this.ruleSelectionMethods.isEmpty()) {
            throw new MissingElementException(this, PMMLElements.RULESET_RULESELECTIONMETHODS);
        }
        return this.ruleSelectionMethods;
    }

    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.isEmpty()));
    }

    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.isEmpty()));
    }

    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