本文整理汇总了Java中org.springframework.hateoas.mvc.ResourceAssemblerSupport类的典型用法代码示例。如果您正苦于以下问题:Java ResourceAssemblerSupport类的具体用法?Java ResourceAssemblerSupport怎么用?Java ResourceAssemblerSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceAssemblerSupport类属于org.springframework.hateoas.mvc包,在下文中一共展示了ResourceAssemblerSupport类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AbstractApiController
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
public AbstractApiController(
RepositoryOperations<T, ID> repository,
Class<T> model,
ResourceAssemblerSupport<T, FilterableResource> assembler) {
this.repository = repository;
this.model = model;
this.assembler = assembler;
}
示例2: createResource
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public HttpEntity<Void> createResource(@RequestBody T t) {
T newT = service.persist(t);
ResourceAssemblerSupport<T, ?> ras = getRas(t);
HttpHeaders httpHeaders = new HttpHeaders();
String newResourceLink = ras.toResource(newT).getLink("self").getHref();
httpHeaders.setLocation(URI.create(newResourceLink));
return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
}
示例3: CrudApiController
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
public CrudApiController(RepositoryOperations<T, ID> repository, Class<T> model,
ResourceAssemblerSupport<T, FilterableResource> assembler) {
super(repository, model, assembler);
}
示例4: ReadOnlyApiController
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
public ReadOnlyApiController(RepositoryOperations<T, ID> repository, Class<T> model,
ResourceAssemblerSupport<T, FilterableResource> assembler) {
super(repository, model, assembler);
}
示例5: getAssembler
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
public ResourceAssemblerSupport<T, FilterableResource> getAssembler() {
return assembler;
}
示例6: createOkResponse
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
protected <T, U extends ResourceSupport> ResponseEntity<U> createOkResponse(T dto,
ResourceAssemblerSupport<T, U> resourceAssembler)
{
return createResponse(dto, HttpStatus.OK, resourceAssembler);
}
示例7: createResponse
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
protected <T, U extends ResourceSupport> ResponseEntity<U> createResponse(T dto, HttpStatus status,
ResourceAssemblerSupport<T, U> resourceAssembler)
{
return new ResponseEntity<>(resourceAssembler.toResource(dto), status);
}
示例8: createCollectionResource
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
public static <T, U extends ResourceSupport> Resources<U> createCollectionResource(Collection<T> dtos,
ResourceAssemblerSupport<T, U> resourceAssembler, ControllerLinkBuilder linkBuilder)
{
return new Resources<>(resourceAssembler.toResources(dtos), linkBuilder.withSelfRel());
}
示例9: getRas
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
@Override
protected ResourceAssemblerSupport<User, ?> getRas(User user) {
return this.userAssembler;
}
示例10: toResources
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
/**
* 将实体集entities转化为Resources
*
* @param entities
* @param assembler
* @param clazz
* @return
*/
public static <T, D extends ResourceSupport> Resources<D> toResources(Iterable<T> entities,
ResourceAssemblerSupport<T, D> assembler, Class<?> clazz) {
Link link = linkTo(clazz).withSelfRel();
Resources<D> resources = new Resources<>(assembler.toResources(entities), link);
return resources;
}
示例11: getRas
import org.springframework.hateoas.mvc.ResourceAssemblerSupport; //导入依赖的package包/类
protected abstract ResourceAssemblerSupport<T, ?> getRas(T t);