commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dusan Chromy (JIRA)" <>
Subject [jira] Commented: (COLLECTIONS-110) Support parametized classes with commons.collections.
Date Fri, 04 Aug 2006 20:26:18 GMT
    [ ]

Dusan Chromy commented on COLLECTIONS-110:

My another argument for generics - and also an idea for improvement in
- would be to make
the functors work with checked exceptions.

Without generics, you have to wrap any checked exception in a FunctorException and unwrap
it later, which sort of steals all the benefits of an algorithm over a loop.

Consider this example:

public deleteBulk(List l) throws AppException {
	try {
		CollectionUtils.forAllDo(l, new Closure() {
			public void execute(Object arg) {
				try {
					deleteAppObj((AppType)arg); //can throw AppException
				} catch (AppException e) {
					throw new FunctorException(e);
	} catch (FunctorException fe) {
		throw (AppException)fe.getCause();

Now in Java 5 we can make our functors exception-savvy:

interface ThrowingClosure<T,E extends Exception> {
	void execute(T arg) throws E;
interface Closure<T> extends ThrowingClosure<T,RuntimeException> {}

With such functors you can rewrite the code from the above example so:

public deleteBulk(List l) throws AppException {
	CollectionUtils.forAllDo(l, new ThrowingClosure<AppType,AppException>() {
		public void execute(AppType arg) throws AppException {
			deleteAppObj(arg); //can throw AppException

As you can see, the latter code is not cluttered with exception handling. Thats Apache Collections
I'd like to have for my Java 5 projects!

> Support parametized classes with commons.collections.
> -----------------------------------------------------
>                 Key: COLLECTIONS-110
>                 URL:
>             Project: Commons Collections
>          Issue Type: Wish
>         Environment: Operating System: other
> Platform: Other
>            Reporter: Colbert Philippe
> It's time to create a parallel version of commons.collections to support 
> parametized classes of each container class and abstract class.  It's not that 
> hard.  There is a 23 PDF document on Sun Java website describing in detail how 
> it should be done and what to watch out for.
> I already converted a few classes from commons.collection privately for my own 
> needs.  Once you get the hang of it, it's a rather quick process.
> I am even willing to volunteer my time to do some more but I need the 
> collaboration of some of the original programmers to watch over things.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message