
com.bebound.plugins.beapp.model.parameter.EnumParameter Maven / Gradle / Ivy
package com.bebound.plugins.beapp.model.parameter;
import com.bebound.plugins.beapp.model.C;
import com.bebound.plugins.beapp.model.Enumeration;
import java.util.HashMap;
/**
* Authorized value type : String
*/
public class EnumParameter extends Parameter {
private Enumeration enumeration;
private String enumerationName;
private String key;
private Integer value;
public EnumParameter(HashMap xmlAttributes) {
super(xmlAttributes);
}
public int getValue() {
computeValue();
return value;
}
public String getEnumerationName() {
return enumerationName;
}
public EnumParameter setEnumerationName(String enumerationName) {
this.enumerationName = enumerationName;
return this;
}
public Enumeration getEnumeration() {
return enumeration;
}
public EnumParameter setEnumeration(Enumeration enumeration) {
this.enumeration = enumeration;
return this;
}
public String getKey() {
return key;
}
@Override
public Parameter parseAttributes() {
if (attributes.containsKey(C.Xml.ATTR_ENUM_REFERENCES))
setEnumerationName(attributes.get(C.Xml.ATTR_ENUM_REFERENCES));
return this;
}
public EnumParameter setKey(String value) {
this.key = value;
return this;
}
private EnumParameter computeValue() {
if (enumeration != null && key != null) {
if (enumeration.getValues().contains(key)) {
value = enumeration.getValues().indexOf(key);
} else {
//TODO Exception value not in enum
}
} else {
//TODO Exception value or enum null
}
return this;
}
@Override
public boolean hasValue() {
return key != null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy