Class JsonPathLinkDiscoverer
java.lang.Object
org.springframework.hateoas.client.JsonPathLinkDiscoverer
- All Implemented Interfaces:
LinkDiscoverer,org.springframework.plugin.core.Plugin<org.springframework.http.MediaType>
- Direct Known Subclasses:
AlpsLinkDiscoverer,CollectionJsonLinkDiscoverer,HalLinkDiscoverer
LinkDiscoverer that uses JsonPath to find links inside a representation.- Author:
- Oliver Gierke, Greg Turnquist
-
Constructor Summary
ConstructorsConstructorDescriptionJsonPathLinkDiscoverer(String pathTemplate, org.springframework.http.MediaType... mediaTypes) Creates a newJsonPathLinkDiscovererusing the given path template supporting the givenMediaType. -
Method Summary
Modifier and TypeMethodDescriptionprotected LinkextractLink(Object element, LinkRelation rel) Callback for eachLinkDiscovererto extract relevant attributes and generate aLink.findLinksWithRel(LinkRelation relation, InputStream representation) Returns all links with the givenLinkRelationfound in the givenInputStreamrepresentation.findLinksWithRel(LinkRelation relation, String representation) Returns all links with the givenLinkRelationfound in the givenStringrepresentation.findLinkWithRel(LinkRelation relation, InputStream representation) Finds a single link with the givenLinkRelationin the givenInputStreamrepresentation.findLinkWithRel(LinkRelation relation, String representation) Finds a single link with the givenLinkRelationin the givenStringrepresentation.booleansupports(org.springframework.http.MediaType delimiter) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.hateoas.client.LinkDiscoverer
findLinksWithRel, findLinksWithRel, findLinkWithRel, findLinkWithRel, findRequiredLinkWithRel, findRequiredLinkWithRel
-
Constructor Details
-
JsonPathLinkDiscoverer
public JsonPathLinkDiscoverer(String pathTemplate, org.springframework.http.MediaType... mediaTypes) Creates a newJsonPathLinkDiscovererusing the given path template supporting the givenMediaType. The template has to contain a single%splaceholder which will be replaced by the relation type.- Parameters:
pathTemplate- must not be null or empty and contain a single placeholder.mediaTypes- theMediaTypes to support.
-
-
Method Details
-
findLinkWithRel
Description copied from interface:LinkDiscovererFinds a single link with the givenLinkRelationin the givenStringrepresentation.- Specified by:
findLinkWithRelin 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:LinkDiscovererFinds a single link with the givenLinkRelationin the givenInputStreamrepresentation.- Specified by:
findLinkWithRelin interfaceLinkDiscoverer- Parameters:
relation- must not be null.representation- must not be null.- Returns:
- the first
Linkwith the givenLinkRelationfound, orOptional.empty()if none was found.
-
findLinksWithRel
Description copied from interface:LinkDiscovererReturns all links with the givenLinkRelationfound in the givenStringrepresentation.- Specified by:
findLinksWithRelin interfaceLinkDiscoverer- Parameters:
relation- must not be null.representation- must not be null.- Returns:
- will never be null.
-
findLinksWithRel
Description copied from interface:LinkDiscovererReturns all links with the givenLinkRelationfound in the givenInputStreamrepresentation.- Specified by:
findLinksWithRelin interfaceLinkDiscoverer- Parameters:
relation- must not be null.representation- must not be null.- Returns:
- will never be null.
-
supports
public boolean supports(@NonNull org.springframework.http.MediaType delimiter) - Specified by:
supportsin interfaceorg.springframework.plugin.core.Plugin<org.springframework.http.MediaType>
-
extractLink
Callback for eachLinkDiscovererto extract relevant attributes and generate aLink.- Parameters:
element-rel-- Returns:
- link
-