3838import java .util .Objects ;
3939import java .util .Optional ;
4040import java .util .Set ;
41+ import java .util .stream .Stream ;
4142
4243/**
4344 * Represents an object of data represented by a map.
@@ -106,6 +107,15 @@ public interface DataView {
106107 */
107108 Set <DataQuery > keys (boolean deep );
108109
110+ /**
111+ * Gets a Stream containing all root keys for this {@link DataView}.
112+ *
113+ * @return Stream of root keys of this container
114+ */
115+ default Stream <String > streamRootKeys () {
116+ return this .keys (false ).stream ().map (k -> k .parts ().getFirst ());
117+ }
118+
109119 /**
110120 * Gets a Map containing all keys and their values for this {@link DataView}.
111121 *
@@ -121,6 +131,15 @@ public interface DataView {
121131 */
122132 Map <DataQuery , Object > values (boolean deep );
123133
134+ /**
135+ * Gets a Stream containing all root keys and their values for this {@link DataView}.
136+ *
137+ * @return Stream of root keys and values of this container
138+ */
139+ default Stream <Map .Entry <String , Object >> streamRootValues () {
140+ return this .values (false ).entrySet ().stream ().map (entry -> Map .entry (entry .getKey ().parts ().getFirst (), entry .getValue ()));
141+ }
142+
124143 /**
125144 * Returns whether this {@link DataView} contains the given path.
126145 *
@@ -158,6 +177,17 @@ public interface DataView {
158177 */
159178 DataView set (DataQuery path , Object value );
160179
180+ /**
181+ * Sets the given Object value to this {@link DataView}'s key.
182+ *
183+ * @param key The key of the object to set
184+ * @param value The value of the data
185+ * @return This view, for chaining
186+ */
187+ default DataView set (String key , Object value ) {
188+ return this .set (DataQuery .of (key ), value );
189+ }
190+
161191 /**
162192 * Removes the data associated to the given path relative to this
163193 * {@link DataView}'s path.
0 commit comments