Android Open Source - sdl_tester_android Enum Comparator

From Project

Back to project page sdl_tester_android.


The source code is released under:

Copyright (c) 2014, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are m...

If you think the Android project sdl_tester_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.livio.sdl.enums;
/*from   w  w  w .  j a va  2 s .  c o  m*/
import java.util.Comparator;

 * This class is simply a comparator for enum values using their toString()
 * method instead of the standard name() method.
 * This allows you to sort your enums by their friendly names, which is much
 * more useful than sorting by the enum name.
 * @author Mike Burke
public class EnumComparator<E extends Enum<E>> implements Comparator<E> {
  public int compare(E lhs, E rhs) {
    return lhs.toString().compareTo(rhs.toString());

Java Source Code List