Improve equals() of Java definition class