Class Traverson
java.lang.Object
org.springframework.hateoas.client.Traverson
Component to ease traversing hypermedia APIs by following links with relation types. Highly inspired by the equally
named JavaScript library.
- Since:
- 0.11
- Author:
- Oliver Gierke, Dietrich Schulten, Greg Turnquist, Tom Bunting, Manish Misra, Michael Wirth
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Builder API to customize traversals. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets up aTraverson.TraversalBuilder
to follow the given rels.Sets up aTraverson.TraversalBuilder
for a single rel with customized details.static List<org.springframework.http.converter.HttpMessageConverter<?>>
getDefaultMessageConverters
(org.springframework.http.MediaType... mediaTypes) Returns allHttpMessageConverter
s that will be registered for the givenMediaType
s by default.setLinkDiscoverers
(@Nullable List<? extends LinkDiscoverer> discoverer) Sets theLinkDiscoverers
to use.setRestOperations
(@Nullable org.springframework.web.client.RestOperations operations) Configures theRestOperations
to use.
-
Constructor Details
-
Traverson
Creates a newTraverson
interacting with the given base URI and using the givenMediaType
s to interact with the service.- Parameters:
baseUri
- must not be null.mediaTypes
- must not be null or empty.
-
Traverson
Creates a newTraverson
interacting with the given base URI and using the givenMediaType
s to interact with the service.- Parameters:
baseUri
- must not be null.mediaTypes
- must not be null or empty.
-
-
Method Details
-
getDefaultMessageConverters
public static List<org.springframework.http.converter.HttpMessageConverter<?>> getDefaultMessageConverters(org.springframework.http.MediaType... mediaTypes) Returns allHttpMessageConverter
s that will be registered for the givenMediaType
s by default.- Parameters:
mediaTypes
- must not be null.- Returns:
-
setRestOperations
public Traverson setRestOperations(@Nullable org.springframework.web.client.RestOperations operations) Configures theRestOperations
to use. If null is provided a defaultRestTemplate
will be used.- Parameters:
operations
-- Returns:
-
setLinkDiscoverers
Sets theLinkDiscoverers
to use. By default a singleHalLinkDiscoverer
is registered. If null is provided the default is re-applied.- Parameters:
discoverer
- can be null.- Returns:
-
follow
Sets up aTraverson.TraversalBuilder
to follow the given rels.- Parameters:
rels
- must not be null or empty.- Returns:
- See Also:
-
follow
Sets up aTraverson.TraversalBuilder
for a single rel with customized details.- Parameters:
hop
- must not be null- Returns:
-