Optional<PsiMethod> (@NotNull PsiClass containingClass, @NotNull PsiClass builderBaseClass, @NotNull PsiClass builderImplClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiClassType psiTypeBaseWithGenerics) { final String builderMethodName = getBuilderMethodName(psiAnnotation); if (builderMethodName.isEmpty() || hasMethod(containingClass, builderMethodName)) { return Optional.empty(); } final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(containingClass.getManager(), builderMethodName) .withMethodReturnType(psiTypeBaseWithGenerics) .withContainingClass(containingClass) .withNavigationElement(psiAnnotation) .withModifier(PsiModifier.PUBLIC) .withModifier(PsiModifier.STATIC); addTypeParameters(containingClass, null, methodBuilder); final String blockText = String.format("return new %s();", PsiClassUtil.getTypeWithGenerics(builderImplClass).getCanonicalText(false)); methodBuilder.withBodyText(blockText); createRelevantNonNullAnnotation(containingClass, methodBuilder); return Optional.of(methodBuilder); }