[Minor] Assert ListParameters do not get null values added
This commit is contained in:
parent
cb633081eb
commit
74a5e140df
|
@ -46,13 +46,13 @@ public class FloatListParameter extends AbstractParameter<List<Double>> implemen
|
|||
* the id
|
||||
* @param name
|
||||
* the name
|
||||
* @param value
|
||||
* the value
|
||||
* @param values
|
||||
* the values
|
||||
*/
|
||||
public FloatListParameter(String id, String name, List<Double> value) {
|
||||
public FloatListParameter(String id, String name, List<Double> values) {
|
||||
super(id, name);
|
||||
|
||||
setValue(value);
|
||||
setValue(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,10 +83,13 @@ public class FloatListParameter extends AbstractParameter<List<Double>> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setValue(List<Double> value) {
|
||||
public void setValue(List<Double> values) {
|
||||
assertNotReadonly();
|
||||
validateValue(value);
|
||||
this.value = new ArrayList<>(value);
|
||||
validateValue(values);
|
||||
for (Double value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
}
|
||||
this.value = new ArrayList<>(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,19 +106,24 @@ public class FloatListParameter extends AbstractParameter<List<Double>> implemen
|
|||
@Override
|
||||
public void addValue(Double value) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
this.value.add(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllValues(List<Double> values) {
|
||||
assertNotReadonly();
|
||||
this.value.addAll(values);
|
||||
for (Double value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
this.value.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllValuesIfNotContains(List<Double> values) {
|
||||
assertNotReadonly();
|
||||
for (Double value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
if (!this.value.contains(value))
|
||||
this.value.add(value);
|
||||
}
|
||||
|
@ -124,6 +132,7 @@ public class FloatListParameter extends AbstractParameter<List<Double>> implemen
|
|||
@Override
|
||||
public boolean addValueIfNotContains(Double value) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
|
||||
if (this.value.contains(value))
|
||||
return false;
|
||||
|
|
|
@ -83,10 +83,13 @@ public class IntegerListParameter extends AbstractParameter<List<Integer>> imple
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setValue(List<Integer> value) {
|
||||
public void setValue(List<Integer> values) {
|
||||
assertNotReadonly();
|
||||
validateValue(value);
|
||||
this.value = new ArrayList<>(value);
|
||||
validateValue(values);
|
||||
for (Integer value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
}
|
||||
this.value = new ArrayList<>(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,19 +106,24 @@ public class IntegerListParameter extends AbstractParameter<List<Integer>> imple
|
|||
@Override
|
||||
public void addValue(Integer value) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
this.value.add(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllValues(List<Integer> values) {
|
||||
assertNotReadonly();
|
||||
this.value.addAll(values);
|
||||
for (Integer value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
this.value.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllValuesIfNotContains(List<Integer> values) {
|
||||
assertNotReadonly();
|
||||
for (Integer value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
if (!this.value.contains(value))
|
||||
this.value.add(value);
|
||||
}
|
||||
|
@ -124,6 +132,7 @@ public class IntegerListParameter extends AbstractParameter<List<Integer>> imple
|
|||
@Override
|
||||
public boolean addValueIfNotContains(Integer value) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
|
||||
if (this.value.contains(value))
|
||||
return false;
|
||||
|
|
|
@ -83,10 +83,13 @@ public class LongListParameter extends AbstractParameter<List<Long>> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setValue(List<Long> value) {
|
||||
public void setValue(List<Long> values) {
|
||||
assertNotReadonly();
|
||||
validateValue(value);
|
||||
this.value = new ArrayList<>(value);
|
||||
validateValue(values);
|
||||
for (Long value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
}
|
||||
this.value = new ArrayList<>(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,12 +106,17 @@ public class LongListParameter extends AbstractParameter<List<Long>> implements
|
|||
@Override
|
||||
public void addValue(Long value) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
this.value.add(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllValues(List<Long> values) {
|
||||
assertNotReadonly();
|
||||
for (Long value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
this.value.add(value);
|
||||
}
|
||||
this.value.addAll(values);
|
||||
}
|
||||
|
||||
|
@ -116,6 +124,7 @@ public class LongListParameter extends AbstractParameter<List<Long>> implements
|
|||
public void addAllValuesIfNotContains(List<Long> values) {
|
||||
assertNotReadonly();
|
||||
for (Long value : values) {
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
if (!this.value.contains(value))
|
||||
this.value.add(value);
|
||||
}
|
||||
|
@ -124,6 +133,7 @@ public class LongListParameter extends AbstractParameter<List<Long>> implements
|
|||
@Override
|
||||
public boolean addValueIfNotContains(Long value) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("null values not allowed!", value);
|
||||
|
||||
if (this.value.contains(value))
|
||||
return false;
|
||||
|
|
|
@ -83,10 +83,13 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setValue(List<String> value) {
|
||||
public void setValue(List<String> values) {
|
||||
assertNotReadonly();
|
||||
validateValue(value);
|
||||
this.value = new ArrayList<>(value);
|
||||
validateValue(values);
|
||||
for (String value : values) {
|
||||
DBC.PRE.assertNotEmpty("empty values not allowed!", value);
|
||||
}
|
||||
this.value = new ArrayList<>(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,19 +106,24 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
|
|||
@Override
|
||||
public void addValue(String value) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotEmpty("empty values not allowed!", value);
|
||||
this.value.add(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllValues(List<String> values) {
|
||||
assertNotReadonly();
|
||||
this.value.addAll(values);
|
||||
for (String value : values) {
|
||||
DBC.PRE.assertNotEmpty("empty values not allowed!", value);
|
||||
this.value.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllValuesIfNotContains(List<String> values) {
|
||||
assertNotReadonly();
|
||||
for (String value : values) {
|
||||
DBC.PRE.assertNotEmpty("empty values not allowed!", value);
|
||||
if (!this.value.contains(value))
|
||||
this.value.add(value);
|
||||
}
|
||||
|
@ -124,6 +132,7 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
|
|||
@Override
|
||||
public boolean addValueIfNotContains(String value) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotEmpty("empty values not allowed!", value);
|
||||
|
||||
if (this.value.contains(value))
|
||||
return false;
|
||||
|
@ -213,7 +222,9 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
|
|||
|
||||
List<String> values = new ArrayList<>();
|
||||
for (String val : valueArr) {
|
||||
values.add(val.trim());
|
||||
String trim = val.trim();
|
||||
if (!trim.isEmpty())
|
||||
values.add(trim);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
@ -223,5 +234,4 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
|
|||
DBC.PRE.assertEquals("Not same Parameter types!", this.getType(), o.getType());
|
||||
return Integer.compare(this.getValue().size(), ((StringListParameter) o).getValue().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue