brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahgittin <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #810: REST API for bundles, types, and subtypes
Date Mon, 25 Sep 2017 08:34:31 GMT
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/810#discussion_r140715935
  
    --- 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 --
    
    didn't think generics would affect persistence, but i've restored it and made a new class,
just in case.
    
    also removed inner classes elsewhere here where they might be returned to the caller.


---

Mime
View raw message