PsiMethod (@NotNull PsiField psiField, @NotNull String methodModifier, @NotNull AccessorsInfo accessorsInfo) { LombokLightMethodBuilder methodBuilder = null; final PsiClass psiFieldContainingClass = psiField.getContainingClass(); if (psiFieldContainingClass != null) { final PsiType returnType = PsiClassUtil.getTypeWithGenerics(psiFieldContainingClass); methodBuilder = new LombokLightMethodBuilder(psiField.getManager(), LombokUtils.getWitherName(psiField, accessorsInfo)) .withMethodReturnType(returnType) .withContainingClass(psiFieldContainingClass) .withNavigationElement(psiField) .withModifier(methodModifier) .withPureContract(); if (accessorsInfo.isMakeFinal()) { methodBuilder.withModifier(PsiModifier.FINAL); } PsiAnnotation witherAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, LombokClassNames.WITHER, LombokClassNames.WITH); LombokCopyableAnnotations.copyOnXAnnotations(witherAnnotation, methodBuilder.getModifierList(), "onMethod"); final String psiFieldName = psiField.getName(); final PsiType psiFieldType = psiField.getType(); final LombokLightParameter methodParameter = new LombokLightParameter(psiFieldName, psiFieldType, methodBuilder); methodBuilder.withParameter(methodParameter); LombokLightModifierList methodParameterModifierList = methodParameter.getModifierList(); LombokCopyableAnnotations.copyCopyableAnnotations(psiField, methodParameterModifierList, LombokCopyableAnnotations.BASE_COPYABLE); LombokCopyableAnnotations.copyOnXAnnotations(witherAnnotation, methodParameterModifierList, "onParam"); if (psiFieldContainingClass.hasModifierProperty(PsiModifier.ABSTRACT)) { methodBuilder.withModifier(PsiModifier.ABSTRACT); } else { final String paramString = getConstructorCall(psiField, psiFieldContainingClass); final String blockText = String.format("return this.%s == %s ? this : new %s(%s);", psiFieldName, psiFieldName, returnType.getCanonicalText(), paramString); methodBuilder.withBodyText(blockText); } LombokAddNullAnnotations.createRelevantNonNullAnnotation(psiFieldContainingClass, methodBuilder); } return methodBuilder; }