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

    https://github.com/apache/incubator-brooklyn/pull/1017#discussion_r44641645
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/typereg/RegisteredTypePredicates.java
 ---
    @@ -109,36 +109,46 @@ public boolean apply(@Nullable RegisteredType item) {
             }
         }
     
    -    public static <T> Predicate<RegisteredType> javaType(final 
Predicate<Class<T>> filter) {
    -        return new JavaTypeMatches(filter);
    +    public static <T> Predicate<RegisteredType> anySuperType(final 
Predicate<Class<T>> filter) {
    +        return new AnySuperTypeMatches(filter);
         }
         @SuppressWarnings({ "unchecked", "rawtypes" })
    -    public static Predicate<RegisteredType> javaTypeAssignableFrom(final 
Class<?> filter) {
    -        return javaType((Predicate)Predicates.assignableFrom(filter));
    +    public static Predicate<RegisteredType> assignableFrom(final Class<?> 
filter) {
    +        return anySuperType((Predicate)Predicates.assignableFrom(filter));
         }
         
    -    private static class JavaTypeMatches implements 
Predicate<RegisteredType> {
    +    private static class AnySuperTypeMatches implements 
Predicate<RegisteredType> {
             private final Predicate<Class<?>> filter;
             
             @SuppressWarnings({ "rawtypes", "unchecked" })
    -        private <T> JavaTypeMatches(Predicate filter) {
    +        private <T> AnySuperTypeMatches(Predicate filter) {
                 this.filter = filter;
             }
             @Override
             public boolean apply(@Nullable RegisteredType item) {
                 if (item==null) return false;
    -            return (item != null) && filter.apply(item.getJavaType());
    +            for (Object o: item.getSuperTypes()) {
    +                if (o instanceof Class) {
    +                    if (filter.apply((Class<?>)o)) return true;
    +                }
    +            }
    +            for (Object o: item.getSuperTypes()) {
    +                if (o instanceof RegisteredType) {
    +                    if (apply((RegisteredType)o)) return true;
    +                }
    +            }
    +            return false;
             }
         }
     
    -    public static final Predicate<RegisteredType> IS_APPLICATION = 
javaTypeAssignableFrom(Application.class);
    +    public static final Predicate<RegisteredType> IS_APPLICATION = 
assignableFrom(Application.class);
         // TODO do we need this?  introduced already deprecated in 0.9.0 so 
can be removed, or enabled
    --- End diff --
    
    +1 to remove


---
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