[New] Added StringParameter(Enum<?>) and .setValue(Enum<?>)
This commit is contained in:
parent
198030f130
commit
d09fb9fa4b
|
@ -15,6 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package li.strolch.model.parameter;
|
package li.strolch.model.parameter;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.model.StrolchValueType;
|
import li.strolch.model.StrolchValueType;
|
||||||
import li.strolch.model.visitor.StrolchElementVisitor;
|
import li.strolch.model.visitor.StrolchElementVisitor;
|
||||||
import li.strolch.utils.dbc.DBC;
|
import li.strolch.utils.dbc.DBC;
|
||||||
|
@ -48,6 +51,21 @@ public class StringParameter extends AbstractParameter<String> {
|
||||||
setValue(value);
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* the id
|
||||||
|
* @param name
|
||||||
|
* the name
|
||||||
|
* @param value
|
||||||
|
* the value
|
||||||
|
*/
|
||||||
|
public StringParameter(String id, String name, Enum<?> value) {
|
||||||
|
super(id, name);
|
||||||
|
setValueE(value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return StrolchValueType.STRING.getType();
|
return StrolchValueType.STRING.getType();
|
||||||
|
@ -76,6 +94,17 @@ public class StringParameter extends AbstractParameter<String> {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setValueE(Enum<?> value) {
|
||||||
|
assertNotReadonly();
|
||||||
|
if (value == null) {
|
||||||
|
String msg = "Can not set null value on Parameter {0}"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, getLocator());
|
||||||
|
throw new StrolchException(msg);
|
||||||
|
}
|
||||||
|
validateValue(value.name());
|
||||||
|
this.value = value.name();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValueFrom(Parameter<String> parameter) {
|
public void setValueFrom(Parameter<String> parameter) {
|
||||||
assertNotReadonly();
|
assertNotReadonly();
|
||||||
|
|
Loading…
Reference in New Issue