Optional<PsiMethod> (@NotNull PsiClass containingClass, @Nullable PsiMethod psiMethod, @NotNull PsiClass builderPsiClass, @NotNull PsiAnnotation psiAnnotation) { final String builderMethodName = getBuilderMethodName(psiAnnotation); if (!builderMethodName.isEmpty() && !hasMethod(containingClass, builderMethodName)) { final PsiType psiTypeWithGenerics = PsiClassUtil.getTypeWithGenerics(builderPsiClass); final String blockText = String.format("return new %s();", psiTypeWithGenerics.getCanonicalText(false)); final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(containingClass.getManager(), builderMethodName) .withMethodReturnType(psiTypeWithGenerics) .withContainingClass(containingClass) .withNavigationElement(psiAnnotation) .withModifier(getBuilderOuterAccessVisibility(psiAnnotation)) .withBodyText(blockText); addTypeParameters(builderPsiClass, psiMethod, methodBuilder); if (null == psiMethod || psiMethod.isConstructor() || psiMethod.hasModifierProperty(PsiModifier.STATIC)) { methodBuilder.withModifier(PsiModifier.STATIC); } createRelevantNonNullAnnotation(containingClass, methodBuilder); return Optional.of(methodBuilder); } return Optional.empty(); }