Is this a good design pattern to enforce a class not being used in any hash-based collection (HashMap
, HashSet
, etc), or could this have unintended consequences?
class DoNotUseInHashBasedCollection {
@Override
public int hashCode() {
throw new UnsupportedOperationException();
}
}