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)
Deprecated.
since 1.1, use
of(String) |
|
Link(String href,
LinkRelation rel)
Deprecated.
since 1.1, use
of(String, LinkRelation) . |
|
Link(String href,
String rel)
Deprecated.
since 1.1, use
of(String, String) . |
|
Link(UriTemplate template,
LinkRelation rel)
Deprecated.
since 1.1, use
of(UriTemplate, LinkRelation) . |
|
Link(UriTemplate template,
String rel)
Deprecated.
since 1.1, use
of(UriTemplate, String) . |
Modifier and Type | Method and Description |
---|---|
Link |
andAffordance(Affordance affordance)
Create new
Link with an additional Affordance . |
Link |
andAffordances(List<Affordance> affordances)
Create new
Link with additional Affordance s. |
boolean |
equals(Object o) |
Link |
expand(Map<String,?> 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
Affordance s. |
String |
getDeprecation() |
String |
getHref() |
String |
getHreflang() |
String |
getMedia() |
String |
getName() |
String |
getProfile() |
LinkRelation |
getRel() |
UriTemplate |
getTemplate() |
String |
getTitle() |
String |
getType() |
List<String> |
getVariableNames()
Returns the variable names contained in the template.
|
List<TemplateVariable> |
getVariables()
Returns all
TemplateVariables contained in the Link . |
int |
hashCode() |
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.
|
static Link |
of(String href)
Creates a new link to the given URI with the self relation.
|
static Link |
of(String href,
LinkRelation relation)
Creates a new
Link to the given href and LinkRelation . |
static Link |
of(String href,
String relation)
Creates a new
Link to the given href with the given relation. |
static Link |
of(UriTemplate template,
LinkRelation relation)
|
static Link |
of(UriTemplate template,
String relation)
Creates a new
Link to the given UriTemplate and link relation. |
String |
toString() |
URI |
toUri()
Returns the current href as URI after expanding the links without any arguments, i.e. all optional URI
TemplateVariable s will be dropped. |
static Link |
valueOf(String element)
|
Link |
withAffordances(List<Affordance> affordances)
Creats a new
Link with the given Affordance s. |
Link |
withDeprecation(String deprecation)
Create a new
Link by copying all attributes and applying the new deprecation. |
Link |
withHref(String href)
Create a new
Link by copying all attributes and applying the new href. |
Link |
withHreflang(String hreflang)
Create a new
Link by copying all attributes and applying the new hrefleng. |
Link |
withMedia(String media)
Create a new
Link by copying all attributes and applying the new media. |
Link |
withName(String name)
Create a new
Link by copying all attributes and applying the new name. |
Link |
withProfile(String profile)
Create a new
Link by copying all attributes and applying the new profile. |
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. |
Link |
withTitle(String title)
Create a new
Link by copying all attributes and applying the new title. |
Link |
withType(String type)
Create a new
Link by copying all attributes and applying the new type. |
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.@Deprecated public Link(String href)
of(String)
href
- must not be null or empty.IanaLinkRelations.SELF
@Deprecated public Link(String href, String rel)
of(String, String)
.Link
to the given URI with the given rel.href
- must not be null or empty.rel
- must not be null or empty.@Deprecated public Link(String href, LinkRelation rel)
of(String, LinkRelation)
.Link
to the given URI with the given rel.href
- must not be null or empty.rel
- must not be null or empty.@Deprecated public Link(UriTemplate template, String rel)
of(UriTemplate, String)
.UriTemplate
and rel.template
- must not be null.rel
- must not be null or empty.@Deprecated public Link(UriTemplate template, LinkRelation rel)
of(UriTemplate, LinkRelation)
.UriTemplate
and rel.template
- must not be null.rel
- must not be null or empty.protected Link()
public static Link of(String href)
href
- must not be null or empty.IanaLinkRelations.SELF
public static Link of(String href, String relation)
Link
to the given href with the given relation.href
- must not be null or empty.relation
- must not be null or empty.public static Link of(String href, LinkRelation relation)
Link
to the given href and LinkRelation
.href
- must not be null or empty.relation
- must not be null.public static Link of(UriTemplate template, String relation)
Link
to the given UriTemplate
and link relation.template
- must not be null.relation
- must not be null or empty.public static Link of(UriTemplate template, LinkRelation relation)
template
- must not be null.relation
- must not be null.public List<Affordance> getAffordances()
Affordance
s.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 andAffordances(List<Affordance> affordances)
Link
with additional Affordance
s.affordances
- must not be null.public Link withAffordances(List<Affordance> affordances)
Link
with the given Affordance
s.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,?> 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()
TemplateVariable
s will be dropped. If the href contains mandatory TemplateVariable
s, the URI
creation will fail with an IllegalStateException
.IllegalStateException
- in case the href contains mandatory URI TemplateVariable
s.public static Link valueOf(String element)
Link
instances from RFC-8288 compatible String
representations of a
link.element
- an RFC-8288 compatible representation of a link.IllegalArgumentException
- if a String
was given that does not adhere to RFC-8288.IllegalArgumentException
- if no rel
attribute could be found.public Link withHref(String href)
Link
by copying all attributes and applying the new href.href
- public Link withHreflang(String hreflang)
Link
by copying all attributes and applying the new hrefleng.hreflang
- public Link withMedia(String media)
Link
by copying all attributes and applying the new media.media
- public Link withTitle(String title)
Link
by copying all attributes and applying the new title.title
- public Link withType(String type)
Link
by copying all attributes and applying the new type.type
- public Link withDeprecation(String deprecation)
Link
by copying all attributes and applying the new deprecation.deprecation
- public Link withProfile(String profile)
Link
by copying all attributes and applying the new profile.profile
- public Link withName(String name)
Link
by copying all attributes and applying the new name.name
- public LinkRelation getRel()
public String getHref()
public UriTemplate getTemplate()
Copyright © 2011–2021 VMware, Inc.. All rights reserved.