Optional<PsiMethod> (@NotNull PsiClass psiClass, @NotNull PsiClass builderClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiClassType psiTypeBaseWithGenerics) { final String className = psiClass.getName(); if (null == className) { return Optional.empty(); } final Collection<PsiMethod> existedConstructors = PsiClassUtil.collectClassConstructorIntern(psiClass); if (ContainerUtil.exists(existedConstructors, psiMethod -> psiMethod.getParameterList().getParametersCount() == 1)) { return Optional.empty(); } LombokLightMethodBuilder constructorBuilderBased = new LombokLightMethodBuilder(psiClass.getManager(), className) .withConstructor(true) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withModifier(PsiModifier.PROTECTED) .withParameter(BUILDER_VARIABLE_NAME, psiTypeBaseWithGenerics); final List<BuilderInfo> builderInfos = createBuilderInfos(psiClass, psiAnnotation, builderClass); //dont need initBuilderInfosBuilderClassType here final String buildMethodPrepare = builderInfos.stream() .map(BuilderInfo::renderSuperBuilderConstruction) .collect(Collectors.joining()); final String codeBlock; final PsiClass superClass = psiClass.getSuperClass(); if (null != superClass && !"Object".equals(superClass.getName())) { codeBlock = "super(b);\n" + buildMethodPrepare; } else { codeBlock = buildMethodPrepare; } constructorBuilderBased.withBodyText(codeBlock); return Optional.of(constructorBuilderBased); }