void (StringBuilder text, @Nullable PsiModifierList modifierList, boolean isInterface, boolean isEnum, boolean toplevel, boolean generateAnnotations) { if (modifierList == null) { text.append("public "); return; } List<String> allowedModifiers = new ArrayList<>(); allowedModifiers.add(PsiModifier.PUBLIC); if (!isEnum) allowedModifiers.add(PsiModifier.FINAL); if (!toplevel) { allowedModifiers.addAll(Arrays.asList(PsiModifier.PROTECTED, PsiModifier.PRIVATE, PsiModifier.STATIC)); } if (!isInterface && !isEnum) { allowedModifiers.add(PsiModifier.ABSTRACT); } writeModifiers(text, modifierList, ArrayUtilRt.toStringArray(allowedModifiers), generateAnnotations); }