當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。