Klasse Link
java.lang.Object
de.kamillionlabs.hateoflux.model.link.Link
Represents a hypermedia link with various attributes defining aspects of the link such as
href, templated nature, and media type among others.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungderiveNavigationLinks(HalPageInfo pagingInformation, SortCriteria... sortCriteria) Derives a list of navigational links (i.e., self, first, prev, next, last) based on the provided pagination and sorting information.deriveNavigationLinks(HalPageInfo pagingInformation, List<SortCriteria> sortCriteria) Variation of thederiveNavigationLinks(HalPageInfo, SortCriteria...)method.Utility method that serves as a proxy forUriExpander.expand(String, Object...).Utility method that serves as a proxy forUriExpander.expand(String, Map).Utility method that serves as a proxy forUriExpander.expand(String, Map, boolean).booleanIndicates whether the href is a URI template that should be templated with variables.static LinklinkAsSelfOf(String href) Creates a newLinkinstance with an IANA relation of typeIanaRelation.SELF.static Linkof(IanaRelation relation, String href) Creates a newLinkinstance and associates it with a specified IANA relation.static LinkCreates a newLinkinstance with the specified href but without any IANA relation.prependBaseUrl(String baseUrl) Prepends the provided base URL to the currenthref.prependBaseUrl(org.springframework.http.server.reactive.ServerHttpRequest httpRequest) Extracts the base URL from the givenServerHttpRequestand prepends it to the currenthref.prependBaseUrl(org.springframework.web.server.ServerWebExchange exchangeWithBaseUrl) Extracts the base URL from the givenServerWebExchangeand prepends it to the currenthref.Appends a specified URI part to the currentLink's href.withDeprecation(String deprecation) A URL that provides information about the deprecation of the link, useful for alerting API consumers that a resource is outdated or scheduled for removal.The URI of the linked resource.withHreflang(String hreflang) Specifies the language of the linked resource, useful for applications supporting multiple languages.Describes the media type of the linked resource, often used to specify the type of content that the client can expect at the URL, such as "application/json" or "text/html".An identifier or label for the link, used for documentation or as additional metadata in client applications.withProfile(String profile) A hint about the profile (or schema) that the linked resource conforms to, providing additional semantics about the linked resource.withRel(IanaRelation relation) The relationship between the current resource and the linked resource.The relationship between the current resource and the linked resource.The relationship between the current resource and the linked resource.A human-readable title for the link, which can be used for labeling the link in user interfaces.Further specifies the MIME type of the linked resource's expected content.
-
Methodendetails
-
of
Creates a newLinkinstance with the specified href but without any IANA relation. This is useful for creating links that do not need to express a specific relationship type.- Parameter:
href- Hypertext REFerence, commonly known as a URL (e.g., https://www.github.com).- Gibt zurück:
- A new instance of
Linkwith no IANA relation.
-
of
Creates a newLinkinstance and associates it with a specified IANA relation. This method defines the type of relationship between the current resource and the linked resource.- Parameter:
relation- IANA relation of the link, which must not be null (seeIanaRelationfor details).href- Hypertext REFerence, commonly known as a URL (e.g., https://www.github.com).- Gibt zurück:
- A new instance of
Linkwith the specified IANA relation.
-
linkAsSelfOf
Creates a newLinkinstance with an IANA relation of typeIanaRelation.SELF. This type indicates that the link's URI is a reference to the resource itself.- Parameter:
href- Hypertext REFerence, commonly known as a URL (e.g., https://www.github.com).- Gibt zurück:
- A new instance of
Linkwith a "self" IANA relation.
-
isTemplated
public boolean isTemplated()Indicates whether the href is a URI template that should be templated with variables.- Gibt zurück:
trueif href of the link is templated;falseotherwise
-
withRel
The relationship between the current resource and the linked resource. Common values include "self", "next", "previous", etc. Custom relations can also be used.- Parameter:
relation- A string specifying the IANA relation of the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the specified relation added.
-
withRel
The relationship between the current resource and the linked resource. Common values include "self", "next", "prev", etc. Custom relations can also be used.- Parameter:
relation- The IANA relation of the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the specified IANA relation added.
-
withSelfRel
The relationship between the current resource and the linked resource. Common values include "self", "next", "prev", etc. Custom relations can also be used.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the "self" relation.
-
withHref
The URI of the linked resource. This is a required attribute and is the actual URL where the resource can be accessed.- Parameter:
href- The new href for the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the updated href.
-
withTitle
A human-readable title for the link, which can be used for labeling the link in user interfaces.- Parameter:
title- The new title for the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the updated title.
-
withName
An identifier or label for the link, used for documentation or as additional metadata in client applications.- Parameter:
name- The new name for the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the updated name.
-
withMedia
Describes the media type of the linked resource, often used to specify the type of content that the client can expect at the URL, such as "application/json" or "text/html".- Parameter:
media- The new media type for the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the updated media type.
-
withType
Further specifies the MIME type of the linked resource's expected content. This can be used to indicate more specific formats when multiple representations are available.- Parameter:
type- The new MIME type for the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the updated type.
-
withDeprecation
A URL that provides information about the deprecation of the link, useful for alerting API consumers that a resource is outdated or scheduled for removal.- Parameter:
deprecation- The new deprecation URL for the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the updated deprecation URL.
-
withProfile
A hint about the profile (or schema) that the linked resource conforms to, providing additional semantics about the linked resource.- Parameter:
profile- The new profile URL for the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the updated profile.
-
withHreflang
Specifies the language of the linked resource, useful for applications supporting multiple languages.- Parameter:
hreflang- The new language code for the link.- Gibt zurück:
- Returns a new
Linkthat is a copy of the current link with the updated language code.
-
slash
Appends a specified URI part to the currentLink's href. The method ensures proper formatting with slashes.- Parameter:
uriPart- The URI part to be appended.- Gibt zurück:
- A new
Linkobject with the appended URI part.
-
prependBaseUrl
Extracts the base URL from the givenServerHttpRequestand prepends it to the currenthref.- Parameter:
httpRequest- The request that provides the data to extract the base URL from.- Gibt zurück:
- A new
Linkobject with the prepended base URL.
-
prependBaseUrl
Extracts the base URL from the givenServerWebExchangeand prepends it to the currenthref.- Parameter:
exchangeWithBaseUrl- The exchange that provides the data to extract the base URL from.- Gibt zurück:
- A new
Linkobject with the prepended base URL.
-
prependBaseUrl
Prepends the provided base URL to the currenthref.- Parameter:
baseUrl- Base URL to prepend to current link- Gibt zurück:
- A new
Linkobject with the prepended base URL.
-
expand
Utility method that serves as a proxy forUriExpander.expand(String, Object...). Please refer to mentioned method for full documentation.- Parameter:
parameters- parameters to expand in templated href- Gibt zurück:
- The expanded or original URI if expansion is not applicable
-
expand
Utility method that serves as a proxy forUriExpander.expand(String, Map, boolean). Please refer to mentioned method for full documentation.- Parameter:
parameters- to expand in templated hrefcollectionRenderedAsComposite- specifies whether the collection should be rendered as composite (true) or non-composite (false)- Gibt zurück:
- the expanded or original URI if expansion is not applicable
-
expand
Utility method that serves as a proxy forUriExpander.expand(String, Map). Please refer to mentioned method for full documentation.- Parameter:
parameters- to expand in templated href- Gibt zurück:
- the expanded or original URI if expansion is not applicable
-