[New] Added ListParameter.addAllValuesIfNotContains()

This commit is contained in:
Robert von Burg 2018-10-23 17:10:38 +02:00
parent 34d53d5d56
commit c6b7a957a6
5 changed files with 44 additions and 0 deletions

View File

@ -112,6 +112,15 @@ public class FloatListParameter extends AbstractParameter<List<Double>> implemen
this.value.addAll(values);
}
@Override
public void addAllValuesIfNotContains(List<Double> values) {
assertNotReadonly();
for (Double value : values) {
if (!this.value.contains(value))
this.value.add(value);
}
}
@Override
public boolean addValueIfNotContains(Double value) {
assertNotReadonly();

View File

@ -112,6 +112,15 @@ public class IntegerListParameter extends AbstractParameter<List<Integer>> imple
this.value.addAll(values);
}
@Override
public void addAllValuesIfNotContains(List<Integer> values) {
assertNotReadonly();
for (Integer value : values) {
if (!this.value.contains(value))
this.value.add(value);
}
}
@Override
public boolean addValueIfNotContains(Integer value) {
assertNotReadonly();

View File

@ -43,6 +43,14 @@ public interface ListParameter<E> extends Parameter<List<E>> {
*/
void addAllValues(List<E> values);
/**
* Adds all of the given values to the {@link List} of values which are not already in the current list
*
* @param values
* the values to add
*/
void addAllValuesIfNotContains(List<E> values);
/**
* Adds a single value to the {@link List} of values if the current list does not already contain the value
*

View File

@ -112,6 +112,15 @@ public class LongListParameter extends AbstractParameter<List<Long>> implements
this.value.addAll(values);
}
@Override
public void addAllValuesIfNotContains(List<Long> values) {
assertNotReadonly();
for (Long value : values) {
if (!this.value.contains(value))
this.value.add(value);
}
}
@Override
public boolean addValueIfNotContains(Long value) {
assertNotReadonly();

View File

@ -112,6 +112,15 @@ public class StringListParameter extends AbstractParameter<List<String>> impleme
this.value.addAll(values);
}
@Override
public void addAllValuesIfNotContains(List<String> values) {
assertNotReadonly();
for (String value : values) {
if (!this.value.contains(value))
this.value.add(value);
}
}
@Override
public boolean addValueIfNotContains(String value) {
assertNotReadonly();