markap14 commented on code in PR #112:
URL: https://github.com/apache/nifi-api/pull/112#discussion_r4360416654
##########
src/main/java/org/apache/nifi/components/state/StateMap.java:
##########
@@ -48,4 +51,32 @@ public interface StateMap {
* @return an immutable Map representation of all keys and values for the
state of a component.
*/
Map<String, String> toMap();
+
+ /**
+ * Returns an immutable Map of all keys and values for the state of a
component, with the given patches applied. This StateMap is not changed.
+ * <p>
+ * Each key in the given patches with a non-null value is added or
overwritten. Each key with a {@code null} value is removed.
+ * Keys that are not in the given patches keep their values from this
StateMap.
+ * </p>
+ *
+ * @param patches a map of state keys to their new values. A key that is
mapped to {@code null} is removed from the result. The map itself must not be
{@code null}.
+ * @return an immutable Map of this state's keys and values with the given
patches applied
+ */
+ default Map<String, String> toMap(final Map<String, String> patches) {
Review Comment:
I actually considered many different options here. I don't like
`getPatchedMap()` because I don't like using getters that do more than just
return a value. Plus, `getPatchedMap()` sounds like it's going to return a
`PatchedMap` rather than a `Map<String, String>`. The `toMap()` already exists
to create a `Map<String, String>` so providing an override here that allows
applying patches on top made sense to me. I could be convinced if you feel
strongly though :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]