本文整理汇总了Java中org.springframework.hateoas.UriTemplate类的典型用法代码示例。如果您正苦于以下问题:Java UriTemplate类的具体用法?Java UriTemplate怎么用?Java UriTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UriTemplate类属于org.springframework.hateoas包,在下文中一共展示了UriTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRootResource
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
@RequestMapping("/")
public HttpEntity<RootResource> getRootResource() {
RootResource resource = new RootResource();
String baseUri = BasicLinkBuilder.linkToCurrentMapping().toString();
Link catalogServiceLink = new Link(new UriTemplate(baseUri + "/catalog"), RootResource.LINK_NAME_CATALOG);
resource.add(catalogServiceLink);
Link reviewServiceLink = new Link(new UriTemplate(baseUri + "/reviews"), RootResource.LINK_NAME_REVIEW);
resource.add(reviewServiceLink);
Link recommendationServiceLink = new Link(new UriTemplate(baseUri + "/recommendations"),
RootResource.LINK_NAME_RECOMMENDATIONS);
resource.add(recommendationServiceLink);
Link orderServiceLink = new Link(new UriTemplate(baseUri + "/orders"), RootResource.LINK_NAME_ORDERS);
resource.add(orderServiceLink);
Link productLink = new Link(new UriTemplate(baseUri + "/product/{id}"), RootResource.LINK_NAME_PRODUCT_DETAIL);
resource.add(productLink);
return new ResponseEntity<>(resource, HttpStatus.OK);
}
示例2: DefaultCurieProvider
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
/**
* Creates a new {@link DefaultCurieProvider} for the given curies using the one with the given name as default, which
* means to expand unprefixed, non-IANA link relations.
*
* @param curies must not be {@literal null}.
* @param defaultCurieName can be {@literal null}.
* @since 0.19
*/
public DefaultCurieProvider(Map<String, UriTemplate> curies, String defaultCurieName) {
Assert.notNull(curies, "Curies must not be null!");
Map<String, Curie> map = new HashMap<String, Curie>(curies.size());
for (Entry<String, UriTemplate> entry : curies.entrySet()) {
String name = entry.getKey();
UriTemplate template = entry.getValue();
Assert.hasText(name, "Curie name must not be null or empty!");
Assert.notNull(template, "UriTemplate must not be null!");
Assert.isTrue(template.getVariableNames().size() == 1,
String.format("Expected a single template variable in the UriTemplate %s!", template.toString()));
map.put(name, new Curie(name, template.toString()));
}
this.defaultCurie = StringUtils.hasText(defaultCurieName) ? map.get(defaultCurieName)
: map.size() == 1 ? map.values().iterator().next() : null;
this.curies = Collections.unmodifiableMap(map);
}
示例3: toResource
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
@Override
public AuthorAccountResource toResource(UserAccount entity) {
AuthorAccountResource resource = new AuthorAccountResource(entity);
try {
resource.add(linkTo(methodOn(AuthorAccountRestController.class).getCurrentAuthorAccount())
.withSelfRel());
String baseUri = BasicLinkBuilder.linkToCurrentMapping().toString();
Link blogsLink = new Link(
new UriTemplate(baseUri + ApiUrls.API_ROOT + ApiUrls.URL_AUTHOR_BLOGS), AuthorAccountResource.LINK_NAME_BLOGS);
resource.add(assembler.appendPaginationParameterTemplates(blogsLink));
Link blogLink = new Link(
new UriTemplate(baseUri + ApiUrls.API_ROOT + ApiUrls.URL_AUTHOR_BLOGS_BLOG), AuthorAccountResource.LINK_NAME_BLOG);
resource.add(blogLink);
} catch (Exception ex) {
//do nothing
}
return resource;
}
示例4: dependenciesLink
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
private Map<String, Object> dependenciesLink(String appUrl) {
String uri = appUrl != null ? appUrl + "/dependencies" : "/dependencies";
UriTemplate uriTemplate = new UriTemplate(uri, this.dependenciesVariables);
Map<String, Object> result = new LinkedHashMap<>();
result.put("href", uriTemplate.toString());
result.put("templated", true);
return result;
}
示例5: curieProvider
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
@Bean
@ConditionalOnBean(DocsMvcEndpoint.class)
@ConditionalOnMissingBean(CurieProvider.class)
@ConditionalOnProperty(prefix = "endpoints.docs.curies", name = "enabled", matchIfMissing = false)
public DefaultCurieProvider curieProvider(ServerProperties server,
ManagementServerProperties management, DocsMvcEndpoint endpoint) {
String path = management.getContextPath() + endpoint.getPath()
+ "/#spring_boot_actuator__{rel}";
if (server.getPort().equals(management.getPort()) && management.getPort() != 0) {
path = server.getPath(path);
}
return new DefaultCurieProvider("boot", new UriTemplate(path));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:EndpointWebMvcHypermediaManagementContextConfiguration.java
示例6: process
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
@Override
public RepositoryLinksResource process(RepositoryLinksResource resource) {
final ControllerLinkBuilder controllerLinkBuilder = linkTo(AttachmentController.class);
final Link attachments = new Link(new UriTemplate(controllerLinkBuilder.toUri().toString() + "/api/attachments{?sha1}"), "attachments");
resource.add(attachments);
return resource;
}
示例7: curieProvider
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
@Bean
@ConditionalOnBean(ActuatorDocsEndpoint.class)
@ConditionalOnMissingBean(CurieProvider.class)
@ConditionalOnProperty(prefix = "endpoints.docs.curies", name = "enabled", matchIfMissing = false)
public DefaultCurieProvider curieProvider(ServerProperties server,
ManagementServerProperties management, ActuatorDocsEndpoint endpoint) {
String path = management.getContextPath() + endpoint.getPath()
+ "/#spring_boot_actuator__{rel}";
if (server.getPort() == management.getPort() && management.getPort() != null
&& management.getPort() != 0) {
path = server.getPath(path);
}
return new DefaultCurieProvider("boot", new UriTemplate(path));
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:15,代码来源:EndpointWebMvcHypermediaManagementContextConfiguration.java
示例8: expand
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
/**
* Expands template variables, arguments must satisfy all required template variables, optional variables will be
* removed.
*
* @param arguments
* to expansion in the order they appear in the template
* @return expanded affordance
*/
@Override
public Affordance expand(Object... arguments) {
UriTemplate template = new UriTemplate(partialUriTemplate.asComponents()
.toString());
String expanded = template.expand(arguments)
.toASCIIString();
return new Affordance(expanded, linkParams, actionDescriptors);
}
示例9: dependenciesLink
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
private ObjectNode dependenciesLink(String appUrl) {
String uri = appUrl != null ? appUrl + "/dependencies" : "/dependencies";
UriTemplate uriTemplate = new UriTemplate(uri, this.dependenciesVariables);
ObjectNode result = nodeFactory().objectNode();
result.put("href", uriTemplate.toString());
result.put("templated", true);
return result;
}
示例10: toResource
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
@Override
public AdminAccountResource toResource(UserAccount userAccount) {
AdminAccountResource resource = new AdminAccountResource(userAccount);
try {
resource.add(linkTo(methodOn(AdminAccountRestController.class).getAdminAccount()).withSelfRel());
String baseUri = BasicLinkBuilder.linkToCurrentMapping().toString();
Link usersLink = new Link(
new UriTemplate(baseUri + ApiUrls.API_ROOT + ApiUrls.URL_ADMIN_USERS), AdminAccountResource.LINK_NAME_USERS);
resource.add(assembler.appendPaginationParameterTemplates(usersLink));
Link blogsLink = new Link(
new UriTemplate(baseUri + ApiUrls.API_ROOT + ApiUrls.URL_ADMIN_BLOGS), AdminAccountResource.LINK_NAME_BLOGS);
resource.add(assembler.appendPaginationParameterTemplates(blogsLink));
Link commentsLink = new Link(
new UriTemplate(baseUri + ApiUrls.API_ROOT + ApiUrls.URL_ADMIN_COMMENTS), AdminAccountResource.LINK_NAME_COMMENTS);
resource.add(assembler.appendPaginationParameterTemplates(commentsLink));
} catch (Exception ex) {
//do nothing
}
return resource;
}
示例11: generateTemplatedUri
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
private String generateTemplatedUri(String appUrl, Type type) {
String uri = appUrl != null ? appUrl + type.getAction() : type.getAction();
uri = uri + "?type=" + type.getId();
UriTemplate uriTemplate = new UriTemplate(uri, this.templateVariables);
return uriTemplate.toString();
}
示例12: CompletionTemplate
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
public CompletionTemplate(RestTemplate restTemplate, Link streamLink, Link taskLink) {
this.restTemplate = restTemplate;
this.streamCompletionUriTemplate = new UriTemplate(streamLink.getHref());
this.taskCompletionUriTemplate = new UriTemplate(taskLink.getHref());
}
示例13: curieProvider
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
public @Bean
CurieProvider curieProvider() {
return new DefaultCurieProvider(CURIE_NAMESPACE, new UriTemplate("/docs/html5/{rel}.html"));
}
示例14: curieProvider
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
@Bean
public CurieProvider curieProvider() {
return new DefaultCurieProvider("api", new UriTemplate("http://localhost/rels/{rel}"));
}
示例15: curieProvider
import org.springframework.hateoas.UriTemplate; //导入依赖的package包/类
@Bean
public CurieProvider curieProvider()
{
return new DefaultCurieProvider("yona", new UriTemplate("http://dev.yona.nu/rels/{rel}"));
}