josephw commented on code in PR #152:
URL: https://github.com/apache/maven-enforcer/pull/152#discussion_r884346819
##########
enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java:
##########
@@ -131,4 +132,13 @@ List<?> getComponentList ( String role )
* @return the container
*/
PlexusContainer getContainer();
+
+ /**
+ * Gets a cached value, or uses the provided producer to compute it.
+ *
+ * @param key a key to identify the value stored
+ * @param producer a supplier for the value if it's not already present
+ * @return a previously-cached or freshly-computed value
+ */
+ Object getCache( String key, Supplier<?> producer );
Review Comment:
I considered this; it's a nicer API signature. However, there's no
enforcement that keys are distinct, so getting a cache response that had
previously been produced by a `Supplier` of a different `<T>` would lead to
types that were inconsistent with the generics.
I could make this more elaborate (e.g. passing in a `Class` and enforcing
that), but I went with a version that I think makes the necessary runtime check
clearer.
--
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]