Package org.camunda.bpm.engine.rest.hal
Class HalLinker
- java.lang.Object
-
- org.camunda.bpm.engine.rest.hal.HalLinker
-
public class HalLinker extends Object
A stateful linker which collects information about the links it creates.- Author:
- Daniel Meyer
-
-
Field Summary
Fields Modifier and Type Field Description protected Hal
hal
protected HalResource<?>
resource
The HalResource on which the links are constructed
-
Constructor Summary
Constructors Constructor Description HalLinker(Hal hal, HalResource<?> resource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createLink(HalRelation rel, String... pathParams)
Creates a link in a given relation.Set<HalRelation>
getLinkedRelations()
Set<String>
getLinkedResourceIdsByRelation(HalRelation relation)
void
mergeLinks(HalResource<?> embedded)
merge the links of an embedded resource into this linker.List<HalResource<?>>
resolve(HalRelation relation, ProcessEngine processEngine)
Resolves a relation.
-
-
-
Field Detail
-
hal
protected final Hal hal
-
resource
protected final HalResource<?> resource
The HalResource on which the links are constructed
-
-
Constructor Detail
-
HalLinker
public HalLinker(Hal hal, HalResource<?> resource)
-
-
Method Detail
-
createLink
public void createLink(HalRelation rel, String... pathParams)
Creates a link in a given relation.- Parameters:
rel
- theHalRelation
for which a link should be constructedpathParams
- the path params to populate the url template with.
-
getLinkedRelations
public Set<HalRelation> getLinkedRelations()
-
getLinkedResourceIdsByRelation
public Set<String> getLinkedResourceIdsByRelation(HalRelation relation)
-
resolve
public List<HalResource<?>> resolve(HalRelation relation, ProcessEngine processEngine)
Resolves a relation. Locates a HalLinkResolver for resolving the set of all linked resources in the relation.- Parameters:
relation
- the relation to resolveprocessEngine
- the process engine to use- Returns:
- the list of resolved resources
- Throws:
RuntimeException
- if no HalLinkResolver can be found for the linked resource type.
-
mergeLinks
public void mergeLinks(HalResource<?> embedded)
merge the links of an embedded resource into this linker. This is useful when building resources which are actually resource collections. You can then merge the relations of all resources in the collection and the unique the set of linked resources to embed.- Parameters:
embedded
- the embedded resource for which the links should be merged into this linker.
-
-