commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <>
Subject [COLLECTIONS] TransformedCollection generic signature seems wrong
Date Tue, 19 Oct 2010 12:00:58 GMT
I'm trying to get my head round the generic signature of the
decorate() method, for example in TransformedCollection:

public static <E> Collection<E> decorate(Collection<E> coll,
Transformer<? super E, ? extends E> transformer)

This does not seem to allow one to transform String into Integer (or
vice-versa) without ignoring type-safety warnings.

I would expect to be able to do something like:

Collection<String> cs = ...
Transformer<String,Integer> s2i = ...
Collection<Integer> ci = TransformedCollection(cs, s2i);

But the signature does not allow this.

I think the signature should probably look like:

public static <I, O> Collection<O> decorate(Collection<I> coll,
Transformer<I, O> transformer)

where I and O stand for Input and Output, as in the Transformer API.

Or have I misunderstood the purpose of the method?

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

View raw message