Spring Hateoas

org.springframework.hateoas
Class Link

java.lang.Object
  extended by org.springframework.hateoas.Link
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DefaultCurieProvider.Curie

public class Link
extends Object
implements Serializable

Value object for links.

Author:
Oliver Gierke
See Also:
Serialized Form

Field Summary
static String ATOM_NAMESPACE
           
static String REL_FIRST
           
static String REL_LAST
           
static String REL_NEXT
           
static String REL_PREVIOUS
           
static String REL_SELF
           
 
Constructor Summary
protected Link()
          Empty constructor required by the marshalling framework.
  Link(String href)
          Creates a new link to the given URI with the self rel.
  Link(String href, String rel)
          Creates a new Link to the given URI with the given rel.
  Link(UriTemplate template, String rel)
          Creates a new Link from the given UriTemplate and rel.
 
Method Summary
 boolean equals(Object obj)
           
 Link expand(Map<String,? extends Object> arguments)
          Turns the current template into a Link by expanding it using the given parameters.
 Link expand(Object... arguments)
          Turns the current template into a Link by expanding it using the given parameters.
 String getHref()
          Returns the actual URI the link is pointing to.
 String getRel()
          Returns the rel of the link.
 List<String> getVariableNames()
          Returns the variable names contained in the template.
 List<TemplateVariable> getVariables()
          Returns all TemplateVariables contained in the Link.
 int hashCode()
           
 boolean isTemplated()
          Returns whether the link is templated.
 String toString()
           
static Link valueOf(String element)
          Factory method to easily create Link instances from RFC-5988 compatible String representations of a link.
 Link withRel(String rel)
          Returns a Link pointing to the same URI but with the given relation.
 Link withSelfRel()
          Returns a Link pointing to the same URI but with the self relation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ATOM_NAMESPACE

public static final String ATOM_NAMESPACE
See Also:
Constant Field Values

REL_SELF

public static final String REL_SELF
See Also:
Constant Field Values

REL_FIRST

public static final String REL_FIRST
See Also:
Constant Field Values

REL_PREVIOUS

public static final String REL_PREVIOUS
See Also:
Constant Field Values

REL_NEXT

public static final String REL_NEXT
See Also:
Constant Field Values

REL_LAST

public static final String REL_LAST
See Also:
Constant Field Values
Constructor Detail

Link

public Link(String href)
Creates a new link to the given URI with the self rel.

Parameters:
href - must not be null or empty.
See Also:
REL_SELF

Link

public Link(String href,
            String rel)
Creates a new Link to the given URI with the given rel.

Parameters:
href - must not be null or empty.
rel - must not be null or empty.

Link

public Link(UriTemplate template,
            String rel)
Creates a new Link from the given UriTemplate and rel.

Parameters:
template - must not be null.
rel - must not be null or empty.

Link

protected Link()
Empty constructor required by the marshalling framework.

Method Detail

getHref

public String getHref()
Returns the actual URI the link is pointing to.

Returns:

getRel

public String getRel()
Returns the rel of the link.

Returns:

withRel

public Link withRel(String rel)
Returns a Link pointing to the same URI but with the given relation.

Parameters:
rel - must not be null or empty.
Returns:

withSelfRel

public Link withSelfRel()
Returns a Link pointing to the same URI but with the self relation.

Returns:

getVariableNames

public List<String> getVariableNames()
Returns the variable names contained in the template.

Returns:

getVariables

public List<TemplateVariable> getVariables()
Returns all TemplateVariables contained in the Link.

Returns:

isTemplated

public boolean isTemplated()
Returns whether the link is templated.

Returns:

expand

public Link expand(Object... arguments)
Turns the current template into a Link by expanding it using the given parameters.

Parameters:
arguments -
Returns:

expand

public Link expand(Map<String,? extends Object> arguments)
Turns the current template into a Link by expanding it using the given parameters.

Parameters:
arguments - must not be null.
Returns:

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

valueOf

public static Link valueOf(String element)
Factory method to easily create Link instances from RFC-5988 compatible String representations of a link. Will return null if an empty or null String is given.

Parameters:
element - an RFC-5899 compatible representation of a link.
Returns:
Throws:
IllegalArgumentException - if a non-empty String was given that does not adhere to RFC-5899.
IllegalArgumentException - if no rel attribute could be found.

Spring Hateoas

Copyright © 2012-2014-2014 Pivotal, Inc.. All Rights Reserved.