Github user richardcloudsoft commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/639#discussion_r30223925
  
    --- Diff: 
locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java 
---
    @@ -1050,42 +1050,59 @@ public void apply(TemplateOptions t, ConfigBag 
props, Object v) {
                         public void apply(TemplateOptions t, ConfigBag props, 
Object v) {
                             t.networks((String)v);
                         }})
    -              .put(TEMPLATE_OPTIONS, new CustomizeTemplateOptions() {
    -                  @Override
    -                  public void apply(TemplateOptions options, ConfigBag 
config, Object v) {
    -                      if (v == null) return;
    -                      @SuppressWarnings("unchecked") Map<String, String> 
optionsMap = (Map<String, String>) v;
    -                      if (optionsMap.isEmpty()) return;
    -
    -                      Class<? extends TemplateOptions> clazz = 
options.getClass();
    -                      Iterable<Method> methods = 
Arrays.asList(clazz.getMethods());
    -                      for(final Map.Entry<String, String> option : 
optionsMap.entrySet()) {
    -                          Optional<Method> methodOptional = 
Iterables.tryFind(methods, new Predicate<Method>() {
    -                              @Override
    -                              public boolean apply(@Nullable Method input) 
{
    -                                  // Matches a method with the expected 
name, and a single parameter that TypeCoercions
    -                                  // can coerce to
    -                                  if (input == null) return false;
    -                                  if 
(!input.getName().equals(option.getKey())) return false;
    -                                  Type[] parameterTypes = 
input.getGenericParameterTypes();
    -                                  return parameterTypes.length == 1
    -                                          && 
TypeCoercions.tryCoerce(option.getValue(), 
TypeToken.of(parameterTypes[0])).isPresentAndNonNull();
    -                              }
    -                          });
    -                          if(methodOptional.isPresent()) {
    -                              try {
    -                                  Method method = methodOptional.get();
    -                                  method.invoke(options, 
TypeCoercions.coerce(option.getValue(), 
TypeToken.of(method.getGenericParameterTypes()[0])));
    -                              } catch (IllegalAccessException e) {
    -                                  throw Exceptions.propagate(e);
    -                              } catch (InvocationTargetException e) {
    -                                  throw Exceptions.propagate(e);
    -                              }
    -                          } else {
    -                              LOG.warn("Ignoring request to set template 
option {} because this is not supported by {}", new Object[] { option.getKey(), 
clazz.getCanonicalName() });
    -                          }
    -                      }
    -                  }
    +            .put(TEMPLATE_OPTIONS, new CustomizeTemplateOptions() {
    +                @Override
    +                public void apply(TemplateOptions options, ConfigBag 
config, Object v) {
    +                    if (v == null) return;
    +                    @SuppressWarnings("unchecked") Map<String, Object> 
optionsMap = (Map<String, Object>) v;
    +                    if (optionsMap.isEmpty()) return;
    +
    +                    Class<? extends TemplateOptions> clazz = 
options.getClass();
    +                    Iterable<Method> methods = 
Arrays.asList(clazz.getMethods());
    +                    for(final Map.Entry<String, Object> option : 
optionsMap.entrySet()) {
    +                        Optional<Method> methodOptional = 
Iterables.tryFind(methods, new Predicate<Method>() {
    +                            @Override
    +                            public boolean apply(@Nullable Method input) {
    +                                // Matches a method with the expected 
name, and a single parameter that TypeCoercions
    --- End diff --
    
    Is the statement "... a single parameter ..." still true, or does this now 
match methods with multiple parameters?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to