/** * Wraps courser only if it is not already wrapped. * * @param source Index which is used to create given cursor. * @param cursor Cursor to wrap. * @param indexRebuildVersion Rebuild version of index <b>before</b> cursor was created. * @return Wrapped cursor. * @see OIndex#getRebuildVersion() */ public static OIndexCursor wrap(OIndex<?> source, OIndexCursor cursor, long indexRebuildVersion) { if (cursor instanceof OIndexChangesWrapper) return cursor; if (cursor instanceof OSizeable) { return new OIndexChangesSizeable(source, cursor, indexRebuildVersion); } return new OIndexChangesWrapper(source, cursor, indexRebuildVersion); }
/** * {@inheritDoc} */ @Override public boolean hasNext() { if (source.isRebuilding()) throwRebuildException(); final boolean isNext = delegate.hasNext(); if (source.getRebuildVersion() != indexRebuildVersion) throwRebuildException(); return isNext; }
cursors.add(OIndexChangesWrapper.wrap(index, cursor, indexRebuildVersion)); if (nullValue instanceof Collection) cursors.add(OIndexChangesWrapper .wrap(index, new OIndexCursorCollectionValue((Collection) nullValue, null), indexRebuildVersion)); else cursors.add(OIndexChangesWrapper .wrap(index, new OIndexCursorSingleValue((OIdentifiable) nullValue, null), indexRebuildVersion));
cursors.add(OIndexChangesWrapper.wrap(index, cursor, indexRebuildVersion)); indexUseAttempts.add(new IndexUsageLog(index, keyParams, indexDefinition)); indexUsed = true;
/** * {@inheritDoc} */ @Override public Set<OIdentifiable> toValues() { if (source.isRebuilding()) throwRebuildException(); final Set<OIdentifiable> values = delegate.toValues(); if (source.getRebuildVersion() != indexRebuildVersion) throwRebuildException(); return values; }
cursors.add(OIndexChangesWrapper.wrap(index, cursor, indexRebuildVersion)); indexUseAttempts.add(new IndexUsageLog(index, keyParams, indexDefinition)); indexUsed = true;
/** * {@inheritDoc} */ @Override public Set<Map.Entry<Object, OIdentifiable>> toEntries() { if (source.isRebuilding()) throwRebuildException(); final Set<Map.Entry<Object, OIdentifiable>> entries = delegate.toEntries(); if (source.getRebuildVersion() != indexRebuildVersion) throwRebuildException(); return entries; }
/** * {@inheritDoc} */ @Override public OIdentifiable next() { if (source.isRebuilding()) throwRebuildException(); final OIdentifiable next = delegate.next(); if (source.getRebuildVersion() != indexRebuildVersion) throwRebuildException(); return next; }
/** * {@inheritDoc} */ @Override public Map.Entry<Object, OIdentifiable> nextEntry() { if (source.isRebuilding()) throwRebuildException(); final Map.Entry<Object, OIdentifiable> entry = delegate.nextEntry(); if (source.getRebuildVersion() != indexRebuildVersion) throwRebuildException(); return entry; }
/** * {@inheritDoc} */ @Override public Set<Object> toKeys() { if (source.isRebuilding()) throwRebuildException(); final Set<Object> keys = delegate.toKeys(); if (source.getRebuildVersion() != indexRebuildVersion) throwRebuildException(); return keys; }