private static void writeBuildIdentifier(final IonWriter writer,
                                           final WriteContext context,
                                           final BuildIdentifier buildIdentifier) throws IOException {
    writer.setFieldName("buildIdentifier");
    context.buildIdentifiersCollector.add(buildIdentifier, 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) {
          writeFile(writer, "rootDir", buildIdentifier.getRootDir());
        }
        writer.stepOut();
      }
    });
  }
private static void writeBuildIdentifier(final IonWriter writer,
                                           final WriteContext context,
                                           final BuildIdentifier buildIdentifier)