Class DefaultCurieProvider
java.lang.Object
org.springframework.hateoas.mediatype.hal.DefaultCurieProvider
- All Implemented Interfaces:
CurieProvider
Default implementation of
CurieProvider
rendering a single configurable UriTemplate
based curie.- Since:
- 0.9
- Author:
- Oliver Gierke, Jeff Stano, Greg Turnquist
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Value object to get the curieLink
rendered in JSON. -
Field Summary
Fields inherited from interface org.springframework.hateoas.mediatype.hal.CurieProvider
NONE
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCurieProvider
(String name, UriTemplate uriTemplate) Creates a newDefaultCurieProvider
for the given name andUriTemplate
.DefaultCurieProvider
(Map<String, UriTemplate> curies) Creates a newDefaultCurieProvider
for the given curies.DefaultCurieProvider
(Map<String, UriTemplate> curies, String defaultCurieName) Creates a newDefaultCurieProvider
for the given curies using the one with the given name as default, which means to expand unprefixed, non-IANA link relations. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
getCurieHref
(String name, UriTemplate template) Returns the href for theDefaultCurieProvider.Curie
instance to be created.Collection<?>
getCurieInformation
(Links links) Returns an object to render as the base curie information.getNamespacedRelFor
(LinkRelation relation) Returns the rel to be rendered for the given rel.getNamespacedRelFrom
(Link link) Returns the rel to be rendered for the givenLink
.
-
Constructor Details
-
DefaultCurieProvider
Creates a newDefaultCurieProvider
for the given name andUriTemplate
. The curie will be used to expand previously unprefixed, non-IANA link relations.- Parameters:
name
- must not be null or empty.uriTemplate
- must not be null and contain exactly one template variable.
-
DefaultCurieProvider
Creates a newDefaultCurieProvider
for the given curies. If more than one curie is given, no default curie will be registered. UseDefaultCurieProvider(Map, String)
to define which of the provided curies shall be used as the default one.- Parameters:
curies
- must not be null.- Since:
- 0.19
- See Also:
-
DefaultCurieProvider
Creates a newDefaultCurieProvider
for the given curies using the one with the given name as default, which means to expand unprefixed, non-IANA link relations.- Parameters:
curies
- must not be null.defaultCurieName
- can be null.- Since:
- 0.19
-
-
Method Details
-
getCurieInformation
Description copied from interface:CurieProvider
Returns an object to render as the base curie information. Implementations have to make sure, the returned instances renders as defined in the spec.- Specified by:
getCurieInformation
in interfaceCurieProvider
- Parameters:
links
- theLinks
that have been added to the response so far.- Returns:
- must not be null.
-
getNamespacedRelFrom
Description copied from interface:CurieProvider
Returns the rel to be rendered for the givenLink
. Will potentially prefix the rel but also might decide not to, depending on the actual rel.- Specified by:
getNamespacedRelFrom
in interfaceCurieProvider
- Returns:
-
getNamespacedRelFor
Description copied from interface:CurieProvider
Returns the rel to be rendered for the given rel. Will potentially prefix the rel but also might decide not to, depending on the actual rel.- Specified by:
getNamespacedRelFor
in interfaceCurieProvider
- Returns:
-
getCurieHref
Returns the href for theDefaultCurieProvider.Curie
instance to be created. Will prepend the current application URI (servlet mapping) in case the template is not an absolute one in the first place.- Parameters:
name
- will never be null or empty.template
- will never be null.- Returns:
- the
String
to be used as href in theDefaultCurieProvider.Curie
to be created, must not be null.
-