Klasse HalWrapper<HalWrapperT extends HalWrapper<? extends HalWrapperT>>
java.lang.Object
de.kamillionlabs.hateoflux.model.hal.HalWrapper<HalWrapperT>
- Typparameter:
HalWrapperT- the implementation that is extendingHalWrapper
- Bekannte direkte Unterklassen:
HalEmbeddedWrapper,HalListWrapper,HalResourceWrapper
public abstract class HalWrapper<HalWrapperT extends HalWrapper<? extends HalWrapperT>>
extends Object
Abstract base class for HAL wrappers, providing essential functionality for managing hypermedia links according to
HAL (Hypertext Application Language) standards. This class facilitates the inclusion and handling of hypermedia
links, crucial for API navigability.
HalWrapper includes utility functions to manage hypermedia links. These functions allow subclasses to add,
and retrieve links, supporting structured implementation of HAL responses.
Subclasses are responsible for specific data implementations (e.g., resources, lists, pagination), using this class's link management capabilities.
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected final Map<LinkRelation, Link> Links of theHalWrapperas whole. -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected voidAdds links to theHalWrapper.protected voidAdds links to theHalWrapper.protected static StringdetermineCollectionRelationName(Class<?> clazz) Determines the collection name based onRelationannotation or using a default naming strategy.protected static StringdetermineRelationNameForObject(Object object) Determines the appropriate relation name for a given object based on its type.protected static StringdetermineResourceRelationName(Class<?> clazz) Determines the resource name based onRelationannotation or using a default naming strategy.getLink(IanaRelation relation) Get a specific link of the links of the wrapped resource(s).Get a specific link of the links of the wrapped resource(s).getLinks()Get the list of links of the wrapped resource(s).getRequiredLink(IanaRelation relation) Get a specific link of the links of the wrapped resource(s).getRequiredLink(String relation) Get a specific link of the links of the wrapped resource(s).protected static booleanAddsLinks to the currently wrapped resource.AddsLinks to the currently wrapped resource.
-
Felddetails
-
links
Links of theHalWrapperas whole.
-
-
Konstruktordetails
-
HalWrapper
protected HalWrapper()Creates emptyHalWrapper
-
-
Methodendetails
-
getLinks
Get the list of links of the wrapped resource(s).- Gibt zurück:
- the list of links of the wrapped resource(s).
-
getLink
Get a specific link of the links of the wrapped resource(s).- Parameter:
relation- Relation with which the link to retrieve is identified- Gibt zurück:
- Found link
-
getLink
Get a specific link of the links of the wrapped resource(s).- Parameter:
relation- Relation with which the link to retrieve is identified- Gibt zurück:
- Found link
-
getRequiredLink
Get a specific link of the links of the wrapped resource(s). In contrast togetLink(IanaRelation), this method assumes, that the link with the provided relation exists. Otherwise, an exception is thrown.- Parameter:
relation- Relation with which the link to retrieve is identified- Gibt zurück:
- Found link
-
getRequiredLink
Get a specific link of the links of the wrapped resource(s). In contrast togetLink(IanaRelation), this method assumes, that the link with the provided relation exists. Otherwise, an exception is thrown.- Parameter:
relation- Relation with which the link to retrieve is identified- Gibt zurück:
- Found link
-
withLinks
AddsLinks to the currently wrapped resource.- Parameter:
links- links to add- Gibt zurück:
- New wrapper with the added links
-
withLinks
AddsLinks to the currently wrapped resource.- Parameter:
links- links to add- Gibt zurück:
- New wrapper with the added links
-
add
Adds links to theHalWrapper. The list is not allowed to be null. The links in it must be fully specified with a href and a relation.- Parameter:
links- links to add- Löst aus:
IllegalArgumentException- if:- list is null
- Containing links that
- Containing links that are null or empty
- Containing links that have no href
- Containing links that have no link relation
-
add
Adds links to theHalWrapper. The list is not allowed to be null. The links in it must be fully specified with a href and a relation.- Parameter:
link- link to add- Löst aus:
IllegalArgumentException- if:- link is null or empty
- link has no href
- link has no link relation
-
determineCollectionRelationName
Determines the collection name based onRelationannotation or using a default naming strategy.- Parameter:
clazz- the resource class- Gibt zurück:
- the name to use for the collection
-
determineResourceRelationName
Determines the resource name based onRelationannotation or using a default naming strategy.- Parameter:
clazz- the resource class- Gibt zurück:
- the name to use for the resource
-
determineRelationNameForObject
Determines the appropriate relation name for a given object based on its type. This method classifies the object as either a collection or a single resource. If the object is an instance ofIterable, it is treated as a collection, otherwise, it is treated as a single resource. The relation name is derived based on theRelationannotation if present, or through a default naming convention otherwise.The method returns a name that is used to represent the relationship of the object in hypermedia-driven outputs:
- Parameter:
object- The object for which to determine the relation name, must not be null (collections also not empty).- Gibt zurück:
- The relation name for the object, suitable for use in generating hypermedia links.
- Löst aus:
IllegalArgumentException- If the object is null or empty.
-
isScalar
-