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

    https://github.com/apache/brooklyn-server/pull/810#discussion_r140600450
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/typereg/RegisteredTypePredicates.java
 ---
    @@ -194,27 +219,42 @@ public boolean apply(@Nullable RegisteredType item) {
             }
         }
     
    -    public static <T> Predicate<RegisteredType> anySuperType(final 
Predicate<Class<T>> filter) {
    +    public static <T> Predicate<RegisteredType> anySuperType(final 
Predicate<Object> filter) {
             return new AnySuperTypeMatches(filter);
         }
    -    @SuppressWarnings({ "unchecked", "rawtypes" })
         public static Predicate<RegisteredType> subtypeOf(final Class<?> 
filter) {
             // the assignableFrom predicate checks if this class is assignable 
from the subsequent *input*.
             // in other words, we're checking if any input is a subtype of 
this class
    -        return anySuperType((Predicate)Predicates.assignableFrom(filter));
    +        return anySuperType(new Predicate<Object>() {
    +            @Override
    +            public boolean apply(Object input) {
    +                if (!(input instanceof Class)) return false;
    +                return filter.isAssignableFrom((Class<?>)input);
    +            }
    +        });
    +    }
    +    public static Predicate<RegisteredType> subtypeOf(final String filter) 
{
    +        // the assignableFrom predicate checks if this class is assignable 
from the subsequent *input*.
    +        // in other words, we're checking if any input is a subtype of 
this class
    +        return anySuperType(new Predicate<Object>() {
    +            @Override
    +            public boolean apply(Object input) {
    +                if (input instanceof Class) input = 
((Class<?>)input).getName();
    +                return filter.equals(input);
    +            }
    +        });
         }
         
         private static class AnySuperTypeMatches implements 
Predicate<RegisteredType> {
    -        private final Predicate<Class<?>> filter;
    +        private final Predicate<Object> filter;
    --- End diff --
    
    Is this definitely not persisted anywhere? If it is, then changing the 
generics could cause weird errors later.


---

Reply via email to