本文整理汇总了Java中org.springframework.hateoas.ResourceAssembler类的典型用法代码示例。如果您正苦于以下问题:Java ResourceAssembler类的具体用法?Java ResourceAssembler怎么用?Java ResourceAssembler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceAssembler类属于org.springframework.hateoas包,在下文中一共展示了ResourceAssembler类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: list
import org.springframework.hateoas.ResourceAssembler; //导入依赖的package包/类
/**
* List Counters that match the given criteria.
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public PagedResources<? extends MetricResource> list(
Pageable pageable,
PagedResourcesAssembler<Metric<Double>> pagedAssembler,
@RequestParam(value = "detailed", defaultValue = "false") boolean detailed) {
/* Page */ Iterable<Metric<?>> metrics = metricRepository.findAll(/* pageable */);
List<Metric<Double>> content = filterCounters(metrics);
long count = content.size();
long pageEnd = Math.min(count, pageable.getOffset() + pageable.getPageSize());
Page counterPage = new PageImpl<>(content.subList(pageable.getOffset(), (int) pageEnd), pageable, content.size());
ResourceAssembler<Metric<Double>, ? extends MetricResource> assemblerToUse =
detailed ? counterResourceAssembler : shallowResourceAssembler;
return pagedAssembler.toResource(counterPage, assemblerToUse);
}
示例2: submissionStatusResourceAssembler
import org.springframework.hateoas.ResourceAssembler; //导入依赖的package包/类
@Bean
public ResourceAssembler<StatusDescription, Resource<StatusDescription>> submissionStatusResourceAssembler() {
return entity -> {
Resource<StatusDescription> res = new Resource<StatusDescription>(entity);
res.add(
linkTo(
methodOn(StatusDescriptionController.class).submissionStatus(entity.getStatusName()
)
).withSelfRel()
);
return res;
};
}
示例3: processingStatusResourceAssembler
import org.springframework.hateoas.ResourceAssembler; //导入依赖的package包/类
@Bean
public ResourceAssembler<StatusDescription, Resource<StatusDescription>> processingStatusResourceAssembler() {
return entity -> {
Resource<StatusDescription> res = new Resource<StatusDescription>(entity);
res.add(
linkTo(
methodOn(StatusDescriptionController.class).processingStatus(entity.getStatusName())
).withSelfRel()
);
return res;
};
}
示例4: releaseStatusResourceAssembler
import org.springframework.hateoas.ResourceAssembler; //导入依赖的package包/类
@Bean
public ResourceAssembler<StatusDescription, Resource<StatusDescription>> releaseStatusResourceAssembler() {
return entity -> {
Resource<StatusDescription> res = new Resource<StatusDescription>(entity);
res.add(
linkTo(
methodOn(StatusDescriptionController.class).releaseStatus(entity.getStatusName())
).withSelfRel()
);
return res;
};
}
示例5: SubmissionStatusController
import org.springframework.hateoas.ResourceAssembler; //导入依赖的package包/类
public SubmissionStatusController(Map<String, StatusDescription> submissionStatusDescriptionMap, SubmissionRepository submissionRepository, ValidationResultService validationResultService, ResourceAssembler<StatusDescription, Resource<StatusDescription>> submissionStatusResourceAssembler, RepositoryEntityLinks repositoryEntityLinks) {
this.submissionStatusDescriptionMap = submissionStatusDescriptionMap;
this.submissionRepository = submissionRepository;
this.validationResultService = validationResultService;
this.submissionStatusResourceAssembler = submissionStatusResourceAssembler;
this.repositoryEntityLinks = repositoryEntityLinks;
}
示例6: StatusDescriptionController
import org.springframework.hateoas.ResourceAssembler; //导入依赖的package包/类
public StatusDescriptionController(List<StatusDescription> releaseStatuses, List<StatusDescription> processingStatuses, List<StatusDescription> submissionStatuses, PagedResourcesAssembler pagedResourcesAssembler, ResourceAssembler<StatusDescription, Resource<StatusDescription>> processingStatusResourceAssembler, ResourceAssembler<StatusDescription, Resource<StatusDescription>> releaseStatusResourceAssembler, ResourceAssembler<StatusDescription, Resource<StatusDescription>> submissionStatusResourceAssembler) {
this.releaseStatuses = releaseStatuses;
this.processingStatuses = processingStatuses;
this.submissionStatuses = submissionStatuses;
this.pagedResourcesAssembler = pagedResourcesAssembler;
this.processingStatusResourceAssembler = processingStatusResourceAssembler;
this.releaseStatusResourceAssembler = releaseStatusResourceAssembler;
this.submissionStatusResourceAssembler = submissionStatusResourceAssembler;
}
示例7: GameController
import org.springframework.hateoas.ResourceAssembler; //导入依赖的package包/类
@Autowired
GameController(GameService gameService, ResourceAssembler<Game, Resource<Game>> resourceAssembler) {
this.gameService = gameService;
this.resourceAssembler = resourceAssembler;
}