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

org.dmg.pmml.Target Maven / Gradle / Ivy

There is a newer version: 1.6.5
Show newest version

package org.dmg.pmml;

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.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlEnum;
import jakarta.xml.bind.annotation.XmlEnumValue;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.dmg.pmml.adapters.FieldNameAdapter;
import org.dmg.pmml.adapters.RealNumberAdapter;
import org.jpmml.model.annotations.Property;

@XmlRootElement(name = "Target", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
    "extensions",
    "targetValues"
})
@JsonRootName("Target")
@JsonPropertyOrder({
    "field",
    "opType",
    "castInteger",
    "min",
    "max",
    "rescaleConstant",
    "rescaleFactor",
    "extensions",
    "targetValues"
})
public class Target
    extends org.dmg.pmml.PMMLObject
    implements HasExtensions , HasOpType , HasTargetFieldReference , Indexable
{

    @XmlAttribute(name = "field")
    @XmlJavaTypeAdapter(FieldNameAdapter.class)
    @org.jpmml.model.annotations.Optional((org.dmg.pmml.Version.PMML_4_3))
    @JsonProperty("field")
    private java.lang.String field;
    @XmlAttribute(name = "optype")
    @JsonProperty("optype")
    private OpType opType;
    @XmlAttribute(name = "castInteger")
    @JsonProperty("castInteger")
    private Target.CastInteger castInteger;
    @XmlAttribute(name = "min")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_3_1))
    @JsonProperty("min")
    private Number min;
    @XmlAttribute(name = "max")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_3_1))
    @JsonProperty("max")
    private Number max;
    @XmlAttribute(name = "rescaleConstant")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_3_1))
    @JsonProperty("rescaleConstant")
    private Number rescaleConstant;
    @XmlAttribute(name = "rescaleFactor")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_3_1))
    @JsonProperty("rescaleFactor")
    private Number rescaleFactor;
    @XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("Extension")
    private List extensions;
    @XmlElement(name = "TargetValue", namespace = "http://www.dmg.org/PMML-4_4")
    @org.jpmml.model.annotations.Optional((org.dmg.pmml.Version.PMML_3_1))
    @JsonProperty("TargetValue")
    private List targetValues;
    private final static Number DEFAULT_RESCALE_CONSTANT = new RealNumberAdapter().unmarshal("0");
    private final static Number DEFAULT_RESCALE_FACTOR = new RealNumberAdapter().unmarshal("1");
    private final static long serialVersionUID = 67371270L;

    @Override
    public java.lang.String getKey() {
        return getTargetField();
    }

    @Override
    public java.lang.String getTargetField() {
        return getField();
    }

    @Override
    public Target setTargetField(java.lang.String targetField) {
        return setField(targetField);
    }

    public java.lang.String getField() {
        return field;
    }

    public Target setField(
        @Property("field")
        java.lang.String field) {
        this.field = field;
        return this;
    }

    @Override
    public OpType getOpType() {
        return opType;
    }

    @Override
    public Target setOpType(
        @Property("opType")
        OpType opType) {
        this.opType = opType;
        return this;
    }

    public Target.CastInteger getCastInteger() {
        return castInteger;
    }

    public Target setCastInteger(
        @Property("castInteger")
        Target.CastInteger castInteger) {
        this.castInteger = castInteger;
        return this;
    }

    public Number getMin() {
        return min;
    }

    public Target setMin(
        @Property("min")
        Number min) {
        this.min = min;
        return this;
    }

    public Number getMax() {
        return max;
    }

    public Target setMax(
        @Property("max")
        Number max) {
        this.max = max;
        return this;
    }

    public Number getRescaleConstant() {
        if (rescaleConstant == null) {
            return DEFAULT_RESCALE_CONSTANT;
        } else {
            return rescaleConstant;
        }
    }

    public Target setRescaleConstant(
        @Property("rescaleConstant")
        Number rescaleConstant) {
        this.rescaleConstant = rescaleConstant;
        return this;
    }

    public Number getRescaleFactor() {
        if (rescaleFactor == null) {
            return DEFAULT_RESCALE_FACTOR;
        } else {
            return rescaleFactor;
        }
    }

    public Target setRescaleFactor(
        @Property("rescaleFactor")
        Number rescaleFactor) {
        this.rescaleFactor = rescaleFactor;
        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 Target addExtensions(Extension... extensions) {
        getExtensions().addAll(Arrays.asList(extensions));
        return this;
    }

    public boolean hasTargetValues() {
        return ((this.targetValues!= null)&&(!this.targetValues.isEmpty()));
    }

    public List getTargetValues() {
        if (targetValues == null) {
            targetValues = new ArrayList();
        }
        return this.targetValues;
    }

    public Target addTargetValues(TargetValue... targetValues) {
        getTargetValues().addAll(Arrays.asList(targetValues));
        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)&&hasTargetValues()) {
                status = org.dmg.pmml.PMMLObject.traverse(visitor, getTargetValues());
            }
            visitor.popParent();
        }
        if (status == VisitorAction.TERMINATE) {
            return VisitorAction.TERMINATE;
        }
        return VisitorAction.CONTINUE;
    }

    @XmlType(name = "")
    @XmlEnum
    public enum CastInteger
        implements StringValue
    {

        @XmlEnumValue("round")
        @JsonProperty("round")
        ROUND("round"),
        @XmlEnumValue("ceiling")
        @JsonProperty("ceiling")
        CEILING("ceiling"),
        @XmlEnumValue("floor")
        @JsonProperty("floor")
        FLOOR("floor");
        private final java.lang.String value;

        CastInteger(java.lang.String v) {
            value = v;
        }

        @Override
        public java.lang.String value() {
            return value;
        }

        public static Target.CastInteger fromValue(java.lang.String v) {
            for (Target.CastInteger c: Target.CastInteger.values()) {
                if (c.value.equals(v)) {
                    return c;
                }
            }
            throw new IllegalArgumentException(v);
        }

        @Override
        public java.lang.String toString() {
            return value();
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy