I\'m implementing compareTo()
method for a simple class such as this (to be able to use Collections.sort()
and other goodies offered by the Java pl
You could design your class to be immutable (Effective Java 2nd Ed. has a great section on this, Item 15: Minimize mutability) and make sure upon construction that no nulls are possible (and use the null object pattern if needed). Then you can skip all those checks and safely assume the values are not null.