private static void rebuildElementsBeforeExistingFields(Project project, PsiClass psiClass, List<? super PsiElement> psiElements) {
    //add generated elements in generated/declaration order, but before existing Fields
    if (!psiElements.isEmpty()) {
      final PsiField existingField = PsiClassUtil.collectClassFieldsIntern(psiClass).stream().findFirst().orElse(null);
      Iterator<? super PsiElement> iterator = psiElements.iterator();
      PsiElement prev = psiClass.addBefore(rebuildPsiElement(project, (PsiElement)iterator.next()), existingField);
      while (iterator.hasNext()) {
        PsiElement curr = rebuildPsiElement(project, (PsiElement)iterator.next());
        if (curr != null) {
          prev = psiClass.addAfter(curr, prev);
        }
      }
    }
  }
private static void rebuildElementsBeforeExistingFields(Project project, PsiClass psiClass, List<? super PsiElement> psiElements)