private static void writeGradleTask(final IonWriter writer,
                                      final WriteContext context,
                                      @Nullable final GradleTask task)
    throws IOException {
    if (task == null) {
      writer.writeNull();
      return;
    }
    context.gradleTasksCollector.add(task, new ObjectCollector.Processor<IOException>() {
      @Override
      public void process(boolean isAdded, int objectId) throws IOException {
        writer.stepIn(IonType.STRUCT);
        writer.setFieldName(OBJECT_ID_FIELD);
        writer.writeInt(objectId);
        if (isAdded) {
          writeString(writer, "name", task.getName());
          writeString(writer, "description", task.getDescription());
          writeString(writer, "path", task.getPath());
          writeString(writer, "group", task.getGroup());
          writeString(writer, "displayName", task.getDisplayName());
          writeBoolean(writer, "isPublic", task.isPublic());
          writeProjectIdentifier(writer, context, task.getProjectIdentifier());
          writeGradleProject(writer, "project", context, task.getProject());
        }
        writer.stepOut();
      }
    });
  }
private static void writeGradleTask(final IonWriter writer,
                                      final WriteContext context,
                                      @Nullable final GradleTask task)