You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by GitBox <gi...@apache.org> on 2019/02/20 10:28:14 UTC

[GitHub] aledsage commented on a change in pull request #1046: allow the types of parameters to be extended programmatically

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:
users@infra.apache.org


With regards,
Apache Git Services