Java: use getField() instead of getAllFields() to get enum constants

GitOrigin-RevId: b16e164b1f42e642d6422de7c8badbb677c20e0b
This commit is contained in:
Bas Leijdekkers
2024-08-21 09:12:08 +00:00
committed by intellij-monorepo-bot
parent 2a0ccb7079
commit 3d38ad9549
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2017 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2024 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,7 +90,7 @@ public final class EnumSwitchStatementWhichMissesCasesInspection extends Abstrac
if (expression == null) return;
final PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(expression.getType());
if (aClass == null || !aClass.isEnum()) return;
Set<String> constants = StreamEx.of(aClass.getAllFields()).select(PsiEnumConstant.class).map(PsiEnumConstant::getName)
Set<String> constants = StreamEx.of(aClass.getFields()).select(PsiEnumConstant.class).map(PsiEnumConstant::getName)
.toCollection(LinkedHashSet::new);
if (constants.isEmpty()) return;
boolean hasDefault = false;