[New] Added ListParameter.getValue(int) and streamValues()

This commit is contained in:
Robert von Burg 2020-08-27 12:16:01 +02:00
parent 5ca616f3f3
commit 23c95cebd0
2 changed files with 29 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import li.strolch.exception.StrolchException;
import li.strolch.utils.helper.StringHelper;
@ -90,6 +91,16 @@ public abstract class AbstractListParameter<E> extends AbstractParameter<List<E>
return new ArrayList<>(this.value);
}
@Override
public E getValue(int index) {
return this.value.get(index);
}
@Override
public Stream<E> streamValues() {
return this.value.stream();
}
@Override
public void setValue(List<E> values) {
assertNotReadonly();

View File

@ -17,6 +17,7 @@ package li.strolch.model.parameter;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
/**
* A {@link Parameter} which supports a list of elements.
@ -28,6 +29,23 @@ public interface ListParameter<E> extends Parameter<List<E>> {
String VALUE_SEPARATOR1 = ";"; //$NON-NLS-1$
String VALUE_SEPARATOR2 = ","; //$NON-NLS-1$
/**
* Returns the value at the given index of this {@link ListParameter}'s value
*
* @param index
* the index from which to return the value
*
* @return the value at the given index
*/
E getValue(int index);
/**
* Returns a {@link Stream} for the values of this list
*
* @return a stream for the values
*/
Stream<E> streamValues();
/**
* Set the internal value to have the content of the collection
*