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: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to