Class HalService


  • public abstract class HalService
    extends Object
    Service with Hal utilities. This service is used by the Resteasy Links, Resteasy Reactive Links and the Rest Data Panache extensions.
    • Constructor Detail

      • HalService

        public HalService()
    • Method Detail

      • toHalCollectionWrapper

        public HalCollectionWrapper toHalCollectionWrapper​(Collection<Object> 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

        public HalEntityWrapper toHalWrapper​(Object entity)
        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

        public String getSelfLink​(Object entity)
        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

        protected abstract Map<String,​HalLink> getClassLinks​(Class<?> entityClass)
        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

        protected abstract Map<String,​HalLink> getInstanceLinks​(Object entity)
        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.