Package io.quarkus.hal
Class HalService
java.lang.Object
io.quarkus.hal.HalService
Service with Hal utilities. This service is used by the Resteasy Links, Resteasy Reactive Links and the
Rest Data Panache extensions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetClassLinks(Class<?> entityClass) Get the Hal links using the entity type class.getInstanceLinks(Object entity) Get the Hal links using the entity instance.getSelfLink(Object entity) Get the HREF link with reference `self` from the Hal links of the entity instance.<T> HalCollectionWrapper<T>toHalCollectionWrapper(Collection<T> collection, String collectionName, Class<?> entityClass) Wrap a collection of objects into a Hal collection wrapper by resolving the Hal links.<T> HalEntityWrapper<T>toHalWrapper(T entity) Wrap an entity into a Hal instance by including the entity itself and the Hal links.
-
Constructor Details
-
HalService
public HalService()
-
-
Method Details
-
toHalCollectionWrapper
public <T> HalCollectionWrapper<T> toHalCollectionWrapper(Collection<T> collection, String collectionName, Class<?> entityClass) Wrap a collection of objects into a Hal collection wrapper by resolving the Hal links. The Hal collection wrapper is then serialized by either json or jackson.- Parameters:
collection- The collection of objects to wrap.collectionName- The name that will include the collection of objects within the `_embedded` Hal object.entityClass- The class of the objects in the collection. If null, it will not resolve the links for these objects.- Returns:
- The Hal collection wrapper instance.
-
toHalWrapper
Wrap an entity into a Hal instance by including the entity itself and the Hal links.- Parameters:
entity- The entity to wrap.- Returns:
- The Hal entity wrapper.
-
getSelfLink
Get the HREF link with reference `self` from the Hal links of the entity instance.- Parameters:
entity- The entity instance where to get the Hal links.- Returns:
- the HREF link with rel `self`.
-
getClassLinks
Get the Hal links using the entity type class.- Parameters:
entityClass- The entity class to get the Hal links.- Returns:
- a map with the Hal links which keys are the rel attributes, and the values are the href attributes.
-
getInstanceLinks
Get the Hal links using the entity instance.- Parameters:
entity- the Object instance.- Returns:
- a map with the Hal links which keys are the rel attributes, and the values are the href attributes.
-