org.dmg.pmml.clustering.ClusteringField Maven / Gradle / Ivy
package org.dmg.pmml.clustering;
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 org.dmg.pmml.CompareFunction;
import org.dmg.pmml.ComparisonField;
import org.dmg.pmml.Extension;
import org.dmg.pmml.FieldName;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.PMMLObject;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.FieldNameAdapter;
import org.jpmml.schema.Added;
import org.jpmml.schema.Version;
/**
* Java class for anonymous complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{http://www.dmg.org/PMML-4_3}Extension" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_3}Comparisons" minOccurs="0"/>
* </sequence>
* <attribute name="field" use="required" type="{http://www.dmg.org/PMML-4_3}FIELD-NAME" />
* <attribute name="isCenterField" default="true">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="true"/>
* <enumeration value="false"/>
* </restriction>
* </simpleType>
* </attribute>
* <attribute name="fieldWeight" type="{http://www.dmg.org/PMML-4_3}REAL-NUMBER" default="1" />
* <attribute name="similarityScale" type="{http://www.dmg.org/PMML-4_3}REAL-NUMBER" />
* <attribute name="compareFunction" type="{http://www.dmg.org/PMML-4_3}COMPARE-FUNCTION" />
* </restriction>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"extensions",
"comparisons"
})
@XmlRootElement(name = "ClusteringField", namespace = "http://www.dmg.org/PMML-4_3")
public class ClusteringField
extends ComparisonField
implements HasExtensions
{
@XmlAttribute(name = "field", required = true)
@XmlJavaTypeAdapter(FieldNameAdapter.class)
private FieldName field;
@XmlAttribute(name = "isCenterField")
@Added(Version.PMML_3_2)
private ClusteringField.CenterField centerField;
@XmlAttribute(name = "fieldWeight")
private Double fieldWeight;
@XmlAttribute(name = "similarityScale")
private Double similarityScale;
@XmlAttribute(name = "compareFunction")
private CompareFunction compareFunction;
@XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_3")
private List extensions;
@XmlElement(name = "Comparisons", namespace = "http://www.dmg.org/PMML-4_3")
private Comparisons comparisons;
private final static Double DEFAULT_FIELD_WEIGHT = 1.0D;
public ClusteringField() {
super();
}
public ClusteringField(final FieldName field) {
super();
this.field = field;
}
/**
* Gets the value of the field property.
*
* @return
* possible object is
* {@link String }
*
*/
public FieldName getField() {
return field;
}
/**
* Sets the value of the field property.
*
* @param field
* allowed object is
* {@link String }
*
*/
public ClusteringField setField(FieldName field) {
this.field = field;
return this;
}
/**
* Gets the value of the centerField property.
*
* @return
* possible object is
* {@link ClusteringField.CenterField }
*
*/
public ClusteringField.CenterField getCenterField() {
if (centerField == null) {
return ClusteringField.CenterField.TRUE;
} else {
return centerField;
}
}
/**
* Sets the value of the centerField property.
*
* @param centerField
* allowed object is
* {@link ClusteringField.CenterField }
*
*/
public ClusteringField setCenterField(ClusteringField.CenterField centerField) {
this.centerField = centerField;
return this;
}
/**
* Gets the value of the fieldWeight property.
*
* @return
* possible object is
* {@link Double }
*
*/
public Double getFieldWeight() {
if (fieldWeight == null) {
return DEFAULT_FIELD_WEIGHT;
} else {
return fieldWeight;
}
}
/**
* Sets the value of the fieldWeight property.
*
* @param fieldWeight
* allowed object is
* {@link Double }
*
*/
public ClusteringField setFieldWeight(Double fieldWeight) {
this.fieldWeight = fieldWeight;
return this;
}
/**
* Gets the value of the similarityScale property.
*
* @return
* possible object is
* {@link Double }
*
*/
public Double getSimilarityScale() {
return similarityScale;
}
/**
* Sets the value of the similarityScale property.
*
* @param similarityScale
* allowed object is
* {@link Double }
*
*/
public ClusteringField setSimilarityScale(Double similarityScale) {
this.similarityScale = similarityScale;
return this;
}
/**
* Gets the value of the compareFunction property.
*
* @return
* possible object is
* {@link CompareFunction }
*
*/
public CompareFunction getCompareFunction() {
return compareFunction;
}
/**
* Sets the value of the compareFunction property.
*
* @param compareFunction
* allowed object is
* {@link CompareFunction }
*
*/
public ClusteringField setCompareFunction(CompareFunction compareFunction) {
this.compareFunction = compareFunction;
return this;
}
/**
* Gets the value of the extensions property.
*
*
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a set
method for the extensions property.
*
*
* For example, to add a new item, do as follows:
*
* getExtensions().add(newItem);
*
*
*
*
* Objects of the following type(s) are allowed in the list
* {@link Extension }
*
*
*/
public List getExtensions() {
if (extensions == null) {
extensions = new ArrayList();
}
return this.extensions;
}
/**
* Gets the value of the comparisons property.
*
* @return
* possible object is
* {@link Comparisons }
*
*/
public Comparisons getComparisons() {
return comparisons;
}
/**
* Sets the value of the comparisons property.
*
* @param comparisons
* allowed object is
* {@link Comparisons }
*
*/
public ClusteringField setComparisons(Comparisons comparisons) {
this.comparisons = comparisons;
return this;
}
public boolean hasExtensions() {
return ((this.extensions!= null)&&(this.extensions.size()> 0));
}
public ClusteringField 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());
}
if (status == VisitorAction.CONTINUE) {
status = PMMLObject.traverse(visitor, getComparisons());
}
visitor.popParent();
}
if (status == VisitorAction.TERMINATE) {
return VisitorAction.TERMINATE;
}
return VisitorAction.CONTINUE;
}
/**
* Java class for null.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="true"/>
* <enumeration value="false"/>
* </restriction>
* </simpleType>
*
*
*/
@XmlType(name = "")
@XmlEnum
@Added(Version.PMML_3_2)
public enum CenterField {
@XmlEnumValue("true")
TRUE("true"),
@XmlEnumValue("false")
FALSE("false");
private final String value;
CenterField(String v) {
value = v;
}
public String value() {
return value;
}
public static ClusteringField.CenterField fromValue(String v) {
for (ClusteringField.CenterField c: ClusteringField.CenterField.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
}