You can simply use Apache Commons Lang:
result = ObjectUtils.compare(firstComparable, secondComparable)
More Related Contents:
- Avoiding NullPointerException in Java
- Sort on a string that may contain a number
- IllegalArgumentException or NullPointerException for a null parameter? [closed]
- Java Compare Two Lists
- Java Integer compareTo() – why use comparison vs. subtraction?
- How do you compare two version Strings in Java?
- How come invoking a (static) method on a null reference doesn’t throw NullPointerException?
- How to find unused/dead code in java projects [closed]
- Java null check why use == instead of .equals()
- Check chains of “get” calls for null
- How to check if my string is equal to null?
- Spark sql how to explode without losing null values
- Is null check needed before calling instanceof?
- Determine if two files store the same content
- Why do == comparisons with Integer.valueOf(String) give different results for 127 and 128?
- compareTo() vs. equals()
- Check if an ArrayList contains every element from another ArrayList (or Collection)
- Refactoring if/else logic
- What does comparison being consistent with equals mean ? What can possibly happen if my class doesn’t follow this principle?
- Should Optional.ofNullable() be used for null check?
- Check if an ArrayList contains every element from another ArrayList
- Is null an Object?
- How to use IntelliJ IDEA to find all unused code?
- Find unused classes in a Java Eclipse project
- Hibernate order by with nulls last
- Writing a new refactoring plugin for Eclipse?
- Understanding the difference between null and ‘\u000’ in Java
- Java: Exception itself is null
- How to instantiate Spring managed beans at runtime?
- When “” == s is false but “”.equals( s ) is true