public class JsonPathLinkDiscoverer extends Object implements LinkDiscoverer
LinkDiscoverer
that uses JsonPath
to find links inside a representation.Constructor and Description |
---|
JsonPathLinkDiscoverer(String pathTemplate,
org.springframework.http.MediaType... mediaTypes)
Creates a new
JsonPathLinkDiscoverer using the given path template supporting the given MediaType . |
Modifier and Type | Method and Description |
---|---|
protected Link |
extractLink(Object element,
LinkRelation rel)
Callback for each
LinkDiscoverer to extract relevant attributes and generate a Link . |
Links |
findLinksWithRel(LinkRelation relation,
InputStream representation)
Returns all links with the given
LinkRelation found in the given InputStream representation. |
Links |
findLinksWithRel(LinkRelation relation,
String representation)
Returns all links with the given
LinkRelation found in the given String representation. |
Optional<Link> |
findLinkWithRel(LinkRelation relation,
InputStream representation)
Finds a single link with the given
LinkRelation in the given InputStream representation. |
Optional<Link> |
findLinkWithRel(LinkRelation relation,
String representation)
Finds a single link with the given
LinkRelation in the given String representation. |
boolean |
supports(org.springframework.http.MediaType delimiter) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
findLinksWithRel, findLinksWithRel, findLinkWithRel, findLinkWithRel, findRequiredLinkWithRel, findRequiredLinkWithRel
public JsonPathLinkDiscoverer(String pathTemplate, org.springframework.http.MediaType... mediaTypes)
JsonPathLinkDiscoverer
using the given path template supporting the given MediaType
.
The template has to contain a single %s
placeholder which will be replaced by the relation type.pathTemplate
- must not be null or empty and contain a single placeholder.mediaTypes
- the MediaType
s to support.public Optional<Link> findLinkWithRel(LinkRelation relation, String representation)
LinkDiscoverer
LinkRelation
in the given String
representation.findLinkWithRel
in interface LinkDiscoverer
relation
- must not be null.representation
- must not be null.Optional.empty()
if none was found.public Optional<Link> findLinkWithRel(LinkRelation relation, InputStream representation)
LinkDiscoverer
LinkRelation
in the given InputStream
representation.findLinkWithRel
in interface LinkDiscoverer
relation
- must not be null.representation
- must not be null.Link
with the given LinkRelation
found, or Optional.empty()
if none was
found.public Links findLinksWithRel(LinkRelation relation, String representation)
LinkDiscoverer
LinkRelation
found in the given String
representation.findLinksWithRel
in interface LinkDiscoverer
relation
- must not be null.representation
- must not be null.public Links findLinksWithRel(LinkRelation relation, InputStream representation)
LinkDiscoverer
LinkRelation
found in the given InputStream
representation.findLinksWithRel
in interface LinkDiscoverer
relation
- must not be null.representation
- must not be null.public boolean supports(org.springframework.http.MediaType delimiter)
supports
in interface org.springframework.plugin.core.Plugin<org.springframework.http.MediaType>
protected Link extractLink(Object element, LinkRelation rel)
LinkDiscoverer
to extract relevant attributes and generate a Link
.element
- rel
- Copyright © 2012-2019–2019 Pivotal, Inc.. All rights reserved.