argos/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BaseFieldDataEntity.java

45 lines
985 B
Java

package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldType;
import eu.eudat.commons.types.xml.XmlSerializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.Map;
public abstract class BaseFieldDataEntity<T> implements XmlSerializable<T> {
private final FieldType fieldType;
public BaseFieldDataEntity(FieldType fieldType) {
this.fieldType = fieldType;
}
private String label;
public FieldType getFieldType() {
return fieldType;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
public T fromXml(Element item) {
this.setLabel(item.getAttribute("label"));
return (T) this;
}
}