Your class violates the contract of equals and hashCode in two ways:
1) equals should return false if the object is of an incompatible class, not throw a ClassCastException as your class will. Add a check:
2) You need to implement hashCode as well. The easiest solution:
For more information, read Object.equals(Object) and Object.hashCode().