Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[riena-dev] FYI - TypedComparator

I was tired of using variations of this snippet in a dozen places:

private static final class StringComparator implements
Comparator<Object>, Serializable {
  public int compare(Object o1, Object o2) {
    String s1 = (String) o1;
    String s2 = (String) o2;
    return s1.compareTo(s2);
  }
}

Now there is a TypedComparator, which works for all types that
implement Comparable :-)

new TypedComparator<String>();
new TypedComparator<Integer>();
new TypedComparator<Boolean>();
...

You can find it in org.eclipse.riena.beans.common.

Greetings,
Elias.


Back to the top