Class Traverson

java.lang.Object
org.springframework.hateoas.client.Traverson

public class Traverson extends Object
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
  • Constructor Details

    • Traverson

      public Traverson(URI baseUri, org.springframework.http.MediaType... mediaTypes)
      Creates a new Traverson interacting with the given base URI and using the given MediaTypes to interact with the service.
      Parameters:
      baseUri - must not be null.
      mediaTypes - must not be null or empty.
    • Traverson

      public Traverson(URI baseUri, List<org.springframework.http.MediaType> mediaTypes)
      Creates a new Traverson interacting with the given base URI and using the given MediaTypes 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 all HttpMessageConverters that will be registered for the given MediaTypes by default.
      Parameters:
      mediaTypes - must not be null.
      Returns:
    • setRestOperations

      public Traverson setRestOperations(@Nullable org.springframework.web.client.RestOperations operations)
      Configures the RestOperations to use. If null is provided a default RestTemplate will be used.
      Parameters:
      operations -
      Returns:
    • setLinkDiscoverers

      public Traverson setLinkDiscoverers(@Nullable List<? extends LinkDiscoverer> discoverer)
      Sets the LinkDiscoverers to use. By default a single HalLinkDiscoverer is registered. If null is provided the default is re-applied.
      Parameters:
      discoverer - can be null.
      Returns:
    • follow

      public Traverson.TraversalBuilder follow(String... rels)
      Sets up a Traverson.TraversalBuilder to follow the given rels.
      Parameters:
      rels - must not be null or empty.
      Returns:
      See Also:
    • follow

      public Traverson.TraversalBuilder follow(Hop hop)
      Sets up a Traverson.TraversalBuilder for a single rel with customized details.
      Parameters:
      hop - must not be null
      Returns: