brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: allow dsl commands to get an enti...
Date Thu, 16 Apr 2015 21:35:06 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/600#discussion_r28552175
  
    --- Diff: usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
---
    @@ -122,14 +124,15 @@ public Entity call() throws Exception {
                     default:
                         throw new IllegalStateException("Unexpected scope "+scope);
                 }
    -            
    -            Optional<Entity> result = Iterables.tryFind(entitiesToSearch, EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID,
componentId));
    +            Predicate<Entity> configEqualTo = EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID,
componentId);
    +            Predicate<Entity> classNameEquals = EntityPredicates.classNameEquals(componentId);
    +            Optional<Entity> result = Iterables.tryFind(entitiesToSearch, Predicates.or(configEqualTo,
classNameEquals));
    --- End diff --
    
    If the string matches both an id and a class name, then would be good to guarantee it
will first match on id rather than it being dependent on the order that it walks through the
entities. I'd therefore go for the more verbose:
    
        Optional<Entity> result = Iterables.tryFind(entitiesToSearch, configEqualTo);
        if (!result.isPresent()) result = Iterables.tryFind(entitiesToSearch, classNameEquals);



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message