public class Link extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static String |
ATOM_NAMESPACE |
static LinkRelation |
REL_FIRST
Deprecated.
Use
IanaLinkRelations.FIRST instead. |
static LinkRelation |
REL_LAST
Deprecated.
Use
IanaLinkRelations.LAST instead. |
static LinkRelation |
REL_NEXT
Deprecated.
Use
IanaLinkRelations.NEXT instead. |
static LinkRelation |
REL_PREVIOUS
Deprecated.
Use
IanaLinkRelations.PREV instead. |
static LinkRelation |
REL_SELF
Deprecated.
Use
IanaLinkRelations.SELF instead. |
| Modifier | Constructor and Description |
|---|---|
protected |
Link()
Empty constructor required by the marshaling framework.
|
|
Link(String href)
Creates a new link to the given URI with the self rel.
|
|
Link(String href,
LinkRelation rel)
Creates a new
Link to the given URI with the given rel. |
|
Link(String href,
String rel)
Creates a new
Link to the given URI with the given rel. |
|
Link(UriTemplate template,
LinkRelation rel)
Creates a new Link from the given
UriTemplate and rel. |
|
Link(UriTemplate template,
String rel)
Creates a new Link from the given
UriTemplate and rel. |
| Modifier and Type | Method and Description |
|---|---|
Link |
andAffordance(Affordance affordance)
Create new
Link with an additional Affordance. |
Link |
andAffordance(org.springframework.http.HttpMethod httpMethod,
Class<?> inputType,
List<QueryParameter> queryMethodParameters,
Class<?> outputType)
Convenience method when chaining an existing
Link. |
Link |
andAffordance(org.springframework.http.HttpMethod httpMethod,
org.springframework.core.ResolvableType inputType,
List<QueryParameter> queryMethodParameters,
org.springframework.core.ResolvableType outputType)
Convenience method when chaining an existing
Link. |
Link |
andAffordance(String name,
org.springframework.http.HttpMethod httpMethod,
org.springframework.core.ResolvableType inputType,
List<QueryParameter> queryMethodParameters,
org.springframework.core.ResolvableType outputType)
Convenience method when chaining an existing
Link. |
Link |
andAffordances(List<Affordance> affordances)
Create new
Link with additional Affordances. |
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. |
List<Affordance> |
getAffordances()
Returns safe copy of
Affordances. |
List<String> |
getVariableNames()
Returns the variable names contained in the template.
|
List<TemplateVariable> |
getVariables()
Returns all
TemplateVariables contained in the Link. |
boolean |
hasRel(LinkRelation rel)
Returns whether the
Link has the given LinkRelation. |
boolean |
hasRel(String rel)
Returns whether the current
Link has the given link relation. |
boolean |
isTemplated()
Returns whether or not the link is templated.
|
String |
toString() |
URI |
toUri()
Returns the current href as URI after expanding the links without any arguments, i.e. all optional URI
TemplateVariables will be dropped. |
static Link |
valueOf(String element)
|
Link |
withAffordances(List<Affordance> affordances)
Creats a new
Link with the given Affordances. |
Link |
withRel(LinkRelation relation)
Creates a new
Link with the same href but given LinkRelation. |
Link |
withRel(String relation)
Creates a new
Link with the same href but given LinkRelation. |
Link |
withSelfRel()
Returns a
Link pointing to the same URI but with the self relation. |
public static final String ATOM_NAMESPACE
@Deprecated public static final LinkRelation REL_SELF
IanaLinkRelations.SELF instead.@Deprecated public static final LinkRelation REL_FIRST
IanaLinkRelations.FIRST instead.@Deprecated public static final LinkRelation REL_PREVIOUS
IanaLinkRelations.PREV instead.@Deprecated public static final LinkRelation REL_NEXT
IanaLinkRelations.NEXT instead.@Deprecated public static final LinkRelation REL_LAST
IanaLinkRelations.LAST instead.public Link(String href)
href - must not be null or empty.IanaLinkRelations.SELFpublic 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(String href, LinkRelation 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.public Link(UriTemplate template, LinkRelation rel)
UriTemplate and rel.template - must not be null.rel - must not be null or empty.protected Link()
public List<Affordance> getAffordances()
Affordances.public Link withSelfRel()
Link pointing to the same URI but with the self relation.public Link andAffordance(Affordance affordance)
Link with an additional Affordance.affordance - must not be null.public Link andAffordance(String name, org.springframework.http.HttpMethod httpMethod, org.springframework.core.ResolvableType inputType, List<QueryParameter> queryMethodParameters, org.springframework.core.ResolvableType outputType)
Link.name - httpMethod - inputType - queryMethodParameters - outputType - public Link andAffordance(org.springframework.http.HttpMethod httpMethod, org.springframework.core.ResolvableType inputType, List<QueryParameter> queryMethodParameters, org.springframework.core.ResolvableType outputType)
Link. Defaults the name of the affordance to verb + classname,
e.g. <httpMethod=HttpMethod.PUT, inputType=Employee> produces <name=putEmployee>.httpMethod - inputType - queryMethodParameters - outputType - public Link andAffordance(org.springframework.http.HttpMethod httpMethod, Class<?> inputType, List<QueryParameter> queryMethodParameters, Class<?> outputType)
Link. Defaults the name of the affordance to verb + classname,
e.g. <httpMethod=HttpMethod.PUT, inputType=Employee> produces <name=putEmployee>.httpMethod - inputType - queryMethodParameters - outputType - public Link andAffordances(List<Affordance> affordances)
Link with additional Affordances.affordances - must not be null.public Link withAffordances(List<Affordance> affordances)
Link with the given Affordances.affordances - must not be null.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 Link withRel(LinkRelation relation)
Link with the same href but given LinkRelation.relation - must not be null.public Link withRel(String relation)
Link with the same href but given LinkRelation.relation - must not be null or empty.public boolean hasRel(String rel)
Link has the given link relation.rel - must not be null or empty.public boolean hasRel(LinkRelation rel)
Link has the given LinkRelation.rel - must not be null.public URI toUri()
TemplateVariables will be dropped. If the href contains mandatory TemplateVariables, the URI
creation will fail with an IllegalStateException.IllegalStateException - in case the href contains mandatory URI TemplateVariables.public static Link valueOf(String element)
Link instances from RFC-5988 compatible String representations of a
link. Will return null if input String is either empty or null.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-2019–2019 Pivotal, Inc.. All rights reserved.