本文整理了Java中org.springframework.hateoas.Resource.add
方法的一些代码示例,展示了Resource.add
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.add
方法的具体详情如下:
包路径:org.springframework.hateoas.Resource
类名称:Resource
方法名:add
暂无
代码示例来源:origin: spring-projects/spring-hateoas
/**
* Creates a new {@link Resource} with the given content and {@link Link}s.
*
* @param content must not be {@literal null}.
* @param links the links to add to the {@link Resource}.
*/
public Resource(T content, Iterable<Link> links) {
Assert.notNull(content, "Content must not be null!");
Assert.isTrue(!(content instanceof Collection), "Content must not be a collection! Use Resources instead!");
this.content = content;
this.add(links);
}
代码示例来源:origin: odrotbohm/spring-restbucks
@Override
public Resource<Order> process(Resource<Order> resource) {
Order order = resource.getContent();
if (!order.isPaid()) {
resource.add(paymentLinks.getPaymentLink(order));
}
if (order.isReady()) {
resource.add(paymentLinks.getReceiptLink(order));
}
return resource;
}
}
代码示例来源:origin: odrotbohm/spring-restbucks
@Override
public Resource<Order> process(Resource<Order> resource) {
Order order = resource.getContent();
if (!order.isPaid()) {
resource.add(entityLinks.linkForSingleResource(order).withRel(CANCEL_REL));
resource.add(entityLinks.linkForSingleResource(order).withRel(UPDATE_REL));
}
return resource;
}
}
代码示例来源:origin: odrotbohm/spring-restbucks
/**
* Renders the given {@link Receipt} including links to the associated {@link Order} as well as a self link in case
* the {@link Receipt} is still available.
*
* @param receipt
* @return
*/
private HttpEntity<Resource<Receipt>> createReceiptResponse(Receipt receipt) {
Order order = receipt.getOrder();
Resource<Receipt> resource = new Resource<>(receipt);
resource.add(entityLinks.linkToSingleResource(order));
if (!order.isTaken()) {
resource.add(entityLinks.linkForSingleResource(order).slash("receipt").withSelfRel());
}
return ResponseEntity.ok(resource);
}
代码示例来源:origin: spring-projects/spring-hateoas
resource.add(resourceLinks);
content.add(resource);
} else {
代码示例来源:origin: org.springframework.hateoas/spring-hateoas
/**
* Creates a new {@link Resource} with the given content and {@link Link}s.
*
* @param content must not be {@literal null}.
* @param links the links to add to the {@link Resource}.
*/
public Resource(T content, Iterable<Link> links) {
Assert.notNull(content, "Content must not be null!");
Assert.isTrue(!(content instanceof Collection), "Content must not be a collection! Use Resources instead!");
this.content = content;
this.add(links);
}
代码示例来源:origin: in28minutes/spring-boot-examples
@GetMapping("/students/{id}")
@ApiOperation(value = "Find student by id",
notes = "Also returns a link to retrieve all students with rel - all-students")
public Resource<Student> retrieveStudent(@PathVariable long id) {
Optional<Student> student = studentRepository.findById(id);
if (!student.isPresent())
throw new StudentNotFoundException("id-" + id);
Resource<Student> resource = new Resource<Student>(student.get());
ControllerLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveAllStudents());
resource.add(linkTo.withRel("all-students"));
return resource;
}
代码示例来源:origin: in28minutes/spring-boot-examples
@GetMapping("/students/{id}")
public Resource<Student> retrieveStudent(@PathVariable long id) {
Optional<Student> student = studentRepository.findById(id);
if (!student.isPresent())
throw new StudentNotFoundException("id-" + id);
Resource<Student> resource = new Resource<Student>(student.get());
ControllerLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveAllStudents());
resource.add(linkTo.withRel("all-students"));
return resource;
}
代码示例来源:origin: in28minutes/spring-boot-examples
@GetMapping("/students/{id}")
public Resource<Student> retrieveStudent(@PathVariable long id) {
Optional<Student> student = studentRepository.findById(id);
if (!student.isPresent())
throw new StudentNotFoundException("id-" + id);
Resource<Student> resource = new Resource<Student>(student.get());
ControllerLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveAllStudents());
resource.add(linkTo.withRel("all-students"));
return resource;
}
代码示例来源:origin: in28minutes/spring-boot-examples
@GetMapping("/students/{id}")
public Resource<Student> retrieveStudent(@PathVariable long id) {
Optional<Student> student = studentRepository.findById(id);
if (!student.isPresent())
throw new StudentNotFoundException("id-" + id);
Resource<Student> resource = new Resource<Student>(student.get());
ControllerLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveAllStudents());
resource.add(linkTo.withRel("all-students"));
return resource;
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-skipper-server-core
@Override
public Resource<PackageSummary> process(Resource<PackageSummary> packageSummaryResource) {
Link link = linkTo(
methodOn(PackageController.class).install(Long.valueOf(packageSummaryResource.getContent().getId()),
null))
.withRel("install");
packageSummaryResource.add(link);
return packageSummaryResource;
}
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-skipper-server-core
@Override
protected void addLinks(Resource<PackageMetadata> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(PackageController.class).install(null)).withRel("install"));
}
}
代码示例来源:origin: dschulten/hydra-java
@RequestMapping(value = "/{eventId}", method = RequestMethod.GET)
public
@ResponseBody
Resource<Event> getEvent(@PathVariable Integer eventId) {
Resource<Event> resource = new Resource<Event>(getEvents().get(eventId));
resource.add(linkTo(ReviewController.class).withRel("review"));
return resource;
}
代码示例来源:origin: dschulten/hydra-java
@RequestMapping(value = "/regex/{eventId:.+}", method = RequestMethod.GET)
public
@ResponseBody
Resource<Event> getEventWithRegexPathVariableMapping(@PathVariable Integer eventId) {
Resource<Event> resource = new Resource<Event>(getEvents().get(eventId));
resource.add(linkTo(ReviewController.class).withRel("review"));
return resource;
}
代码示例来源:origin: spring-cloud/spring-cloud-skipper
@Override
protected void addLinks(Resource<PackageMetadata> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(PackageController.class).install(null)).withRel("install"));
}
}
代码示例来源:origin: spring-cloud/spring-cloud-skipper
@Override
protected void addLinks(Resource<Release> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(ReleaseController.class).status(null)).withRel("status"));
}
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-skipper-server-core
@Override
protected void addLinks(Resource<Info> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(ReleaseController.class).manifest(null)).withRel("manifest"));
}
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-skipper-server-core
@Override
protected void addLinks(Resource<Manifest> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(ReleaseController.class).status(null)).withRel("status"));
}
}
代码示例来源:origin: vvgomes/event-driven-restaurant
@Override
public Resource<Customer> process(Resource<Customer> resource) {
String id = resource.getContent().getId();
resource.add(linkTo(methodOn(CustomerCommandsController.class).getCommands(id)).withRel("commands"));
return resource;
}
}
代码示例来源:origin: de.escalon.hypermedia/hydra-service
private void addAffordances(Event event) {
event.add(AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(this.getClass())
.getEvent(event.id))
.and(AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(EventController.class)
.updateEvent(event.id, event)))
.and(AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(EventController.class)
.deleteEvent(event.id)))
.withSelfRel());
event.workPerformed.add(AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(ReviewController.class)
.addReview(event.id, new Review(null, new Rating(3))))
.withRel("review"));
}
内容来源于网络,如有侵权,请联系作者删除!