Inspectopedia Help

Overlapping Enumeration Constants

Overlapping Enumeration Constants

The @IntDef annotation allows you to create a light-weight "enum" or type definition. However, it's possible to accidentally specify the same value for two or more of the values, which can lead to hard-to-detect bugs. This check looks for this scenario and flags any repeated constants.

In some cases, the repeated constant is intentional (for example, renaming a constant to a more intuitive name, and leaving the old name in place for compatibility purposes). In that case, simply suppress this check by adding a @SuppressLint("UniqueConstants") annotation.

Issue id: UniqueConstants

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for Android 2023.3, Qodana for JVM 2023.3


Android, 2022.3.1 Beta 2

Last modified: 13 July 2023