public class Link extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static String |
ATOM_NAMESPACE |
static String |
REL_FIRST |
static String |
REL_LAST |
static String |
REL_NEXT |
static String |
REL_PREVIOUS |
static String |
REL_SELF |
Modifier | Constructor and Description |
---|---|
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. |
Modifier and Type | Method and Description |
---|---|
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)
|
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. |
public static final String ATOM_NAMESPACE
public static final String REL_SELF
public static final String REL_FIRST
public static final String REL_PREVIOUS
public static final String REL_NEXT
public static final String REL_LAST
public Link(String href)
href
- must not be null or empty.REL_SELF
public Link(String href, String rel)
Link
to the given URI with the given rel.href
- must not be null or empty.rel
- must not be null or empty.public Link(UriTemplate template, String rel)
UriTemplate
and rel.template
- must not be null.rel
- must not be null or empty.protected Link()
public String getHref()
public String getRel()
public Link withRel(String rel)
Link
pointing to the same URI but with the given relation.rel
- must not be null or empty.public Link withSelfRel()
Link
pointing to the same URI but with the self
relation.public List<String> getVariableNames()
public List<TemplateVariable> getVariables()
TemplateVariables
contained in the Link
.public boolean isTemplated()
public Link expand(Object... arguments)
Link
by expanding it using the given parameters.arguments
- public Link expand(Map<String,? extends Object> arguments)
Link
by expanding it using the given parameters.arguments
- must not be null.public static Link valueOf(String element)
Link
instances from RFC-5988 compatible String
representations of a
link. Will return null if an empty or null String
is given.element
- an RFC-5899 compatible representation of a link.IllegalArgumentException
- if a non-empty String
was given that does not adhere to RFC-5899.IllegalArgumentException
- if no rel
attribute could be found.Copyright © 2012-2015–2015 Pivotal, Inc.. All rights reserved.