From fc896be5b5c5e7dda6602e6759a1a5f20cf25023 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Fri, 5 Oct 2018 11:18:05 +0200 Subject: [PATCH] [New] added ListParameter.addAllValues --- .../model/parameter/FloatListParameter.java | 6 +++ .../model/parameter/IntegerListParameter.java | 6 +++ .../model/parameter/ListParameter.java | 28 +++++++---- .../model/parameter/LongListParameter.java | 6 +++ .../li/strolch/model/parameter/Parameter.java | 48 +++++++++---------- .../model/parameter/StringListParameter.java | 6 +++ 6 files changed, 66 insertions(+), 34 deletions(-) diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/FloatListParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/FloatListParameter.java index d4ded7d3c..ac4f12fc1 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/parameter/FloatListParameter.java +++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/FloatListParameter.java @@ -106,6 +106,12 @@ public class FloatListParameter extends AbstractParameter> implemen this.value.add(value); } + @Override + public void addAllValues(List values) { + assertNotReadonly(); + this.value.addAll(values); + } + @Override public boolean addValueIfNotContains(Double value) { assertNotReadonly(); diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/IntegerListParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/IntegerListParameter.java index ded8e322f..8af6c43ca 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/parameter/IntegerListParameter.java +++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/IntegerListParameter.java @@ -106,6 +106,12 @@ public class IntegerListParameter extends AbstractParameter> imple this.value.add(value); } + @Override + public void addAllValues(List values) { + assertNotReadonly(); + this.value.addAll(values); + } + @Override public boolean addValueIfNotContains(Integer value) { assertNotReadonly(); diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/ListParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/ListParameter.java index 7789b7f63..0e4a854c5 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/parameter/ListParameter.java +++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/ListParameter.java @@ -24,8 +24,8 @@ import java.util.List; */ public interface ListParameter extends Parameter> { - public static final String VALUE_SEPARATOR1 = ";"; //$NON-NLS-1$ - public static final String VALUE_SEPARATOR2 = ","; //$NON-NLS-1$ + String VALUE_SEPARATOR1 = ";"; //$NON-NLS-1$ + String VALUE_SEPARATOR2 = ","; //$NON-NLS-1$ /** * Adds a single value to the {@link List} of values @@ -33,7 +33,15 @@ public interface ListParameter extends Parameter> { * @param value * the value to add */ - public void addValue(E value); + void addValue(E value); + + /** + * Adds the given values to the {@link List} of values + * + * @param values + * the values to add + */ + void addAllValues(List values); /** * Adds a single value to the {@link List} of values if the current list does not already contain the value @@ -41,7 +49,7 @@ public interface ListParameter extends Parameter> { * @param value * the value to add */ - public boolean addValueIfNotContains(E value); + boolean addValueIfNotContains(E value); /** * Removes a single value from the {@link List} of values @@ -51,26 +59,26 @@ public interface ListParameter extends Parameter> { * * @return true if the value was removed, false if it did not exist */ - public boolean removeValue(E value); + boolean removeValue(E value); /** * Clears the list of values, i.e the list of values is empty after this call */ - public void clear(); + void clear(); /** * Returns true if the list of values is empty, false if not * * @return true if the list of values is empty, false if not */ - public boolean isEmpty(); + boolean isEmpty(); /** * Returns the size of the list of values * * @return the size of the list of values */ - public int size(); + int size(); /** * Returns true if the list of values contains the given element, false if not @@ -80,7 +88,7 @@ public interface ListParameter extends Parameter> { * * @return true if the list of values contains the given element, false if not */ - public boolean contains(E value); + boolean contains(E value); /** * Returns true if the list of values contains all of the given elements, false if not @@ -90,5 +98,5 @@ public interface ListParameter extends Parameter> { * * @return true if the list of values contains all of the given elements, false if not */ - public boolean containsAll(List values); + boolean containsAll(List values); } diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/LongListParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/LongListParameter.java index 1c9ba8804..00d5ef2a7 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/parameter/LongListParameter.java +++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/LongListParameter.java @@ -106,6 +106,12 @@ public class LongListParameter extends AbstractParameter> implements this.value.add(value); } + @Override + public void addAllValues(List values) { + assertNotReadonly(); + this.value.addAll(values); + } + @Override public boolean addValueIfNotContains(Long value) { assertNotReadonly(); diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/Parameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/Parameter.java index 94231bba6..3cb1bb921 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/parameter/Parameter.java +++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/Parameter.java @@ -30,7 +30,7 @@ public interface Parameter extends StrolchElement, Comparable> { * * @return the value as string */ - public String getValueAsString(); + String getValueAsString(); /** * Set the value of the parameter from a string @@ -38,14 +38,14 @@ public interface Parameter extends StrolchElement, Comparable> { * @param valueAsString * the string from which to set the value */ - public void setValueFromString(String valueAsString); + void setValueFromString(String valueAsString); /** * the value of the parameter * * @return the value */ - public U getValue(); + U getValue(); /** * set the value of the parameter @@ -53,7 +53,7 @@ public interface Parameter extends StrolchElement, Comparable> { * @param value * the new value */ - public void setValue(T value); + void setValue(T value); /** * set the value of the parameter from another value, i.e. copying the value @@ -61,18 +61,18 @@ public interface Parameter extends StrolchElement, Comparable> { * @param parameter * the parameter from which to copy the new value */ - public void setValueFrom(Parameter parameter); + void setValueFrom(Parameter parameter); /** * Clears the value, dependent on the concrete class */ - public void clear(); + 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(); + boolean isEmpty(); /** * Returns true if the given parameter's value is equal to the current value @@ -82,7 +82,7 @@ public interface Parameter extends StrolchElement, Comparable> { * * @return true if the given parameter's value is equal to the current value */ - public boolean isEqualTo(Parameter otherValue); + boolean isEqualTo(Parameter otherValue); /** * Returns true if the given value is equal to the current value @@ -92,14 +92,14 @@ public interface Parameter extends StrolchElement, Comparable> { * * @return true if the given value is equal to the current value */ - public boolean isEqualTo(T otherValue); + boolean isEqualTo(T otherValue); /** * get the hidden attribute * * @return hidden value */ - public boolean isHidden(); + boolean isHidden(); /** * set the hidden attribute @@ -107,14 +107,14 @@ public interface Parameter extends StrolchElement, Comparable> { * @param hidden * new hidden value */ - public void setHidden(boolean hidden); + void setHidden(boolean hidden); /** * Get the UOM of this {@link Parameter} * * @return the UOM */ - public String getUom(); + String getUom(); /** * Set the UOM of this {@link Parameter} @@ -122,14 +122,14 @@ public interface Parameter extends StrolchElement, Comparable> { * @param uom * the new UOM */ - public void setUom(String uom); + void setUom(String uom); /** * Returns the index of this {@link Parameter}. This can be used to sort the parameters in a UI * * @return the index of this {@link Parameter}. This can be used to sort the parameters in a UI */ - public int getIndex(); + int getIndex(); /** * Set the index of this {@link Parameter}. This can be used to sort the parameters in a UI @@ -137,7 +137,7 @@ public interface Parameter extends StrolchElement, Comparable> { * @param index * the index to set */ - public void setIndex(int index); + void setIndex(int index); /** * Returns the interpretation of this {@link Parameter}. The interpretation semantic describes what the value of @@ -150,7 +150,7 @@ public interface Parameter extends StrolchElement, Comparable> { * * @return string value */ - public String getInterpretation(); + String getInterpretation(); /** * Set the interpretation of this {@link Parameter}. The interpretation semantic describes what the value of this @@ -164,7 +164,7 @@ public interface Parameter extends StrolchElement, Comparable> { * @param interpretation * the interpretation */ - public void setInterpretation(String interpretation); + void setInterpretation(String interpretation); /** * The {@link ParameterizedElement} parent to which this {@link Parameter} belongs @@ -172,27 +172,27 @@ public interface Parameter extends StrolchElement, Comparable> { * @return the parent */ @Override - public ParameterizedElement getParent(); + ParameterizedElement getParent(); /** * Sets the parent for this {@link Parameter} */ - public void setParent(ParameterizedElement parent); + void setParent(ParameterizedElement parent); @Override - public int hashCode(); + int hashCode(); @Override - public boolean equals(Object obj); + boolean equals(Object obj); @Override - public int compareTo(Parameter o); + int compareTo(Parameter o); @Override - public Parameter getClone(); + Parameter getClone(); /** * @return the {@link StrolchValueType} */ - public StrolchValueType getValueType(); + StrolchValueType getValueType(); } diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/StringListParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/StringListParameter.java index d339d6359..add058d5c 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/parameter/StringListParameter.java +++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/StringListParameter.java @@ -106,6 +106,12 @@ public class StringListParameter extends AbstractParameter> impleme this.value.add(value); } + @Override + public void addAllValues(List values) { + assertNotReadonly(); + this.value.addAll(values); + } + @Override public boolean addValueIfNotContains(String value) { assertNotReadonly();