private PsiMethod generateMethodFor(
      PsiField field, String methodName, String parameterName, PsiElementFactory elementFactory) {
    PsiMethod withMethod =
        elementFactory.createMethod(
            methodName, elementFactory.createType(field.getContainingClass()));
    PsiParameter parameter = elementFactory.createParameter(parameterName, field.getType());
    withMethod.getParameterList().add(parameter);
    PsiUtil.setModifierProperty(withMethod, PsiModifier.PUBLIC, true);

    return withMethod;
  }
  private PsiMethod generateMethodBodyFor(
      PsiMethod method,
      String propertyName,
      String parameterName,
      PsiElementFactory elementFactory) {
    StringBuilder methodBodyBuilder =
        new StringBuilder()
            .append("{\n")
            .append("this.")
            .append(propertyName)
            .append("=")
            .append(parameterName)
            .append(";\n")
            .append("return this;\n")
            .append("}\n");

    PsiCodeBlock methodBody =
        elementFactory.createCodeBlockFromText(methodBodyBuilder.toString(), null);
    method.getBody().replace(methodBody);
    method = (PsiMethod) CodeStyleManager.getInstance(method.getProject()).reformat(method);
    return method;
  }