brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <>
Subject [GitHub] incubator-brooklyn pull request: add uniqueTag and tags for all ad...
Date Tue, 05 Aug 2014 11:33:50 GMT
Github user aledsage commented on a diff in the pull request:
    --- Diff: utils/common/src/main/java/brooklyn/util/guava/ ---
    @@ -68,5 +73,25 @@
         public static <T> Class<T> getRawRawType(TypeToken<T> token) {
             return (Class)token.getRawType();
    +    @SuppressWarnings({ "unchecked", "rawtypes" })
    +    public static <T> TypeToken<Set<T>> setOf(Class<T> type)
    +        return (TypeToken) TypeToken.of(Set.class);
    +    }
    +    @SuppressWarnings({ "unchecked", "rawtypes" })
    +    public static <K,V> TypeToken<Map<K,V>> mapOf(Class<K> key,
Class<V> value) {
    --- End diff --
    Not sure I follow. I thought one of the points of `TypeToken` is that it has the generics
information at runtime (i.e. it is not lost through type erasure). However, just casting `TypeToken.of(Map.class)`
means it will not have the generics at runtime. We need to declare a sub-class of `TypeToken`
in order to preserve the generics - i.e. TypeToken.of()
    It feels like these utilities have a place (e.g. in removing compile warnings about casting
and missing generics etc), but do we subsequently rely on the `TypeToken` still having the
generics at runtime?

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