本文整理汇总了Java中com.theoryinpractise.halbuilder.api.Representation.withBean方法的典型用法代码示例。如果您正苦于以下问题:Java Representation.withBean方法的具体用法?Java Representation.withBean怎么用?Java Representation.withBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.theoryinpractise.halbuilder.api.Representation
的用法示例。
在下文中一共展示了Representation.withBean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newSlotsRepresentation
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
public Representation newSlotsRepresentation(List<Slot> slots) {
UriBuilder slotsUriBuilder = newSlotsUriBuilder();
Representation rep = newRepresentation(slotsUriBuilder.build());
rep = rep.withBean(slots);
int numSlots = slots.size();
UriBuilder slotUriBuilder = newSlotUriBuilder();
for (int i = 0; i < numSlots; i++) {
Optional<Slot> previousSlot = Optional.empty();
Optional<Slot> nextSlot = Optional.empty();
if (i - 1 >= 0) {
previousSlot = Optional.of(slots.get(i - 1));
}
if (i + 1 < numSlots) {
nextSlot = Optional.of(slots.get(i + 1));
}
rep.withRepresentation("slots",
newSlotRepresentation(slots.get(i), previousSlot, nextSlot));
rep.withLink("item", slotUriBuilder.build(slots.get(i).getId())
.toString());
}
if (numSlots > 0) {
rep.withLink("start", slotUriBuilder.build(slots.get(0).getId())
.toString());
}
return rep;
}
示例2: newAppointmentRepresentation
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
public Representation newAppointmentRepresentation(Appointment appt) {
UriBuilder apptUriBuilder = newAppointmentUriBuilder();
Representation rep = newRepresentation(apptUriBuilder.build(
appt.getId()).toString());
rep.withLink("edit", apptUriBuilder.build(appt.getId()).toString(),
"cancel", "cancel", null, null);
rep.withBean(appt);
return rep;
}