void (@NotNull PsiModifierListOwner targetElement, @NotNull PsiAnnotation newPsiAnnotation, String annotationClassName) { final PsiAnnotation presentAnnotation = PsiAnnotationSearchUtil.findAnnotation(targetElement, annotationClassName); final Project project = targetElement.getProject(); final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project); javaCodeStyleManager.shortenClassReferences(newPsiAnnotation); if (null == presentAnnotation) { PsiModifierList modifierList = targetElement.getModifierList(); if (null != modifierList) { modifierList.addAfter(newPsiAnnotation, null); } } else { presentAnnotation.setDeclaredAttributeValue(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME, newPsiAnnotation.findDeclaredAttributeValue(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME)); } }