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 javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.dmg.pmml.adapters.FieldNameAdapter;
import org.dmg.pmml.adapters.RealNumberAdapter;
import org.jpmml.model.annotations.Property;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "extensions",
    "targetValues"
})
@XmlRootElement(name = "Target", namespace = "http://www.dmg.org/PMML-4_3")
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonPropertyOrder({
    "field",
    "opType",
    "castInteger",
    "min",
    "max",
    "rescaleConstant",
    "rescaleFactor",
    "extensions",
    "targetValues"
})
public class Target
    extends org.dmg.pmml.PMMLObject
    implements HasExtensions , HasFieldReference , HasOpType , Indexable
{

    @XmlAttribute(name = "field")
    @XmlJavaTypeAdapter(FieldNameAdapter.class)
    @org.jpmml.model.annotations.Optional((org.dmg.pmml.Version.PMML_4_3))
    @JsonProperty("field")
    private org.dmg.pmml.FieldName 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_3")
    @JsonProperty("Extension")
    private List extensions;
    @XmlElement(name = "TargetValue", namespace = "http://www.dmg.org/PMML-4_3")
    @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 = 67305489L;

    @Override
    public org.dmg.pmml.FieldName getKey() {
        return getField();
    }

    @Override
    public org.dmg.pmml.FieldName getField() {
        return field;
    }

    @Override
    public Target setField(
        @Property("field")
        org.dmg.pmml.FieldName 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.size()> 0));
    }

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

    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 String value;

        CastInteger(String v) {
            value = v;
        }

        @Override
        public String value() {
            return value;
        }

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

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

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy