Collection<PsiMethod> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass implBuilderClass) { Collection<PsiMethod> result = new ArrayList<>(); final Collection<String> existedMethodNames = ContainerUtil.map2Set(PsiClassUtil.collectClassMethodsIntern(implBuilderClass), PsiMethod::getName); final String builderImplClassName = StringUtil.notNullize(implBuilderClass.getName()); final PsiManager psiManager = psiClass.getManager(); if (!existedMethodNames.contains(builderImplClassName)) { //create private no args constructor final LombokLightMethodBuilder privateConstructor = new LombokLightMethodBuilder(psiManager, builderImplClassName) .withConstructor(true) .withContainingClass(implBuilderClass) .withNavigationElement(psiClass) .withModifier(PsiModifier.PRIVATE) .withBodyText(""); result.add(privateConstructor); } if (!existedMethodNames.contains(SELF_METHOD)) { // create 'self' method final LombokLightMethodBuilder selfMethod = new LombokLightMethodBuilder(psiManager, SELF_METHOD) .withMethodReturnType(PsiClassUtil.getTypeWithGenerics(implBuilderClass)) .withContainingClass(implBuilderClass) .withNavigationElement(psiClass) .withModifier(PsiModifier.PROTECTED) .withBodyText("return this;"); result.add(selfMethod); } final String buildMethodName = getBuildMethodName(psiAnnotation); if (!existedMethodNames.contains(buildMethodName)) { // create 'build' method final PsiType builderType = getReturnTypeOfBuildMethod(psiClass, null); final PsiSubstitutor builderSubstitutor = getBuilderSubstitutor(psiClass, implBuilderClass); final PsiType returnType = builderSubstitutor.substitute(builderType); final LombokLightMethodBuilder buildMethod = new LombokLightMethodBuilder(psiManager, buildMethodName) .withMethodReturnType(returnType) .withContainingClass(implBuilderClass) .withNavigationElement(psiClass) .withModifier(PsiModifier.PUBLIC); final String buildCodeBlockText = String.format("return new %s(this);", PsiClassUtil.getTypeWithGenerics(psiClass).getCanonicalText(false)); buildMethod.withBodyText(buildCodeBlockText); createRelevantNonNullAnnotation(psiClass, buildMethod); result.add(buildMethod); } return result; }