com.github.hal4j.resources.curie.CurieResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hal4j-api Show documentation
Show all versions of hal4j-api Show documentation
HAL API specification for Java
package com.github.hal4j.resources.curie;
import com.github.hal4j.uritemplate.URITemplate;
/**
* Represents a function that maps HAL link namespaces to URI templates. When constructing a resource
* the resource builder uses an instance implementing this interface to include CURIE links for each HAL link
* with a namespace.
*
* Example:
*
* {
* "_links" : {
* "curies" : [
* {
* "href" : "https://my.example.com/apidoc/v1/{rel}",
* "name" : "my",
* "template" : "true"
* },
* {
* "href" : "https://docs.another.com/api/{rel}",
* "name" : "another",
* "template" : "true"
* }
* ],
* "my:link" { "href": "https://my.example.com/api/v1/something" },
* "another:endpoint" { "href": "https://api.another.com/endpoint" },
* "self": { "href" : "https://api.example.com/object/123" }
* }
* }
*
* In this example namespace my
wasresolved
* to URI template https://my.example.com/apidoc/v1/{rel}
* and namespace another
to https://docs.another.com/api/{rel}
*
* @see com.github.hal4j.resources.ResourceSupport
* @see com.github.hal4j.resources.HALLink
*/
public interface CurieResolver {
/**
* Name of the relation containing CURIE links
*/
String REL_CURIES = "curies";
/**
* Returns CURIE link for given namespace
* @param namespace the namespace to look up the link
* @return CURIE link as URI template
*/
URITemplate resolve(String namespace);
}