Class JsonPathLinkDiscoverer
java.lang.Object
org.springframework.hateoas.client.JsonPathLinkDiscoverer
- All Implemented Interfaces:
LinkDiscoverer
,org.springframework.plugin.core.Plugin<MediaType>
- Direct Known Subclasses:
AlpsLinkDiscoverer
,CollectionJsonLinkDiscoverer
,HalLinkDiscoverer
LinkDiscoverer
that uses JsonPath
to find links inside a representation.- Author:
- Oliver Gierke, Greg Turnquist
-
Constructor Summary
ConstructorDescriptionJsonPathLinkDiscoverer
(String pathTemplate, MediaType... mediaTypes) Creates a newJsonPathLinkDiscoverer
using the given path template supporting the givenMediaType
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Link
extractLink
(Object element, LinkRelation rel) Callback for eachLinkDiscoverer
to extract relevant attributes and generate aLink
.findLinksWithRel
(LinkRelation relation, InputStream representation) Returns all links with the givenLinkRelation
found in the givenInputStream
representation.findLinksWithRel
(LinkRelation relation, String representation) Returns all links with the givenLinkRelation
found in the givenString
representation.findLinkWithRel
(LinkRelation relation, InputStream representation) Finds a single link with the givenLinkRelation
in the givenInputStream
representation.findLinkWithRel
(LinkRelation relation, String representation) Finds a single link with the givenLinkRelation
in the givenString
representation.boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.hateoas.client.LinkDiscoverer
findLinksWithRel, findLinksWithRel, findLinkWithRel, findLinkWithRel, findRequiredLinkWithRel, findRequiredLinkWithRel
-
Constructor Details
-
JsonPathLinkDiscoverer
Creates a newJsonPathLinkDiscoverer
using the given path template supporting the givenMediaType
. The template has to contain a single%s
placeholder which will be replaced by the relation type.- Parameters:
pathTemplate
- must not be null or empty and contain a single placeholder.mediaTypes
- theMediaType
s to support.
-
-
Method Details
-
findLinkWithRel
Description copied from interface:LinkDiscoverer
Finds a single link with the givenLinkRelation
in the givenString
representation.- Specified by:
findLinkWithRel
in interfaceLinkDiscoverer
- Parameters:
relation
- must not be null.representation
- must not be null.- Returns:
- the first link with the given relation type found, or
Optional.empty()
if none was found.
-
findLinkWithRel
Description copied from interface:LinkDiscoverer
Finds a single link with the givenLinkRelation
in the givenInputStream
representation.- Specified by:
findLinkWithRel
in interfaceLinkDiscoverer
- Parameters:
relation
- must not be null.representation
- must not be null.- Returns:
- the first
Link
with the givenLinkRelation
found, orOptional.empty()
if none was found.
-
findLinksWithRel
Description copied from interface:LinkDiscoverer
Returns all links with the givenLinkRelation
found in the givenString
representation.- Specified by:
findLinksWithRel
in interfaceLinkDiscoverer
- Parameters:
relation
- must not be null.representation
- must not be null.- Returns:
- will never be null.
-
findLinksWithRel
Description copied from interface:LinkDiscoverer
Returns all links with the givenLinkRelation
found in the givenInputStream
representation.- Specified by:
findLinksWithRel
in interfaceLinkDiscoverer
- Parameters:
relation
- must not be null.representation
- must not be null.- Returns:
- will never be null.
-
supports
- Specified by:
supports
in interfaceorg.springframework.plugin.core.Plugin<MediaType>
-
extractLink
Callback for eachLinkDiscoverer
to extract relevant attributes and generate aLink
.- Parameters:
element
-rel
-- Returns:
- link
-