I've found this library quite handy: http://javatuple.com/

On Feb 8, 10:41 pm, Keith Haber <[email protected]> wrote:
> Our team's Pair class has a few extra methods in it that make it non-
> trivial enough to justify putting it into a reusable jar file (with
> other utility classes we've come up with, of course).
>
> Our Pair implements java.lang.Comparable.  It compares first element
> to first element, then second element to second element.  If either
> element is itself Comparable, it uses its compareTo method for that
> comparison; otherwise it compares against the toString() of the
> elements.  Nulls are considered less than any non-null value.
>
> Here are some of the other methods in our Pair class:
>
> public Pair<B, A> getReverse()
>
> public static <X, Y> List<Pair<Y, X>> reversePairs(Collection<Pair<X,
> Y>> pairs)
>
> public static <X, Y> Map<X, Y> toMap(Collection<Pair<X, Y>> pairs)
>
> public static <X, Y> List<Pair<X, Y>> fromMap(Map<X, Y> map)
>
> public static <T, X, Y> List<Pair<X, Y>> convertBeansToPairs
> (Collection<T> beanList,
>         String firstPropertyName, String secondPropertyName)
>
> And in defense of using getters, they're pretty much a must in cases
> where you need to use JavaBean properties to access the values.
> Examples would be use in JSPs (with JSTL), or with utilities like the
> Jakarta Commons PropertyUtils classes.
>
> For what it's worth...
>
> Keith
>
> On Feb 8, 9:08 pm, Weiqi Gao <[email protected]> wrote:
>
> > Reinier Zwitserloot wrote:
>
> > > If you've been adding it to every project, why not make a jar out of
> > > it?
>
> > Because that would be more work than writing the class.
>
> > --
> > Weiqi Gao
> > [email protected]http://www.weiqigao.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to