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

org.dmg.pmml.sequence.SequenceRule Maven / Gradle / Ivy

There is a newer version: 1.6.6
Show newest version

package org.dmg.pmml.sequence;

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 jakarta.xml.bind.annotation.XmlAnyElement;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElementRef;
import jakarta.xml.bind.annotation.XmlElementRefs;
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.Entity;
import org.dmg.pmml.Extension;
import org.dmg.pmml.PMMLObject;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.IntegerAdapter;
import org.dmg.pmml.adapters.NonNegativeIntegerAdapter;
import org.dmg.pmml.adapters.RealNumberAdapter;
import org.jpmml.model.MissingAttributeException;
import org.jpmml.model.annotations.Added;
import org.jpmml.model.annotations.ValueConstructor;

@XmlRootElement(name = "SequenceRule", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
    "content"
})
@JsonRootName("SequenceRule")
@JsonPropertyOrder({
    "id",
    "numberOfSets",
    "occurrence",
    "support",
    "confidence",
    "lift",
    "content"
})
public class SequenceRule
    extends Entity
{

    @XmlAttribute(name = "id", required = true)
    @JsonProperty("id")
    private String id;
    @XmlAttribute(name = "numberOfSets", required = true)
    @XmlJavaTypeAdapter(NonNegativeIntegerAdapter.class)
    @XmlSchemaType(name = "nonNegativeInteger")
    @JsonProperty("numberOfSets")
    private Integer numberOfSets;
    @XmlAttribute(name = "occurrence", required = true)
    @XmlJavaTypeAdapter(IntegerAdapter.class)
    @JsonProperty("occurrence")
    private Integer occurrence;
    @XmlAttribute(name = "support", required = true)
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @JsonProperty("support")
    private Number support;
    @XmlAttribute(name = "confidence", required = true)
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @JsonProperty("confidence")
    private Number confidence;
    @XmlAttribute(name = "lift")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @Added((org.dmg.pmml.Version.PMML_3_1))
    @JsonProperty("lift")
    private Number lift;
    @XmlElementRefs({
        @XmlElementRef(name = "Extension", namespace = "http://www.dmg.org/PMML-4_4", type = Extension.class, required = false),
        @XmlElementRef(name = "AntecedentSequence", namespace = "http://www.dmg.org/PMML-4_4", type = AntecedentSequence.class, required = false),
        @XmlElementRef(name = "Delimiter", namespace = "http://www.dmg.org/PMML-4_4", type = Delimiter.class, required = false),
        @XmlElementRef(name = "Time", namespace = "http://www.dmg.org/PMML-4_4", type = Time.class, required = false),
        @XmlElementRef(name = "ConsequentSequence", namespace = "http://www.dmg.org/PMML-4_4", type = ConsequentSequence.class, required = false)
    })
    @XmlAnyElement(lax = true)
    @JsonProperty("content")
    private List content;
    private final static long serialVersionUID = 67371270L;

    public SequenceRule() {
    }

    @ValueConstructor
    public SequenceRule(
        @org.jpmml.model.annotations.Property("id")
        String id,
        @org.jpmml.model.annotations.Property("numberOfSets")
        Integer numberOfSets,
        @org.jpmml.model.annotations.Property("occurrence")
        Integer occurrence,
        @org.jpmml.model.annotations.Property("support")
        Number support,
        @org.jpmml.model.annotations.Property("confidence")
        Number confidence) {
        this.id = id;
        this.numberOfSets = numberOfSets;
        this.occurrence = occurrence;
        this.support = support;
        this.confidence = confidence;
    }

    public String requireId() {
        if (this.id == null) {
            throw new MissingAttributeException(this, PMMLAttributes.SEQUENCERULE_ID);
        }
        return this.id;
    }

    @Override
    public String getId() {
        return id;
    }

    @Override
    public SequenceRule setId(
        @org.jpmml.model.annotations.Property("id")
        String id) {
        this.id = id;
        return this;
    }

    public Integer requireNumberOfSets() {
        if (this.numberOfSets == null) {
            throw new MissingAttributeException(this, PMMLAttributes.SEQUENCERULE_NUMBEROFSETS);
        }
        return this.numberOfSets;
    }

    public Integer getNumberOfSets() {
        return numberOfSets;
    }

    public SequenceRule setNumberOfSets(
        @org.jpmml.model.annotations.Property("numberOfSets")
        Integer numberOfSets) {
        this.numberOfSets = numberOfSets;
        return this;
    }

    public Integer requireOccurrence() {
        if (this.occurrence == null) {
            throw new MissingAttributeException(this, PMMLAttributes.SEQUENCERULE_OCCURRENCE);
        }
        return this.occurrence;
    }

    public Integer getOccurrence() {
        return occurrence;
    }

    public SequenceRule setOccurrence(
        @org.jpmml.model.annotations.Property("occurrence")
        Integer occurrence) {
        this.occurrence = occurrence;
        return this;
    }

    public Number requireSupport() {
        if (this.support == null) {
            throw new MissingAttributeException(this, PMMLAttributes.SEQUENCERULE_SUPPORT);
        }
        return this.support;
    }

    public Number getSupport() {
        return support;
    }

    public SequenceRule setSupport(
        @org.jpmml.model.annotations.Property("support")
        Number support) {
        this.support = support;
        return this;
    }

    public Number requireConfidence() {
        if (this.confidence == null) {
            throw new MissingAttributeException(this, PMMLAttributes.SEQUENCERULE_CONFIDENCE);
        }
        return this.confidence;
    }

    public Number getConfidence() {
        return confidence;
    }

    public SequenceRule setConfidence(
        @org.jpmml.model.annotations.Property("confidence")
        Number confidence) {
        this.confidence = confidence;
        return this;
    }

    public Number getLift() {
        return lift;
    }

    public SequenceRule setLift(
        @org.jpmml.model.annotations.Property("lift")
        Number lift) {
        this.lift = lift;
        return this;
    }

    public boolean hasContent() {
        return ((this.content!= null)&&(!this.content.isEmpty()));
    }

    public List getContent() {
        if (content == null) {
            content = new ArrayList();
        }
        return this.content;
    }

    public SequenceRule addContent(Object... content) {
        getContent().addAll(Arrays.asList(content));
        return this;
    }

    @Override
    public VisitorAction accept(Visitor visitor) {
        VisitorAction status = visitor.visit(this);
        if (status == VisitorAction.CONTINUE) {
            visitor.pushParent(this);
            if ((status == VisitorAction.CONTINUE)&&hasContent()) {
                status = PMMLObject.traverseMixed(visitor, getContent());
            }
            visitor.popParent();
        }
        if (status == VisitorAction.TERMINATE) {
            return VisitorAction.TERMINATE;
        }
        return VisitorAction.CONTINUE;
    }

}