org.dmg.pmml.baseline.TestDistributions Maven / Gradle / Ivy
package org.dmg.pmml.baseline;
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.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.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
import org.dmg.pmml.Extension;
import org.dmg.pmml.FieldName;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.HasFieldReference;
import org.dmg.pmml.StringValue;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.FieldNameAdapter;
import org.dmg.pmml.adapters.IntegerAdapter;
import org.dmg.pmml.adapters.RealNumberAdapter;
import org.jpmml.model.annotations.Added;
import org.jpmml.model.annotations.ValueConstructor;
@XmlRootElement(name = "TestDistributions", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
"extensions",
"baseline",
"alternate"
})
@Added((org.dmg.pmml.Version.PMML_4_1))
@JsonRootName("TestDistributions")
@JsonPropertyOrder({
"field",
"testStatistic",
"resetValue",
"windowSize",
"weightField",
"normalizationScheme",
"extensions",
"baseline",
"alternate"
})
public class TestDistributions
extends org.dmg.pmml.PMMLObject
implements HasExtensions , HasFieldReference
{
@XmlAttribute(name = "field", required = true)
@XmlJavaTypeAdapter(FieldNameAdapter.class)
@JsonProperty("field")
private FieldName field;
@XmlAttribute(name = "testStatistic", required = true)
@JsonProperty("testStatistic")
private TestDistributions.TestStatistic testStatistic;
@XmlAttribute(name = "resetValue")
@XmlJavaTypeAdapter(RealNumberAdapter.class)
@JsonProperty("resetValue")
private Number resetValue;
@XmlAttribute(name = "windowSize")
@XmlJavaTypeAdapter(IntegerAdapter.class)
@JsonProperty("windowSize")
private Integer windowSize;
@XmlAttribute(name = "weightField")
@XmlJavaTypeAdapter(FieldNameAdapter.class)
@JsonProperty("weightField")
private FieldName weightField;
@XmlAttribute(name = "normalizationScheme")
@JsonProperty("normalizationScheme")
private String normalizationScheme;
@XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_4")
@JsonProperty("Extension")
private List extensions;
@XmlElement(name = "Baseline", namespace = "http://www.dmg.org/PMML-4_4", required = true)
@JsonProperty("Baseline")
private Baseline baseline;
@XmlElement(name = "Alternate", namespace = "http://www.dmg.org/PMML-4_4")
@JsonProperty("Alternate")
private Alternate alternate;
private final static Number DEFAULT_RESET_VALUE = new RealNumberAdapter().unmarshal("0.0");
private final static Integer DEFAULT_WINDOW_SIZE = new IntegerAdapter().unmarshal("0");
private final static long serialVersionUID = 67371267L;
public TestDistributions() {
}
@ValueConstructor
public TestDistributions(
@org.jpmml.model.annotations.Property("field")
FieldName field,
@org.jpmml.model.annotations.Property("testStatistic")
TestDistributions.TestStatistic testStatistic,
@org.jpmml.model.annotations.Property("baseline")
Baseline baseline) {
this.field = field;
this.testStatistic = testStatistic;
this.baseline = baseline;
}
@Override
public FieldName getField() {
return field;
}
@Override
public TestDistributions setField(
@org.jpmml.model.annotations.Property("field")
FieldName field) {
this.field = field;
return this;
}
public TestDistributions.TestStatistic getTestStatistic() {
return testStatistic;
}
public TestDistributions setTestStatistic(
@org.jpmml.model.annotations.Property("testStatistic")
TestDistributions.TestStatistic testStatistic) {
this.testStatistic = testStatistic;
return this;
}
public Number getResetValue() {
if (resetValue == null) {
return DEFAULT_RESET_VALUE;
} else {
return resetValue;
}
}
public TestDistributions setResetValue(
@org.jpmml.model.annotations.Property("resetValue")
Number resetValue) {
this.resetValue = resetValue;
return this;
}
public Integer getWindowSize() {
if (windowSize == null) {
return DEFAULT_WINDOW_SIZE;
} else {
return windowSize;
}
}
public TestDistributions setWindowSize(
@org.jpmml.model.annotations.Property("windowSize")
Integer windowSize) {
this.windowSize = windowSize;
return this;
}
public FieldName getWeightField() {
return weightField;
}
public TestDistributions setWeightField(
@org.jpmml.model.annotations.Property("weightField")
FieldName weightField) {
this.weightField = weightField;
return this;
}
public String getNormalizationScheme() {
return normalizationScheme;
}
public TestDistributions setNormalizationScheme(
@org.jpmml.model.annotations.Property("normalizationScheme")
String normalizationScheme) {
this.normalizationScheme = normalizationScheme;
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 TestDistributions addExtensions(Extension... extensions) {
getExtensions().addAll(Arrays.asList(extensions));
return this;
}
public Baseline getBaseline() {
return baseline;
}
public TestDistributions setBaseline(
@org.jpmml.model.annotations.Property("baseline")
Baseline baseline) {
this.baseline = baseline;
return this;
}
public Alternate getAlternate() {
return alternate;
}
public TestDistributions setAlternate(
@org.jpmml.model.annotations.Property("alternate")
Alternate alternate) {
this.alternate = alternate;
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) {
status = org.dmg.pmml.PMMLObject.traverse(visitor, getBaseline(), getAlternate());
}
visitor.popParent();
}
if (status == VisitorAction.TERMINATE) {
return VisitorAction.TERMINATE;
}
return VisitorAction.CONTINUE;
}
@XmlType(name = "")
@XmlEnum
public enum TestStatistic
implements StringValue
{
@XmlEnumValue("zValue")
@JsonProperty("zValue")
Z_VALUE("zValue"),
@XmlEnumValue("chiSquareIndependence")
@JsonProperty("chiSquareIndependence")
CHI_SQUARE_INDEPENDENCE("chiSquareIndependence"),
@XmlEnumValue("chiSquareDistribution")
@JsonProperty("chiSquareDistribution")
CHI_SQUARE_DISTRIBUTION("chiSquareDistribution"),
@JsonProperty("CUSUM")
CUSUM("CUSUM"),
@XmlEnumValue("scalarProduct")
@JsonProperty("scalarProduct")
SCALAR_PRODUCT("scalarProduct");
private final String value;
TestStatistic(String v) {
value = v;
}
@Override
public String value() {
return value;
}
public static TestDistributions.TestStatistic fromValue(String v) {
for (TestDistributions.TestStatistic c: TestDistributions.TestStatistic.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
@Override
public String toString() {
return value();
}
}
}