core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java
@Override
  public ODocument toStream() {
    internalAcquireExclusiveLock();
    try {
      document.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);

      try {
        final OTrackedSet<ODocument> indexes = new OTrackedSet<>(document);

        for (final OIndex<?> i : this.indexes.values()) {
          indexes.add(((OIndexInternal<?>) i).updateConfiguration());
        }
        document.field(CONFIG_INDEXES, indexes, OType.EMBEDDEDSET);

      } finally {
        document.setInternalStatus(ORecordElement.STATUS.LOADED);
      }
      document.setDirty();

      return document;
    } finally {
      internalReleaseExclusiveLock();
    }
  }
@Override
  public ODocument toStream() {
    internalAcquireExclusiveLock();
    try {
      document.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);

      try {
        final OTrackedSet<ODocument> indexes = new OTrackedSet<>(document);

        for (final OIndex<?> i : this.indexes.values()) {
          indexes.add(((OIndexInternal<?>) i).updateConfiguration());
        }
        document.field(CONFIG_INDEXES, indexes, OType.EMBEDDEDSET);

      } finally {
        document.setInternalStatus(ORecordElement.STATUS.LOADED);
      }
      document.setDirty();

      return document;
    } finally {
      internalReleaseExclusiveLock();
    }
  }
Binds POJO to ODocument.