Package org.springframework.hateoas
Class Link
java.lang.Object
org.springframework.hateoas.Link
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DefaultCurieProvider.Curie,LinkMixin
Value object for links.
- Author:
- Oliver Gierke, Greg Turnquist, Jens Schauder, Viliam Durina
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLink()Empty constructor required by the marshaling framework.protectedLink(String href, LinkRelation rel) Creates a newLinkto the given URI with the given rel.protectedLink(UriTemplate template, LinkRelation rel) Creates a new Link from the givenUriTemplateand rel. -
Method Summary
Modifier and TypeMethodDescriptionandAffordance(Affordance affordance) Create newLinkwith an additionalAffordance.andAffordances(List<Affordance> affordances) Create newLinkwith additionalAffordances.booleanTurns the current template into aLinkby expanding it using the given parameters.Turns the current template into aLinkby expanding it using the given parameters.Returns safe copy ofAffordances.@Nullable StringgetHref()@Nullable String@Nullable StringgetMedia()@Nullable StringgetName()@Nullable StringgetRel()@Nullable StringgetTitle()@Nullable StringgetType()Returns the variable names contained in the template.Returns allTemplateVariablescontained in theLink.inthashCode()booleanReturns whether the currentLinkhas the given link relation.booleanhasRel(LinkRelation rel) Returns whether theLinkhas the givenLinkRelation.booleanReturns whether the links are logically the same, i.e. share all link characteristics but might have different affordances attached.booleanReturns whether or not the link is templated.static LinkCreates a new link to the given URI with the self relation.static LinkCreates a newLinkto the given href with the given relation.static Linkof(String href, LinkRelation relation) Creates a newLinkto the given href andLinkRelation.static Linkof(UriTemplate template, String relation) Creates a newLinkto the givenUriTemplateand link relation.static Linkof(UriTemplate template, LinkRelation relation) toString()toUri()Returns the current href as URI after expanding the links without any arguments, i.e. all optional URITemplateVariables will be dropped.static LinkwithAffordances(List<Affordance> affordances) Creates a newLinkwith the givenAffordances.withDeprecation(@Nullable String deprecation) Create a newLinkby copying all attributes and applying the new deprecation.Create a newLinkby copying all attributes and applying the new href.withHreflang(@Nullable String hreflang) Create a newLinkby copying all attributes and applying the new hreflang.Create a newLinkby copying all attributes and applying the new media.Create a newLinkby copying all attributes and applying the new name.Returns a newLinkwithout anyAffordances.withProfile(@Nullable String profile) Create a newLinkby copying all attributes and applying the new profile.Creates a newLinkwith the same href but givenLinkRelation.withRel(LinkRelation relation) Creates a newLinkwith the same href but givenLinkRelation.Returns aLinkpointing to the same URI but with theselfrelation.Create a newLinkby copying all attributes and applying the new title.Create a newLinkby copying all attributes and applying the new type.
-
Field Details
-
ATOM_NAMESPACE
- See Also:
-
-
Constructor Details
-
Link
Creates a newLinkto the given URI with the given rel.- Parameters:
href- must not be null or empty.rel- must not be null or empty.
-
Link
Creates a new Link from the givenUriTemplateand rel.- Parameters:
template- must not be null.rel- must not be null or empty.
-
Link
protected Link()Empty constructor required by the marshaling framework.
-
-
Method Details
-
of
Creates a new link to the given URI with the self relation.- Parameters:
href- must not be null or empty.- Returns:
- Since:
- 1.1
- See Also:
-
of
Creates a newLinkto the given href with the given relation.- Parameters:
href- must not be null or empty.relation- must not be null or empty.- Returns:
- Since:
- 1.1
-
of
Creates a newLinkto the given href andLinkRelation.- Parameters:
href- must not be null or empty.relation- must not be null.- Returns:
- Since:
- 1.1
-
of
Creates a newLinkto the givenUriTemplateand link relation.- Parameters:
template- must not be null.relation- must not be null or empty.- Returns:
- Since:
- 1.1
-
of
- Parameters:
template- must not be null.relation- must not be null.- Returns:
- Since:
- 1.1
-
getAffordances
Returns safe copy ofAffordances.- Returns:
-
withSelfRel
Returns aLinkpointing to the same URI but with theselfrelation.- Returns:
-
andAffordance
Create newLinkwith an additionalAffordance.- Parameters:
affordance- must not be null.- Returns:
-
andAffordances
Create newLinkwith additionalAffordances.- Parameters:
affordances- must not be null.- Returns:
-
withAffordances
Creates a newLinkwith the givenAffordances.- Parameters:
affordances- must not be null.- Returns:
- will never be null.
-
withoutAffordances
Returns a newLinkwithout anyAffordances.- Returns:
- will never be null.
- Since:
- 3.0
-
getVariableNames
Returns the variable names contained in the template.- Returns:
-
getVariables
Returns allTemplateVariablescontained in theLink.- Returns:
-
isTemplated
public boolean isTemplated()Returns whether or not the link is templated.- Returns:
-
isSameAs
Returns whether the links are logically the same, i.e. share all link characteristics but might have different affordances attached.- Parameters:
other- must not be null.- Since:
- 3.0
-
expand
Turns the current template into aLinkby expanding it using the given parameters.- Parameters:
arguments-- Returns:
-
expand
Turns the current template into aLinkby expanding it using the given parameters.- Parameters:
arguments- must not be null.- Returns:
-
withRel
Creates a newLinkwith the same href but givenLinkRelation.- Parameters:
relation- must not be null.- Returns:
- will never be null.
-
withRel
Creates a newLinkwith the same href but givenLinkRelation.- Parameters:
relation- must not be null or empty.- Returns:
- will never be null.
-
hasRel
Returns whether the currentLinkhas the given link relation.- Parameters:
rel- must not be null or empty.- Returns:
-
hasRel
Returns whether theLinkhas the givenLinkRelation.- Parameters:
rel- must not be null.- Returns:
-
toUri
Returns the current href as URI after expanding the links without any arguments, i.e. all optional URITemplateVariables will be dropped. If the href contains mandatoryTemplateVariables, the URI creation will fail with anIllegalStateException.- Returns:
- will never be null.
- Throws:
IllegalStateException- in case the href contains mandatory URITemplateVariables.
-
valueOf
Factory method to easily createLinkinstances from RFC-8288 compatibleStringrepresentations of a link.- Parameters:
source- an RFC-8288 compatible representation of a link.- Returns:
- will never be null.
- Throws:
IllegalArgumentException- if aStringwas given that does not adhere to RFC-8288.IllegalArgumentException- if norelattribute could be found.
-
withHref
Create a newLinkby copying all attributes and applying the new href.- Parameters:
href- can be null- Returns:
- will never be null.
-
withHreflang
Create a newLinkby copying all attributes and applying the new hreflang.- Parameters:
hreflang- can be null- Returns:
- will never be null.
-
withMedia
Create a newLinkby copying all attributes and applying the new media.- Parameters:
media- can be null- Returns:
- will never be null.
-
withTitle
Create a newLinkby copying all attributes and applying the new title.- Parameters:
title- can be null- Returns:
- will never be null.
-
withType
Create a newLinkby copying all attributes and applying the new type.- Parameters:
type- can be null- Returns:
- will never be null.
-
withDeprecation
Create a newLinkby copying all attributes and applying the new deprecation.- Parameters:
deprecation- can be null- Returns:
- will never be null.
-
withProfile
Create a newLinkby copying all attributes and applying the new profile.- Parameters:
profile- can be null- Returns:
- will never be null.
-
withName
Create a newLinkby copying all attributes and applying the new name.- Parameters:
name- can be null- Returns:
- will never be null.
-
getRel
-
getHref
-
getHreflang
-
getMedia
-
getTitle
-
getType
-
getDeprecation
-
getProfile
-
getName
-
getTemplate
-
equals
-
hashCode
public int hashCode() -
toString
-