本文整理汇总了Java中io.vertx.codegen.annotations.Nullable类的典型用法代码示例。如果您正苦于以下问题:Java Nullable类的具体用法?Java Nullable怎么用?Java Nullable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Nullable类属于io.vertx.codegen.annotations包,在下文中一共展示了Nullable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
private void handle(RoutingContext rc) {
@Nullable JsonObject json = rc.getBodyAsJson();
if (json == null || json.getDouble("amount") == null) {
System.out.println("No content or no amount");
rc.fail(400);
return;
}
double amount = json.getDouble("amount");
String target = json.getString("currency");
if (target == null) {
target = "EUR";
}
double rate = getRate(target);
if (rate == -1) {
System.out.println("Unknown currency: " + target);
rc.fail(400);
}
int i = random.nextInt(10);
if (i < 5) {
rc.response().end(new JsonObject()
.put("amount", convert(amount, rate))
.put("currency", target).encode()
);
} else if (i < 8) {
// Failure
rc.fail(500);
}
// Timeout, we don't write the response.
}
示例2: methodWithListNullableStringReturn
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public List<@Nullable String> methodWithListNullableStringReturn() {
ArrayList<String> ret = new ArrayList<>();
ret.add("first");
ret.add(null);
ret.add("third");
return ret;
}
示例3: removeDocumentsWithOptions
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public MongoClient removeDocumentsWithOptions(String collection, JsonObject query, @Nullable WriteOption writeOption, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler) {
requireNonNull(collection, "collection cannot be null");
requireNonNull(query, "query cannot be null");
requireNonNull(resultHandler, "resultHandler cannot be null");
MongoCollection<JsonObject> coll = getCollection(collection, writeOption);
Bson bquery = wrap(encodeKeyWhenUseObjectId(query));
coll.deleteMany(bquery, toMongoClientDeleteResult(resultHandler));
return this;
}
示例4: getCollection
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
private MongoCollection<JsonObject> getCollection(String name, @Nullable WriteOption writeOption) {
MongoCollection<JsonObject> coll = holder.db.getCollection(name, JsonObject.class);
if (coll != null && writeOption != null) {
coll = coll.withWriteConcern(WriteConcern.valueOf(writeOption.name()));
}
return coll;
}
示例5: methodWithNullableJsonObjectReturn
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public @Nullable JsonObject methodWithNullableJsonObjectReturn(boolean notNull) {
if (notNull) {
return new JsonObject().put("foo", "wibble").put("bar", 3);
} else {
return null;
}
}
示例6: bodyAsJsonObject
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
/**
* @return the response body decoded as a json object
*/
@CacheReturn
@Nullable
default JsonObject bodyAsJsonObject() {
Buffer b = bodyAsBuffer();
return b != null ? BodyCodecImpl.JSON_OBJECT_DECODER.apply(b) : null;
}
示例7: subtag
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public @Nullable String subtag(int level) {
ensureHeaderProcessed();
if(level < parsedValues.size()){
return parsedValues.get(level);
}
return null;
}
示例8: methodWithNullableListJsonObjectReturn
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public @Nullable List<JsonObject> methodWithNullableListJsonObjectReturn(boolean notNull) {
if (notNull) {
return Arrays.asList(new JsonObject().put("foo", "bar"), new JsonObject().put("juu", 3));
} else {
return null;
}
}
示例9: methodWithNullableListCharReturn
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public @Nullable List<Character> methodWithNullableListCharReturn(boolean notNull) {
if (notNull) {
return Arrays.asList('x', 'y', 'z');
} else {
return null;
}
}
示例10: getAlias
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
private @Nullable String getAlias() {
return context.request().getParam("alias");
}
示例11: endHandler
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public HttpServerResponse endHandler(@Nullable Handler<Void> handler) {
serverResponse.endHandler(handler);
return null;
}
示例12: methodWithNullableListGenEnumHandlerAsyncResult
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public void methodWithNullableListGenEnumHandlerAsyncResult(boolean notNull, Handler<AsyncResult<@Nullable List<TestGenEnum>>> handler) {
handler.handle(Future.succeededFuture(methodWithNullableListGenEnumReturn(notNull)));
}
示例13: methodWithSetNullableLongHandlerAsyncResult
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Override
public void methodWithSetNullableLongHandlerAsyncResult(Handler<AsyncResult<Set<@Nullable Long>>> handler) {
handler.handle(Future.succeededFuture(methodWithSetNullableLongReturn()));
}
示例14: toBson
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Nullable
private static Bson toBson(@Nullable JsonObject json) {
return json == null ? null : BsonDocument.parse(json.encode());
}
示例15: wrap
import io.vertx.codegen.annotations.Nullable; //导入依赖的package包/类
@Nullable
private JsonObjectBsonAdapter wrap(@Nullable JsonObject jsonObject) {
return jsonObject == null ? null : new JsonObjectBsonAdapter(jsonObject);
}