Class Traverson.TraversalBuilder

java.lang.Object
org.springframework.hateoas.client.Traverson.TraversalBuilder
Enclosing class:
Traverson

public class Traverson.TraversalBuilder extends Object
Builder API to customize traversals.
Author:
Oliver Gierke
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the Link found for the last rel in the rels configured to follow.
    Returns the templated Link found for the last relation in the rels configured to follow.
    follow(String... rels)
    Follows the given rels one by one, which means a request per rel to discover the next resource with the rel in line.
    follow(Hop hop)
    Follows the given rels one by one, which means a request per rel to discover the next resource with the rel in line.
    <T> org.springframework.http.ResponseEntity<T>
    toEntity(Class<T> type)
    Returns the raw ResponseEntity with the representation unmarshalled into an instance of the given type.
    <T> @Nullable T
    toObject(Class<T> type)
    Executes the traversal and marshals the final response into an object of the given type.
    <T> T
    toObject(String jsonPath)
    Executes the traversal and returns the result of the given JSON Path expression evaluated against the final representation.
    <T> @Nullable T
    toObject(org.springframework.core.ParameterizedTypeReference<T> type)
    Executes the traversal and marshals the final response into an object of the given ParameterizedTypeReference.
    withHeaders(org.springframework.http.HttpHeaders headers)
    The HttpHeaders that shall be used for the requests of the traversal.
    Adds the given operations parameters to the traversal.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • follow

      public Traverson.TraversalBuilder follow(String... rels)
      Follows the given rels one by one, which means a request per rel to discover the next resource with the rel in line.
      Parameters:
      rels - must not be null.
      Returns:
    • follow

      public Traverson.TraversalBuilder follow(Hop hop)
      Follows the given rels one by one, which means a request per rel to discover the next resource with the rel in line.
      Parameters:
      hop - must not be null.
      Returns:
      See Also:
    • withTemplateParameters

      public Traverson.TraversalBuilder withTemplateParameters(Map<String,Object> parameters)
      Adds the given operations parameters to the traversal. If a link discovered by the traversal is templated, the given parameters will be used to expand the operations into a resolvable URI.
      Parameters:
      parameters - can be null.
      Returns:
    • withHeaders

      public Traverson.TraversalBuilder withHeaders(org.springframework.http.HttpHeaders headers)
      The HttpHeaders that shall be used for the requests of the traversal.
      Parameters:
      headers - can be null.
      Returns:
    • toObject

      public <T> @Nullable T toObject(Class<T> type)
      Executes the traversal and marshals the final response into an object of the given type.
      Parameters:
      type - must not be null.
      Returns:
    • toObject

      public <T> @Nullable T toObject(org.springframework.core.ParameterizedTypeReference<T> type)
      Executes the traversal and marshals the final response into an object of the given ParameterizedTypeReference.
      Parameters:
      type - must not be null.
      Returns:
    • toObject

      public <T> T toObject(String jsonPath)
      Executes the traversal and returns the result of the given JSON Path expression evaluated against the final representation.
      Parameters:
      jsonPath - must not be null or empty.
      Returns:
    • toEntity

      public <T> org.springframework.http.ResponseEntity<T> toEntity(Class<T> type)
      Returns the raw ResponseEntity with the representation unmarshalled into an instance of the given type.
      Parameters:
      type - must not be null.
      Returns:
    • asLink

      public Link asLink()
      Returns the Link found for the last rel in the rels configured to follow. Will expand the final Link using the
      Returns:
      Since:
      0.15
      See Also:
    • asTemplatedLink

      public Link asTemplatedLink()
      Returns the templated Link found for the last relation in the rels configured to follow.
      Returns:
      Since:
      0.17