PsiAnnotation (@NotNull PsiModifierListOwner psiModifierListOwner, @Nullable String value, String annotationClassName) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiModifierListOwner.getProject()); final PsiClass psiClass = PsiTreeUtil.getParentOfType(psiModifierListOwner, PsiClass.class); final String valueString = StringUtil.isNotEmpty(value) ? "(" + value + ")" : ""; return elementFactory.createAnnotationFromText("@" + annotationClassName + valueString, psiClass); }