From f6a7e6e353b22ca7ad91197653027f49c9c2c778 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 7 Dec 2021 19:48:33 +0100 Subject: [PATCH] [New] Added ITimeVariable.streamValues() --- .../java/li/strolch/model/timevalue/ITimeVariable.java | 8 ++++++++ .../li/strolch/model/timevalue/impl/TimeVariable.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/li.strolch.model/src/main/java/li/strolch/model/timevalue/ITimeVariable.java b/li.strolch.model/src/main/java/li/strolch/model/timevalue/ITimeVariable.java index efe8c4b75..590d5ae05 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/timevalue/ITimeVariable.java +++ b/li.strolch.model/src/main/java/li/strolch/model/timevalue/ITimeVariable.java @@ -17,6 +17,7 @@ package li.strolch.model.timevalue; import java.util.Collection; 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. @@ -101,6 +102,13 @@ public interface ITimeVariable { */ SortedSet> getValues(); + /** + * Returns a {@link Stream} over all {@link ITimeValue} objects + * + * @return a stream of all the values + */ + Stream> streamValues(); + /** * 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 diff --git a/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/TimeVariable.java b/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/TimeVariable.java index 09859c40c..f2b56f4c1 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/TimeVariable.java +++ b/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/TimeVariable.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.SortedSet; import java.util.TreeSet; +import java.util.stream.Stream; import li.strolch.exception.StrolchModelException; import li.strolch.model.timevalue.ITimeValue; @@ -93,6 +94,11 @@ public class TimeVariable implements ITimeVariable, Seriali return new TreeSet<>(this.container); } + @Override + public Stream> streamValues() { + return this.container.stream(); + } + @Override public void applyChange(final IValueChange change, boolean compact) { assertNotReadonly();