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

    https://github.com/apache/brooklyn-server/pull/879#discussion_r149616384
  
    --- Diff: 
api/src/main/java/org/apache/brooklyn/api/mgmt/ManagementContext.java ---
    @@ -309,8 +310,14 @@
         /** As {@link #lookup(String, Class)} but not constraining the return 
type */
         public BrooklynObject lookup(String id);
         
    -    /** Finds an entity with the given ID known at this management context 
*/
    -    // TODO in future support policies etc
    +    /** As {@link #lookup(Predicate)} comparing the ID of the object with 
the given string */
         public <T extends BrooklynObject> T lookup(String id, Class<T> type); 
     
    -}
    \ No newline at end of file
    +    /** Finds a {@link BrooklynObject} known in this management context 
    +     * satisfying the given predicate, or null */
    +    public <T extends BrooklynObject> T lookup(Predicate<? super T> 
filter);
    --- End diff --
    
    marked `@Beta`.  i'd be happy with ` Maybe tryLookup` which might be useful 
for tests (do a `get()` after to force a nice error easily, as opposed to null 
check and new explicit message.  but a primary use case is groovy console, 
`mgmt.lookup("ID")` is super handy.


---

Reply via email to