[Major] Updates to Parameter interface
This commit is contained in:
parent
43eb6c7298
commit
7ce6375288
|
@ -73,13 +73,18 @@ public class BooleanParameter extends AbstractParameter<Boolean> {
|
|||
/**
|
||||
* Sets the value to false
|
||||
*
|
||||
* @see Parameter#clearValue()
|
||||
* @see Parameter#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return !this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return StrolchValueType.BOOLEAN.getType();
|
||||
|
|
|
@ -28,6 +28,7 @@ import li.strolch.utils.iso8601.ISO8601FormatFactory;
|
|||
public class DateParameter extends AbstractParameter<Date> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
private static final Date EMPTY_VALUE = ISO8601FormatFactory.getInstance().getDateFormat().parse("-");
|
||||
|
||||
private Date value;
|
||||
|
||||
|
@ -75,11 +76,16 @@ public class DateParameter extends AbstractParameter<Date> {
|
|||
/**
|
||||
* Sets the value to 1970-01-01 (unix time 0)
|
||||
*
|
||||
* @see Parameter#clearValue()
|
||||
* @see Parameter#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clearValue() {
|
||||
this.value = ISO8601FormatFactory.getInstance().getDateFormat().parse("-");
|
||||
public void clear() {
|
||||
this.value = EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.value.equals(EMPTY_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -68,13 +68,18 @@ public class DurationParameter extends AbstractParameter<Long> {
|
|||
/**
|
||||
* Sets the value to 0
|
||||
*
|
||||
* @see Parameter#clearValue()
|
||||
* @see Parameter#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value = 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.value == 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromString(String valueAsString) {
|
||||
setValue(parseFromString(valueAsString));
|
||||
|
|
|
@ -107,12 +107,12 @@ public class FloatListParameter extends AbstractParameter<List<Double>> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValueEmpty() {
|
||||
public boolean isEmpty() {
|
||||
return this.value.isEmpty();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,13 +69,18 @@ public class FloatParameter extends AbstractParameter<Double> {
|
|||
/**
|
||||
* Sets the value to 0
|
||||
*
|
||||
* @see Parameter#clearValue()
|
||||
* @see Parameter#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value = 0.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.value == 0.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromString(String valueAsString) {
|
||||
setValue(parseFromString(valueAsString));
|
||||
|
|
|
@ -107,12 +107,12 @@ public class IntegerListParameter extends AbstractParameter<List<Integer>> imple
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValueEmpty() {
|
||||
public boolean isEmpty() {
|
||||
return this.value.isEmpty();
|
||||
}
|
||||
|
||||
|
|
|
@ -73,13 +73,18 @@ public class IntegerParameter extends AbstractParameter<Integer> {
|
|||
/**
|
||||
* Sets the value to 0
|
||||
*
|
||||
* @see Parameter#clearValue()
|
||||
* @see Parameter#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.value == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromString(String valueAsString) {
|
||||
setValue(parseFromString(valueAsString));
|
||||
|
|
|
@ -48,12 +48,12 @@ public interface ListParameter<E> extends Parameter<List<E>> {
|
|||
/**
|
||||
* Clears the list of values, i.e the list of values is empty after this call
|
||||
*/
|
||||
public void clearValue();
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* Returns true if the list of values is empty, false if not
|
||||
*
|
||||
* @returns true if the list of values is empty, false if not
|
||||
*/
|
||||
public boolean isValueEmpty();
|
||||
public boolean isEmpty();
|
||||
}
|
||||
|
|
|
@ -107,12 +107,12 @@ public class LongListParameter extends AbstractParameter<List<Long>> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValueEmpty() {
|
||||
public boolean isEmpty() {
|
||||
return this.value.isEmpty();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,13 +68,18 @@ public class LongParameter extends AbstractParameter<Long> {
|
|||
/**
|
||||
* Sets the value to 0
|
||||
*
|
||||
* @see Parameter#clearValue()
|
||||
* @see Parameter#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value = 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.value == 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromString(String valueAsString) {
|
||||
setValue(parseFromString(valueAsString));
|
||||
|
|
|
@ -57,7 +57,13 @@ public interface Parameter<T> extends StrolchElement, Comparable<Parameter<?>> {
|
|||
/**
|
||||
* Clears the value, dependent on the concrete class
|
||||
*/
|
||||
public void clearValue();
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* @return true if the value is empty, i.e. if the value is the same as the value which would be set if
|
||||
* {@link #clear()} was called
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
|
||||
/**
|
||||
* get the hidden attribute
|
||||
|
|
|
@ -107,12 +107,12 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValueEmpty() {
|
||||
public boolean isEmpty() {
|
||||
return this.value.isEmpty();
|
||||
}
|
||||
|
||||
|
|
|
@ -74,10 +74,10 @@ public class StringParameter extends AbstractParameter<String> {
|
|||
/**
|
||||
* Sets the value to the empty string
|
||||
*
|
||||
* @see Parameter#clearValue()
|
||||
* @see Parameter#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clearValue() {
|
||||
public void clear() {
|
||||
this.value = "";
|
||||
}
|
||||
|
||||
|
|
|
@ -482,7 +482,7 @@ public class ModelTest {
|
|||
assertEquals("a, b", stringListP.getValueAsString());
|
||||
stringListP.setValueFromString("a,b");
|
||||
assertEquals("a, b", stringListP.getValueAsString());
|
||||
stringListP.clearValue();
|
||||
stringListP.clear();
|
||||
assertEquals("", stringListP.getValueAsString());
|
||||
stringListP.addValue("a");
|
||||
assertEquals("a", stringListP.getValueAsString());
|
||||
|
@ -499,7 +499,7 @@ public class ModelTest {
|
|||
assertEquals("4, 45", intListP.getValueAsString());
|
||||
intListP.setValueFromString("4,45");
|
||||
assertEquals("4, 45", intListP.getValueAsString());
|
||||
intListP.clearValue();
|
||||
intListP.clear();
|
||||
assertEquals("", intListP.getValueAsString());
|
||||
intListP.addValue(55);
|
||||
assertEquals("55", intListP.getValueAsString());
|
||||
|
@ -516,7 +516,7 @@ public class ModelTest {
|
|||
assertEquals("4.2, 4.1", floatListP.getValueAsString());
|
||||
floatListP.setValueFromString("4.2,4.1");
|
||||
assertEquals("4.2, 4.1", floatListP.getValueAsString());
|
||||
floatListP.clearValue();
|
||||
floatListP.clear();
|
||||
assertEquals("", floatListP.getValueAsString());
|
||||
floatListP.addValue(55.5);
|
||||
assertEquals("55.5", floatListP.getValueAsString());
|
||||
|
@ -533,7 +533,7 @@ public class ModelTest {
|
|||
assertEquals("4, 4", longListP.getValueAsString());
|
||||
longListP.setValueFromString("4,4");
|
||||
assertEquals("4, 4", longListP.getValueAsString());
|
||||
longListP.clearValue();
|
||||
longListP.clear();
|
||||
assertEquals("", longListP.getValueAsString());
|
||||
longListP.addValue(55L);
|
||||
assertEquals("55", longListP.getValueAsString());
|
||||
|
|
Loading…
Reference in New Issue