brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <>
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:
    --- Diff: usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/
    @@ -122,14 +124,15 @@ public Entity call() throws Exception {
                         throw new IllegalStateException("Unexpected scope "+scope);
    -            Optional<Entity> result = Iterables.tryFind(entitiesToSearch, EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID,
    +            Predicate<Entity> configEqualTo = EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID,
    +            Predicate<Entity> classNameEquals = EntityPredicates.classNameEquals(componentId);
    +            Optional<Entity> result = Iterables.tryFind(entitiesToSearch, Predicates.or(configEqualTo,
    --- 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 or file a JIRA ticket
with INFRA.

View raw message