pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noel Grandin <noelgran...@gmail.com>
Subject type-inferencing factory methods for collection classes
Date Mon, 13 Apr 2009 14:24:33 GMT
Hi

There is a chance that this problem might be solved by Project Coin,
which may introduce compiler-driven constructor type inference into
Java 1.7.

But in the meantime.... what are the thoughts about introducing methods like

public clas HashMap {
    public static <K, V> HashMap<K, V> create() {
    	return new HashMap<K, V>();
    }
}

which help reduce unnecessary clutter like this:

    private static final Map<Class<?>, BeanDictionary> defaultsCache =
             new HashMap<Class<?>, BeanDictionary>();

to this

    private static final Map<Class<?>, BeanDictionary> defaultsCache =
             HashMap.create();


??

Mime
View raw message