According to IBM this actually is an anti-pattern. These 'typedef' like classes are called psuedo types.
The article explains it a lot better than I do, but I'll try to summarize it in case the link goes down:
- Any code that expects a
WidgetCache
cannot handle aMap<String, Widget>
- These Pseudotypes are 'viral' when using multiple packages they lead to incompatibilities while the base type (just a silly Map<...>) would've worked in all cases in all packages.
- Pseudo types are often to concrete, they do not implement specific interfaces because their base classes only implement the generic version.
In the article they propose the following trick to make life easier without using pseudo types:
public static <K,V> Map<K,V> newHashMap() {
return new HashMap<K,V>();
}
Map<Socket, Future<String>> socketOwner = Util.newHashMap();
Which works due to automatic type inference.
(I came to this answer via thisthis related stack overflow question)