当前位置: 首页>>代码示例>>Java>>正文


Java Link.getRel方法代码示例

本文整理汇总了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);
}
 
开发者ID:mockitoo,项目名称:spring-data-rest-android,代码行数:18,代码来源:Jackson2HalModule.java

示例2: unescapeTemplateVariables

import org.springframework.hateoas.Link; //导入方法依赖的package包/类
private Link unescapeTemplateVariables(Link raw) {
	return new Link(raw.getHref().replace("%7B", "{").replace("%7D", "}"), raw.getRel());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:4,代码来源:RootController.java

示例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);

    }
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:22,代码来源:LinkHelper.java

示例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);
}
 
开发者ID:mockitoo,项目名称:spring-data-rest-android,代码行数:60,代码来源:Jackson2HalModule.java

示例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));
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:8,代码来源:LinkHelper.java


注:本文中的org.springframework.hateoas.Link.getRel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。