PsiField (@NotNull Project project, @NotNull PsiField fromField) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); final PsiField resultField; if (fromField instanceof PsiEnumConstant) { resultField = elementFactory.createEnumConstantFromText(fromField.getName(), fromField.getContext()); } else { resultField = elementFactory.createField(fromField.getName(), fromField.getType()); resultField.setInitializer(fromField.getInitializer()); } copyModifiers(fromField.getModifierList(), resultField.getModifierList()); return resultField; }