commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (COLLECTIONS-372) ComparatorUtils.transformedComparator wrongly typed (generics)
Date Wed, 06 Mar 2013 19:54:13 GMT

     [ https://issues.apache.org/jira/browse/COLLECTIONS-372?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thomas Neidhart resolved COLLECTIONS-372.
-----------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0

Made change in r1453516.

Makes sense for a TransformingComparator imho, not always possible for other occurrences.
                
> ComparatorUtils.transformedComparator wrongly typed (generics)
> --------------------------------------------------------------
>
>                 Key: COLLECTIONS-372
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-372
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Comparator
>    Affects Versions: 4.x
>         Environment: n/a
>            Reporter: HaveNone
>            Priority: Minor
>              Labels: patch
>             Fix For: 4.0
>
>
> ComparatorUtils.transformedComparator is currently typed as follows :
> {{public static <I,O> Comparator<O> transformedComparator(Comparator<I>
comparator, Transformer<I, O> transformer)}}
> It should be typed as follows so that is can be used without removing generics typing:
> {{public static <I,O> Comparator<I> transformedComparator(Comparator<O>
comparator, Transformer<I, O> transformer)}}
> Here is a unit test for it : 
> Transformer<Integer, String> itosTransformer = TransformerUtils.stringValueTransformer();
> 		Comparator<Integer> c = new Comparator<Integer>() {
> 			
> 			@Override
> 			public int compare(Integer o1, Integer o2) {
> 				return o1.compareTo(o2);
> 			}
> 		};
> 		Comparator<String> stringComparator = ComparatorUtils.transformedComparator(c,
itosTransformer);
> 		
> 		stringComparator.compare("string1", "string2");

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message