下面列出了怎么用com.mongodb.lang.Nullable的API类实例代码及写法,或者点击链接到github查看源代码。
@Substitute
private List<MongoCompressor> buildCompressors(final String compressors, @Nullable final Integer zlibCompressionLevel) {
List<MongoCompressor> compressorsList = new ArrayList<>();
for (String cur : compressors.split(",")) {
if (cur.equals("zlib")) {
MongoCompressor zlibCompressor = MongoCompressor.createZlibCompressor();
zlibCompressor = zlibCompressor.withProperty(MongoCompressor.LEVEL, zlibCompressionLevel);
compressorsList.add(zlibCompressor);
} else if (cur.equals("snappy")) {
// DO NOTHING
} else if (!cur.isEmpty()) {
throw new IllegalArgumentException("Unsupported compressor '" + cur + "'");
}
}
return unmodifiableList(compressorsList);
}
@Override
public Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable QueryLookupStrategy.Key key,
QueryMethodEvaluationContextProvider evaluationContextProvider) {
Optional<QueryLookupStrategy> parentQueryLookupStrategy = super.getQueryLookupStrategy(key, evaluationContextProvider);
Assert.isTrue(parentQueryLookupStrategy.isPresent(), "Expecting parent lookup strategy");
return Optional.of(new AggregateQueryLookupStrategy(parentQueryLookupStrategy.get()));
}
/**
* Equivalent to a $text operand.
*
* @param search the search terms to apply to the text index.
* @param language the language to use.
* @return {@code this}
* @mongodb.server.release 2.6
*/
public QueryBuilder text(final String search, @Nullable final String language) {
if (currentKey != null) {
throw new QueryBuilderException("The text operand may only occur at the top-level of a query. It does"
+ " not apply to a specific element, but rather to a document as a whole.");
}
put(QueryOperators.TEXT);
addOperand(QueryOperators.SEARCH, search);
if (language != null) {
addOperand(QueryOperators.LANGUAGE, language);
}
return this;
}
final void add(@Nullable final WriteModel<DocumentT> write) {
if (write == null) {
return;
}
this.bulkWriteModels.add(write);
}
final void merge(@Nullable final WriteModelContainer<CollectionT, DocumentT> container) {
if (container == null) {
return;
}
this.bulkWriteModels.addAll(container.bulkWriteModels);
}
@Nullable
abstract BsonDocument bucket();
@Override
@Nullable
public ServerAddress getPinnedServerAddress() {
return session.getPinnedServerAddress();
}
@Override
@Nullable
public BsonDocument getRecoveryToken() {
return session.getRecoveryToken();
}