Skip to content

Commit a450f1a

Browse files
committed
Add ValueContainer#streamKeys and ValueContainer#streamValues
1 parent 99068e7 commit a450f1a

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/main/java/org/spongepowered/api/data/value/ValueContainer.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.OptionalInt;
3737
import java.util.OptionalLong;
3838
import java.util.Set;
39+
import java.util.stream.Stream;
3940

4041
/**
4142
* A value holder is a holder of a particular set of {@link Value}s. While
@@ -215,6 +216,15 @@ default boolean supports(final Value<?> value) {
215216
*/
216217
Set<Key<?>> getKeys();
217218

219+
/**
220+
* Gets all applicable {@link Key}s for this {@link ValueContainer}.
221+
*
222+
* @return A stream of known {@link Key}s
223+
*/
224+
default Stream<Key<?>> streamKeys() {
225+
return this.getKeys().stream();
226+
}
227+
218228
/**
219229
* Gets all applicable {@link Value}s associated with this
220230
* {@link ValueContainer}. As the data backed by the values are copied,
@@ -224,4 +234,16 @@ default boolean supports(final Value<?> value) {
224234
* @return An immutable set of copied values
225235
*/
226236
Set<Value.Immutable<?>> getValues();
237+
238+
/**
239+
* Gets all applicable {@link Value}s associated with this
240+
* {@link ValueContainer}. As the data backed by the values are copied,
241+
* any modifications to the {@link Value}s will not be reflected onto
242+
* this {@link ValueContainer}.
243+
*
244+
* @return A stream of copied values
245+
*/
246+
default Stream<Value.Immutable<?>> streamValues() {
247+
return this.getValues().stream();
248+
}
227249
}

0 commit comments

Comments
 (0)