jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Boston <...@tfd.co.uk>
Subject Re: Generics generator class
Date Tue, 05 May 2009 11:28:54 GMT

On 4 May 2009, at 14:17, Thomas Müller wrote:

> Hi,
> I would like to use Java 1.5 features now in Jackrabbit. I hope this
> will improve reliability, simplify maintenance, and reduce source code
> size. Unfortunately using generics is sometimes quite verbose.
> Example:
> HashMap wspInfos = new HashMap();
> becomes
> HashMap<String, WorkspaceInfo> wspInfos = new HashMap<String,  
> WorkspaceInfo>();
> Part of that could be avoided using a helper class:
> HashMap<String, WorkspaceInfo> wspInfos = New.hashMap();
> I propose to add a new 'generics generator class' called 'New' to
> jackrabbit-jcr-commons. It would contain constructor methods for the
> most commonly used collection objects.
> public class New {
>    public static <K, V> HashMap<K, V> hashMap() {
>        return new HashMap<K, V>();
>    }
>    public static <T> ArrayList<T> arrayList() {
>        return new ArrayList<T>();
>    }
>    public static <T> WeakReference<T> weakReference(T t) {
>        return new WeakReference<T>(t);
>    }
>    ...
> }
> What do you think? Are there better solutions?
> Regards,
> Thomas

Unfortunately Commons Collections isn't generics aware (yet), if it  
was, it would have this built in.

I Shindig, where I am a committer, we are using Google Collections  
which does know about generics.

It also has some fast immutable implementations.
and a variety of linked, ordered, sorted maps, sets etc

That decision was probably influenced by the high proportion of  
googlers on the team, but it has made the code base simpler and has  
clearly differentiated between writable and non writable collections.

When using it also clear what the intent was.

Although its at 1.0 RC1, its running in production most of those who  
have taken shindig into production. eg hi5, Ning, myspace, google etc.

here was the discussion:



View raw message