org.dmg.pmml.Aggregate Maven / Gradle / Ivy
package org.dmg.pmml;
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.adapters.FieldNameAdapter;
import org.jpmml.model.annotations.ValueConstructor;
@XmlRootElement(name = "Aggregate", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
"extensions"
})
@JsonRootName("Aggregate")
@JsonPropertyOrder({
"field",
"function",
"groupField",
"sqlWhere",
"extensions"
})
public class Aggregate
extends Expression
implements HasExtensions , HasFieldReference
{
@XmlAttribute(name = "field", required = true)
@XmlJavaTypeAdapter(FieldNameAdapter.class)
@JsonProperty("field")
private FieldName field;
@XmlAttribute(name = "function", required = true)
@JsonProperty("function")
private Aggregate.Function function;
@XmlAttribute(name = "groupField")
@XmlJavaTypeAdapter(FieldNameAdapter.class)
@JsonProperty("groupField")
private FieldName groupField;
@XmlAttribute(name = "sqlWhere")
@JsonProperty("sqlWhere")
private String sqlWhere;
@XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_4")
@JsonProperty("Extension")
private List extensions;
private final static long serialVersionUID = 67371009L;
public Aggregate() {
}
@ValueConstructor
public Aggregate(
@org.jpmml.model.annotations.Property("field")
FieldName field,
@org.jpmml.model.annotations.Property("function")
Aggregate.Function function) {
this.field = field;
this.function = function;
}
@Override
public FieldName getField() {
return field;
}
@Override
public Aggregate setField(
@org.jpmml.model.annotations.Property("field")
FieldName field) {
this.field = field;
return this;
}
public Aggregate.Function getFunction() {
return function;
}
public Aggregate setFunction(
@org.jpmml.model.annotations.Property("function")
Aggregate.Function function) {
this.function = function;
return this;
}
public FieldName getGroupField() {
return groupField;
}
public Aggregate setGroupField(
@org.jpmml.model.annotations.Property("groupField")
FieldName groupField) {
this.groupField = groupField;
return this;
}
public String getSqlWhere() {
return sqlWhere;
}
public Aggregate setSqlWhere(
@org.jpmml.model.annotations.Property("sqlWhere")
String sqlWhere) {
this.sqlWhere = sqlWhere;
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 Aggregate 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;
}
@XmlType(name = "")
@XmlEnum
public enum Function
implements StringValue
{
@XmlEnumValue("count")
@JsonProperty("count")
COUNT("count"),
@XmlEnumValue("sum")
@JsonProperty("sum")
SUM("sum"),
@XmlEnumValue("average")
@JsonProperty("average")
AVERAGE("average"),
@XmlEnumValue("min")
@JsonProperty("min")
MIN("min"),
@XmlEnumValue("max")
@JsonProperty("max")
MAX("max"),
@XmlEnumValue("multiset")
@JsonProperty("multiset")
MULTISET("multiset");
private final String value;
Function(String v) {
value = v;
}
@Override
public String value() {
return value;
}
public static Aggregate.Function fromValue(String v) {
for (Aggregate.Function c: Aggregate.Function.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
@Override
public String toString() {
return value();
}
}
}