object boolean java_Java JsonObject.getBoolean方法代码示例

该代码段展示了如何在Java中使用JsonObject的getBoolean方法获取JSON对象中的布尔值。在示例中,从JSON对象中提取了is_periodic字段,并根据其值决定发送不同类型的事件通知。
摘要由CSDN通过智能技术生成

import org.vertx.java.core.json.JsonObject; //导入方法依赖的package包/类

private void notifyBookingDeleted(final HttpServerRequest request, final UserInfos user,

final JsonObject booking, final String bookingId) {

final String owner = booking.getString("owner", null);

final String startDate = booking.getString("start_date", null);

final String endDate = booking.getString("end_date", null);

final boolean isPeriodic = booking.getBoolean("is_periodic");

final String resourceName = booking.getString("resource_name", null);

final String notificationName;

if (startDate == null || endDate == null ||

owner == null || owner.trim().isEmpty() ||

resourceName == null || resourceName.trim().isEmpty()) {

log.error("Could not get start_date, end_date, owner or resource_name from response. Unable to send timeline "+

BOOKING_DELETED_EVENT_TYPE + " or " + PERIODIC_BOOKING_DELETED_EVENT_TYPE + " notification.");

return;

}

// Notify only if current user is not the booking's owner

if(!owner.equals(user.getUserId())) {

if(isPeriodic) {

notificationName = "periodic-booking-deleted";

}

else {

notificationName = "booking-deleted";

}

JsonObject params = new JsonObject();

params.putString("username", user.getUsername())

.putString("uri", "/userbook/annuaire#" + user.getUserId() + "#" + user.getType())

.putString("startdate", startDate)

.putString("enddate", endDate)

.putString("resourcename", resourceName);

List recipients = new ArrayList<>();

recipients.add(owner);

notification.notifyTimeline(request, "rbs." + notificationName, user, recipients, bookingId, params);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值