Array can be replaced with enum values
Reports arrays of enum constants that can be replaced with a call to EnumType.values()
.
Usually, when updating such an enum, you have to update the array as well. However, if you use EnumType.values()
instead, no modifications are required.
Example:
enum States {
NOT_RUN, IN_PROGRESS, FINISHED;
}
handleStates(new States[] {NOT_RUN, IN_PROGRESS, FINISHED});
After the quick-fix is applied:
handleStates(States.values());
New in 2019.1
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023