jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Meschberger <fmesc...@gmail.com>
Subject Re: Generics generator class
Date Mon, 04 May 2009 14:12:04 GMT
Hi,

Thomas Müller schrieb:
> 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.

I don't consider this a big issue.

> 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?

-1

Starting to have such helper classes amounts to a spiral with no end.
There is IMHO also no use.

In fact, while the "new HashMap<String, WorkspaceInfo>()" construct has
almost no influence on the generated class file, the helper class
creates a new class object and increases memory footprint. I think the
price is beyond what might be acceptable.

Regards
Felix


> 
> Regards,
> Thomas
> 


Mime
View raw message