org.dmg.pmml.time_series.TimeSeries Maven / Gradle / Ivy
package org.dmg.pmml.time_series;
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.StringValue;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.RealNumberAdapter;
import org.jpmml.model.annotations.Added;
import org.jpmml.model.annotations.Property;
import org.jpmml.model.annotations.Removed;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"timeAnchor",
"timeExceptions",
"timeValues"
})
@XmlRootElement(name = "TimeSeries", namespace = "http://www.dmg.org/PMML-4_3")
@Added((org.dmg.pmml.Version.PMML_4_0))
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonPropertyOrder({
"usage",
"startTime",
"endTime",
"interpolationMethod",
"timeAnchor",
"timeExceptions",
"timeValues"
})
public class TimeSeries
extends org.dmg.pmml.PMMLObject
{
@XmlAttribute(name = "usage")
@JsonProperty("usage")
private TimeSeries.Usage usage;
@XmlAttribute(name = "startTime")
@XmlJavaTypeAdapter(RealNumberAdapter.class)
@JsonProperty("startTime")
private Number startTime;
@XmlAttribute(name = "endTime")
@XmlJavaTypeAdapter(RealNumberAdapter.class)
@JsonProperty("endTime")
private Number endTime;
@XmlAttribute(name = "interpolationMethod")
@JsonProperty("interpolationMethod")
private TimeSeries.InterpolationMethod interpolationMethod;
@XmlElement(name = "TimeAnchor", namespace = "http://www.dmg.org/PMML-4_3")
@JsonProperty("TimeAnchor")
private TimeAnchor timeAnchor;
@XmlElement(name = "TimeException", namespace = "http://www.dmg.org/PMML-4_3")
@Removed((org.dmg.pmml.Version.PMML_4_1))
@JsonProperty("TimeException")
private List timeExceptions;
@XmlElement(name = "TimeValue", namespace = "http://www.dmg.org/PMML-4_3")
@JsonProperty("TimeValue")
private List timeValues;
private final static long serialVersionUID = 67305489L;
public TimeSeries.Usage getUsage() {
if (usage == null) {
return TimeSeries.Usage.ORIGINAL;
} else {
return usage;
}
}
public TimeSeries setUsage(
@Property("usage")
TimeSeries.Usage usage) {
this.usage = usage;
return this;
}
public Number getStartTime() {
return startTime;
}
public TimeSeries setStartTime(
@Property("startTime")
Number startTime) {
this.startTime = startTime;
return this;
}
public Number getEndTime() {
return endTime;
}
public TimeSeries setEndTime(
@Property("endTime")
Number endTime) {
this.endTime = endTime;
return this;
}
public TimeSeries.InterpolationMethod getInterpolationMethod() {
if (interpolationMethod == null) {
return TimeSeries.InterpolationMethod.NONE;
} else {
return interpolationMethod;
}
}
public TimeSeries setInterpolationMethod(
@Property("interpolationMethod")
TimeSeries.InterpolationMethod interpolationMethod) {
this.interpolationMethod = interpolationMethod;
return this;
}
public TimeAnchor getTimeAnchor() {
return timeAnchor;
}
public TimeSeries setTimeAnchor(
@Property("timeAnchor")
TimeAnchor timeAnchor) {
this.timeAnchor = timeAnchor;
return this;
}
public boolean hasTimeExceptions() {
return ((this.timeExceptions!= null)&&(this.timeExceptions.size()> 0));
}
public List getTimeExceptions() {
if (timeExceptions == null) {
timeExceptions = new ArrayList();
}
return this.timeExceptions;
}
public TimeSeries addTimeExceptions(TimeException... timeExceptions) {
getTimeExceptions().addAll(Arrays.asList(timeExceptions));
return this;
}
public boolean hasTimeValues() {
return ((this.timeValues!= null)&&(this.timeValues.size()> 0));
}
public List getTimeValues() {
if (timeValues == null) {
timeValues = new ArrayList();
}
return this.timeValues;
}
public TimeSeries addTimeValues(TimeValue... timeValues) {
getTimeValues().addAll(Arrays.asList(timeValues));
return this;
}
@Override
public VisitorAction accept(Visitor visitor) {
VisitorAction status = visitor.visit(this);
if (status == VisitorAction.CONTINUE) {
visitor.pushParent(this);
if (status == VisitorAction.CONTINUE) {
status = org.dmg.pmml.PMMLObject.traverse(visitor, getTimeAnchor());
}
if ((status == VisitorAction.CONTINUE)&&hasTimeExceptions()) {
status = org.dmg.pmml.PMMLObject.traverse(visitor, getTimeExceptions());
}
if ((status == VisitorAction.CONTINUE)&&hasTimeValues()) {
status = org.dmg.pmml.PMMLObject.traverse(visitor, getTimeValues());
}
visitor.popParent();
}
if (status == VisitorAction.TERMINATE) {
return VisitorAction.TERMINATE;
}
return VisitorAction.CONTINUE;
}
@XmlType(name = "")
@XmlEnum
public enum InterpolationMethod
implements StringValue
{
@XmlEnumValue("none")
@JsonProperty("none")
NONE("none"),
@XmlEnumValue("linear")
@JsonProperty("linear")
LINEAR("linear"),
@XmlEnumValue("exponentialSpline")
@JsonProperty("exponentialSpline")
EXPONENTIAL_SPLINE("exponentialSpline"),
@XmlEnumValue("cubicSpline")
@JsonProperty("cubicSpline")
CUBIC_SPLINE("cubicSpline");
private final String value;
InterpolationMethod(String v) {
value = v;
}
@Override
public String value() {
return value;
}
public static TimeSeries.InterpolationMethod fromValue(String v) {
for (TimeSeries.InterpolationMethod c: TimeSeries.InterpolationMethod.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
@Override
public String toString() {
return value();
}
}
@XmlType(name = "")
@XmlEnum
public enum Usage
implements StringValue
{
@XmlEnumValue("original")
@JsonProperty("original")
ORIGINAL("original"),
@XmlEnumValue("logical")
@JsonProperty("logical")
LOGICAL("logical"),
@XmlEnumValue("prediction")
@JsonProperty("prediction")
PREDICTION("prediction");
private final String value;
Usage(String v) {
value = v;
}
@Override
public String value() {
return value;
}
public static TimeSeries.Usage fromValue(String v) {
for (TimeSeries.Usage c: TimeSeries.Usage.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
@Override
public String toString() {
return value();
}
}
}