You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: add putOrRemove to DefaultManagedDependentResourceContext
The javadoc of the existing put method states that it returns Optional.
The implementation also returns Optional, but the method signature
declares it returns T. Meaning the caller has to cast it to Optional
to get at the return value.
This new method will supercede the existing put method
Signed-off-by: Robert Young <robeyoun@redhat.com>
Copy file name to clipboardExpand all lines: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/DefaultManagedDependentResourceContext.java
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,15 @@ public <T> T put(Object key, T value) {
Copy file name to clipboardExpand all lines: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedDependentResourceContext.java
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,21 @@ public interface ManagedDependentResourceContext {
40
40
@SuppressWarnings("unchecked")
41
41
<T> Tput(Objectkey, Tvalue);
42
42
43
+
/**
44
+
* Associates the specified contextual value to the specified key. If the value is {@code null},
45
+
* the semantics of this operation is defined as removing the mapping associated with the
46
+
* specified key.
47
+
*
48
+
* @param <T> object type
49
+
* @param key the key identifying which contextual object to add or remove from the context
50
+
* @param value the value to add to the context or {@code null} to remove an existing entry
51
+
* associated with the specified key
52
+
* @return an Optional containing the previous value associated with the key or
53
+
* {@link Optional#empty()} if none existed
54
+
*/
55
+
@SuppressWarnings("unchecked")
56
+
<T> Optional<T> putOrRemove(Objectkey, Tvalue);
57
+
43
58
/**
44
59
* Retrieves the value associated with the key or fail with an exception if none exists.
0 commit comments