private static void checkEqualFunctionNames( @NotNull PsiNamedElement namedElement, @NotNull JavaMethod method) { if (!ComparatorUtil.equalsNullable(method.getName().asString(), namedElement.getName())) { throw new AlternativeSignatureMismatchException( "Function names mismatch, original: %s, alternative: %s", method.getName().asString(), namedElement.getName()); } }
/** * @return true if {@code method} is a static method of enum class, which is to be put into its * class object (and not into the corresponding package). This applies to values() and * valueOf(String) methods */ public static boolean shouldBeInEnumClassObject(@NotNull JavaMethod method) { if (!method.getContainingClass().isEnum()) return false; String signature = JavaSignatureFormatter.getInstance().formatMethod(method); return "values()".equals(signature) || "valueOf(java.lang.String)".equals(signature); }
private static boolean hasStaticMembers(@NotNull JavaClass javaClass) { for (JavaMethod method : javaClass.getMethods()) { if (method.isStatic() && !shouldBeInEnumClassObject(method)) { return true; } } for (JavaField field : javaClass.getFields()) { if (field.isStatic() && !field.isEnumEntry()) { return true; } } for (JavaClass nestedClass : javaClass.getInnerClasses()) { if (SingleAbstractMethodUtils.isSamInterface(nestedClass)) { return true; } if (nestedClass.isStatic() && hasStaticMembers(nestedClass)) { return true; } } return false; }