本文整理汇总了Java中org.springframework.hateoas.Link.getRel方法的典型用法代码示例。如果您正苦于以下问题:Java Link.getRel方法的具体用法?Java Link.getRel怎么用?Java Link.getRel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.hateoas.Link
的用法示例。
在下文中一共展示了Link.getRel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toHalLink
import org.springframework.hateoas.Link; //导入方法依赖的package包/类
/**
* Wraps the given link into a HAL specifc extension.
*
* @param link must not be {@literal null}.
* @return
*/
private HalLink toHalLink(Link link) {
String rel = link.getRel();
String title = getTitle(rel);
if (title == null) {
title = getTitle(rel.contains(":") ? rel.substring(rel.indexOf(":") + 1) : rel);
}
return new HalLink(link, title);
}
示例2: unescapeTemplateVariables
import org.springframework.hateoas.Link; //导入方法依赖的package包/类
private Link unescapeTemplateVariables(Link raw) {
return new Link(raw.getHref().replace("%7B", "{").replace("%7D", "}"), raw.getRel());
}
示例3: addSearchLink
import org.springframework.hateoas.Link; //导入方法依赖的package包/类
public void addSearchLink(Collection<Link> links, Class type) {
Link collectionLink = repositoryEntityLinks.linkToCollectionResource(type).expand();
String relBase = collectionLink.getRel();
Links searchLinks = repositoryEntityLinks.linksToSearchResources(type);
if (searchLinks == null || searchLinks.isEmpty()) {
logger.debug("No search links found for class {}", type);
} else {
logger.debug("Search links found for class {}: {} ", type, searchLinks);
String href = collectionLink.getHref() + "/search";
String rel = relBase + SEARCH_REL_SUFFIX;
Link searchesLink = new Link(href, rel);
links.add(searchesLink);
}
}
示例4: serialize
import org.springframework.hateoas.Link; //导入方法依赖的package包/类
@Override
public void serialize(List<Link> value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException {
// sort links according to their relation
Map<String, List<Object>> sortedLinks = new LinkedHashMap<String, List<Object>>();
List<Link> links = new ArrayList<Link>();
boolean prefixingRequired = curieProvider != null;
boolean curiedLinkPresent = false;
boolean skipCuries = !jgen.getOutputContext().getParent().inRoot();
Object currentValue = jgen.getCurrentValue();
if (currentValue instanceof Resources) {
if (mapper.hasCuriedEmbed((Resources<?>) currentValue)) {
curiedLinkPresent = true;
}
}
for (Link link : value) {
if (link.equals(CURIES_REQUIRED_DUE_TO_EMBEDS)) {
continue;
}
String rel = prefixingRequired ? curieProvider.getNamespacedRelFrom(link) : link.getRel();
if (!link.getRel().equals(rel)) {
curiedLinkPresent = true;
}
if (sortedLinks.get(rel) == null) {
sortedLinks.put(rel, new ArrayList<Object>());
}
links.add(link);
sortedLinks.get(rel).add(toHalLink(link));
}
if (!skipCuries && prefixingRequired && curiedLinkPresent) {
ArrayList<Object> curies = new ArrayList<Object>();
curies.add(curieProvider.getCurieInformation(new Links(links)));
sortedLinks.put("curies", curies);
}
TypeFactory typeFactory = provider.getConfig().getTypeFactory();
JavaType keyType = typeFactory.uncheckedSimpleType(String.class);
JavaType valueType = typeFactory.constructCollectionType(ArrayList.class, Object.class);
JavaType mapType = typeFactory.constructMapType(HashMap.class, keyType, valueType);
MapSerializer serializer = MapSerializer.construct(new String[]{}, mapType, true, null,
provider.findKeySerializer(keyType, null), new OptionalListJackson2Serializer(property), null);
serializer.serialize(sortedLinks, jgen, provider);
}
示例5: addCreateLink
import org.springframework.hateoas.Link; //导入方法依赖的package包/类
public void addCreateLink(Collection<Link> links, Class type) {
Link collectionLink = repositoryEntityLinks.linkToCollectionResource(type).expand();
String relBase = collectionLink.getRel();
links.add(collectionLink.withRel(relBase + CREATE_REL_SUFFIX));
}