當前位置: 首頁>>代碼示例>>Java>>正文


Java StreamId.ALL屬性代碼示例

本文整理匯總了Java中org.fuin.esc.api.StreamId.ALL屬性的典型用法代碼示例。如果您正苦於以下問題:Java StreamId.ALL屬性的具體用法?Java StreamId.ALL怎麽用?Java StreamId.ALL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.fuin.esc.api.StreamId的用法示例。


在下文中一共展示了StreamId.ALL屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readEventsForward

@Override
public final StreamEventsSlice readEventsForward(final StreamId streamId,
        final int start, final int count) {

    Contract.requireArgNotNull("streamId", streamId);
    Contract.requireArgMin("start", start, 0);
    Contract.requireArgMin("count", count, 1);
    ensureOpen();

    final List<CommonEvent> events;
    if (streamId == StreamId.ALL) {
        events = all;
    } else {
        events = getStream(streamId, ExpectedVersion.ANY.getNo())
                .getEvents();
    }

    final List<CommonEvent> result = new ArrayList<CommonEvent>();
    for (int i = start; (i < (start + count)) && (i < events.size()); i++) {
        result.add(events.get(i));
    }
    final int fromEventNumber = start;
    final int nextEventNumber = (start + result.size());
    final boolean endOfStream = (result.size() < count);

    return new StreamEventsSlice(fromEventNumber, result, nextEventNumber,
            endOfStream);

}
 
開發者ID:fuinorg,項目名稱:event-store-commons,代碼行數:29,代碼來源:InMemoryEventStore.java

示例2: readEventsBackward

@Override
public final StreamEventsSlice readEventsBackward(final StreamId streamId,
        final int start, final int count) {

    Contract.requireArgNotNull("streamId", streamId);
    Contract.requireArgMin("start", start, 0);
    Contract.requireArgMin("count", count, 1);
    ensureOpen();

    final List<CommonEvent> events;
    if (streamId == StreamId.ALL) {
        events = all;
    } else {
        events = getStream(streamId, ExpectedVersion.ANY.getNo())
                .getEvents();
    }

    final List<CommonEvent> result = new ArrayList<CommonEvent>();
    if (start < events.size()) {
        for (int i = start; (i > (start - count)) && (i >= 0); i--) {
            result.add(events.get(i));
        }
    }

    final int fromEventNumber = start;
    int nextEventNumber = start - result.size();
    if (nextEventNumber < 0) {
        nextEventNumber = 0;
    }
    final boolean endOfStream = (start - count) < 0;

    return new StreamEventsSlice(fromEventNumber, result, nextEventNumber,
            endOfStream);
}
 
開發者ID:fuinorg,項目名稱:event-store-commons,代碼行數:34,代碼來源:InMemoryEventStore.java

示例3: deleteStream

@Override
public final void deleteStream(final StreamId streamId, final int expected,
        final boolean hardDelete) {

    Contract.requireArgNotNull("streamId", streamId);
    ensureOpen();

    if (streamId.isProjection()) {
        throw new StreamReadOnlyException(streamId);
    }
    if (streamId == StreamId.ALL) {
        throw new IllegalArgumentException(
                "It's not possible to delete the 'all' stream");
    }

    final InternalStream stream = streams.get(streamId);
    if (stream == null) {
        // Stream never existed
        if (expected == ExpectedVersion.ANY.getNo()
                || expected == ExpectedVersion.NO_OR_EMPTY_STREAM.getNo()) {
            if (hardDelete) {
                final InternalStream hds = new InternalStream();
                hds.delete(hardDelete);
                streams.put(streamId, hds);
            }
            // Ignore
            return;
        }
        throw new WrongExpectedVersionException(streamId, expected, null);
    }
    if (stream.getState() == StreamState.SOFT_DELETED) {
        // Ignore
        return;
    }
    if (stream.getState() == StreamState.HARD_DELETED) {
        throw new StreamDeletedException(streamId);
    }
    // StreamState.ACTIVE
    if (expected != ExpectedVersion.ANY.getNo()
            && expected != stream.getVersion()) {
        throw new WrongExpectedVersionException(streamId, expected,
                stream.getVersion());
    }
    stream.delete(hardDelete);

}
 
開發者ID:fuinorg,項目名稱:event-store-commons,代碼行數:46,代碼來源:InMemoryEventStore.java


注:本文中的org.fuin.esc.api.StreamId.ALL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。