本文整理匯總了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);
}
示例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);
}
示例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);
}