本文整理了Java中akka.stream.javadsl.Source.orElse()
方法的一些代码示例,展示了Source.orElse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Source.orElse()
方法的具体详情如下:
包路径:akka.stream.javadsl.Source
类名称:Source
方法名:orElse
暂无
代码示例来源:origin: eclipse/ditto
private Source<Optional<Instant>, NotUsed> retrieveLastSuccessfulStreamEndAsync() {
return Source.fromPublisher(lastSuccessfulSearchSyncCollection.find())
.limit(1)
.flatMapConcat(doc -> {
final Date date = doc.getDate(FIELD_TIMESTAMP);
final Instant timestamp = date.toInstant();
LOGGER.debug("Returning last timestamp of search synchronization: <{}>.", timestamp);
return Source.single(Optional.of(timestamp));
})
.orElse(Source.single(Optional.empty()));
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-utils-persistence
private Source<Optional<Instant>, NotUsed> retrieveLastSuccessfulStreamEndAsync() {
return Source.fromPublisher(lastSuccessfulSearchSyncCollection.find())
.limit(1)
.flatMapConcat(doc -> {
final Date date = doc.getDate(FIELD_TIMESTAMP);
final Instant timestamp = date.toInstant();
LOGGER.debug("Returning last timestamp of search synchronization: <{}>.", timestamp);
return Source.single(Optional.of(timestamp));
})
.orElse(Source.single(Optional.empty()));
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence
/**
* {@inheritDoc}
*/
@Override
public final Source<ThingMetadata, NotUsed> getThingMetadata(final String thingId) {
log.debug("Retrieving Thing Metadata for Thing: <{}>", thingId);
final Bson filter = eq(FIELD_ID, thingId);
return Source.fromPublisher(collection.find(filter)
.projection(Projections.include(FIELD_REVISION, FIELD_POLICY_ID, FIELD_POLICY_REVISION)))
.map(mapThingMetadataToModel())
.orElse(defaultThingMetadata());
}
代码示例来源:origin: eclipse/ditto
/**
* {@inheritDoc}
*/
@Override
public final Source<ThingMetadata, NotUsed> getThingMetadata(final String thingId) {
log.debug("Retrieving Thing Metadata for Thing: <{}>", thingId);
final Bson filter = eq(FIELD_ID, thingId);
return Source.fromPublisher(collection.find(filter)
.projection(Projections.include(FIELD_REVISION, FIELD_POLICY_ID, FIELD_POLICY_REVISION)))
.map(mapThingMetadataToModel())
.orElse(defaultThingMetadata());
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence
@Override
public Source<Long, NotUsed> count(final PolicyRestrictedSearchAggregation policyRestrictedSearchAggregation) {
checkNotNull(policyRestrictedSearchAggregation, "policy restricted aggregation");
final Source<Document, NotUsed> source = policyRestrictedSearchAggregation.execute(collection, maxQueryTime);
return source.map(doc -> doc.get(PersistenceConstants.COUNT_RESULT_NAME))
.map(countResult -> (Number) countResult)
.map(Number::longValue) // use Number.longValue() to support both Integer and Long values
.orElse(Source.<Long>single(0L))
.mapError(handleMongoExecutionTimeExceededException())
.log("count");
}
代码示例来源:origin: eclipse/ditto
@Override
public Source<Long, NotUsed> count(final PolicyRestrictedSearchAggregation policyRestrictedSearchAggregation) {
checkNotNull(policyRestrictedSearchAggregation, "policy restricted aggregation");
final Source<Document, NotUsed> source = policyRestrictedSearchAggregation.execute(collection, maxQueryTime);
return source.map(doc -> doc.get(PersistenceConstants.COUNT_RESULT_NAME))
.map(countResult -> (Number) countResult)
.map(Number::longValue) // use Number.longValue() to support both Integer and Long values
.orElse(Source.<Long>single(0L))
.mapError(handleMongoExecutionTimeExceededException())
.log("count");
}
代码示例来源:origin: eclipse/ditto
.orElse(Source.single(ThingNotAccessibleException.newBuilder("").build()))
.filterNot(el -> el instanceof DittoRuntimeException)
.map(param -> thingPlainJsonSupplier.apply((Jsonifiable<?>) param))
内容来源于网络,如有侵权,请联系作者删除!