aledsage commented on a change in pull request #1046: allow the types of 
parameters to be extended programmatically
URL: https://github.com/apache/brooklyn-server/pull/1046#discussion_r258415524
 
 

 ##########
 File path: 
core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
 ##########
 @@ -197,6 +199,15 @@ public String toString() {
         return type;
     }
 
+    /** Allows extensions to define additional types that are supported for 
parameters in YAML.
+     * Rules should return a TypeToken if the given name is known, null if not 
handled, or 
+     * throw if the name is decisively problematic. Handlers will throw if no 
rules match. 
+     */
+    @Beta
+    public static void addCustomTypeNameInference(String ruleName, 
BiFunction<String,BrooklynClassLoadingContext,TypeToken<?>> rule) {
+        ParseYamlInputs.customTypeNameInferencing.put(ruleName, rule);
+    }
+    
     private static final class ParseYamlInputs {
 
 Review comment:
   Feels a bit strange to have a bunch of static methods on this class rather 
than in a utility class (but I see lots of static methods already exist here, 
so not suggesting we change it here).
   
   Your new methods would *not* be suitable for a utility because it is 
stateful (updating the static field).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to