DiscouragedHashKey
This type should not be used as an element of a hash-based Set, or a key of a hash-based Map, Multimap, or Multiset

Severity
WARNING

The problem

Hash-based containers call equals and hashCode on their elements and keys. Some types are not suitable for this even though their equals and hashCode methods are well-defined, for example because they are expensive to hash, or because instances that represent the same logical value don’t compare equal.

This check reports elements of hash-based Sets, and keys of hash-based Maps, Multimaps, and Multisets, whose types have been configured as unsuitable hash keys. Prefer keying on a stable identifier for the value, or using a non-hash-based container.

Options

Types whose equals methods are not meaningful, such as arrays or Collection, are handled by UndefinedEquals instead.

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("DiscouragedHashKey") to the enclosing element.