[New] Added ITimeVariable.streamValues()

This commit is contained in:
Robert von Burg 2021-12-07 19:48:33 +01:00
parent 7a7140cbea
commit f6a7e6e353
2 changed files with 14 additions and 0 deletions

View File

@ -17,6 +17,7 @@ package li.strolch.model.timevalue;
import java.util.Collection; import java.util.Collection;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.stream.Stream;
/** /**
* A timed variable storing a ordered sequence of {@link ITimeValue} objects modeling a time evolution of a quantity. * A timed variable storing a ordered sequence of {@link ITimeValue} objects modeling a time evolution of a quantity.
@ -101,6 +102,13 @@ public interface ITimeVariable<T extends IValue> {
*/ */
SortedSet<ITimeValue<T>> getValues(); SortedSet<ITimeValue<T>> getValues();
/**
* Returns a {@link Stream} over all {@link ITimeValue} objects
*
* @return a stream of all the values
*/
Stream<ITimeValue<T>> streamValues();
/** /**
* removes {@link ITimeValue} objects from the sequence, where the successor matches value. I.e considering a pair * removes {@link ITimeValue} objects from the sequence, where the successor matches value. I.e considering a pair
* of adjacent {@link ITimeValue} objects in the sequence which have the same {@link IValue}, the later one is * of adjacent {@link ITimeValue} objects in the sequence which have the same {@link IValue}, the later one is

View File

@ -20,6 +20,7 @@ import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.stream.Stream;
import li.strolch.exception.StrolchModelException; import li.strolch.exception.StrolchModelException;
import li.strolch.model.timevalue.ITimeValue; import li.strolch.model.timevalue.ITimeValue;
@ -93,6 +94,11 @@ public class TimeVariable<T extends IValue> implements ITimeVariable<T>, Seriali
return new TreeSet<>(this.container); return new TreeSet<>(this.container);
} }
@Override
public Stream<ITimeValue<T>> streamValues() {
return this.container.stream();
}
@Override @Override
public void applyChange(final IValueChange<T> change, boolean compact) { public void applyChange(final IValueChange<T> change, boolean compact) {
assertNotReadonly(); assertNotReadonly();