garydgregory commented on issue #398: Add ComparableUtils
URL: https://github.com/apache/commons-lang/pull/398#issuecomment-520532425
 
 
   -1 Over the top, the same 'legibility' IMO can simply be achieved with:
   
   ```
   public class ComparableUtils {
   
       public enum Compared {EQUALS, GREATER, LESSER};
       
       public static Compared compare(Comparable c1, Object o) {
           final int result = c1.compareTo(o);
           return result == 0 ? Compared.EQUALS : result > 0 ? Compared.GREATER 
: Compared.LESSER;
       }
       
       @Test
       public void test() {
           Assertions.assertEquals(Compared.GREATER, ComparableUtils.compare(1, 
0));
           Assertions.assertEquals(Compared.LESSER, ComparableUtils.compare(0, 
1));
           Assertions.assertEquals(Compared.EQUALS, ComparableUtils.compare(0, 
0));
       }
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to