org.dmg.pmml.regression.CategoricalPredictor Maven / Gradle / Ivy
package org.dmg.pmml.regression;
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.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
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 org.dmg.pmml.Extension;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.HasFieldReference;
import org.dmg.pmml.HasValue;
import org.dmg.pmml.PMMLObject;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.FieldNameAdapter;
import org.dmg.pmml.adapters.ObjectAdapter;
import org.dmg.pmml.adapters.RealNumberAdapter;
import org.jpmml.model.annotations.ValueConstructor;
@XmlRootElement(name = "CategoricalPredictor", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
"extensions"
})
@JsonRootName("CategoricalPredictor")
@JsonPropertyOrder({
"field",
"value",
"coefficient",
"extensions"
})
public class CategoricalPredictor
extends Term
implements HasExtensions , HasFieldReference , HasValue
{
@XmlAttribute(name = "name", required = true)
@XmlJavaTypeAdapter(FieldNameAdapter.class)
@JsonProperty("name")
private org.dmg.pmml.FieldName field;
@XmlAttribute(name = "value", required = true)
@XmlJavaTypeAdapter(ObjectAdapter.class)
@XmlSchemaType(name = "anySimpleType")
@JsonProperty("value")
private Object value;
@XmlAttribute(name = "coefficient", required = true)
@XmlJavaTypeAdapter(RealNumberAdapter.class)
@JsonProperty("coefficient")
private Number coefficient;
@XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_4")
@JsonProperty("Extension")
private List extensions;
private final static long serialVersionUID = 67371009L;
public CategoricalPredictor() {
}
@ValueConstructor
public CategoricalPredictor(
@org.jpmml.model.annotations.Property("field")
org.dmg.pmml.FieldName field,
@org.jpmml.model.annotations.Property("value")
Object value,
@org.jpmml.model.annotations.Property("coefficient")
Number coefficient) {
this.field = field;
this.value = value;
this.coefficient = coefficient;
}
@Override
public org.dmg.pmml.FieldName getName() {
return getField();
}
@Override
public CategoricalPredictor setName(org.dmg.pmml.FieldName name) {
return setField(name);
}
@Override
public org.dmg.pmml.FieldName getField() {
return field;
}
@Override
public CategoricalPredictor setField(
@org.jpmml.model.annotations.Property("field")
org.dmg.pmml.FieldName field) {
this.field = field;
return this;
}
@Override
public Object getValue() {
return value;
}
@Override
public CategoricalPredictor setValue(
@org.jpmml.model.annotations.Property("value")
Object value) {
this.value = value;
return this;
}
public Number getCoefficient() {
return coefficient;
}
public CategoricalPredictor setCoefficient(
@org.jpmml.model.annotations.Property("coefficient")
Number coefficient) {
this.coefficient = coefficient;
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 CategoricalPredictor addExtensions(Extension... extensions) {
getExtensions().addAll(Arrays.asList(extensions));
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 = PMMLObject.traverse(visitor, getExtensions());
}
visitor.popParent();
}
if (status == VisitorAction.TERMINATE) {
return VisitorAction.TERMINATE;
}
return VisitorAction.CONTINUE;
}
}