Klasse HalListWrapper<ResourceT,EmbeddedT>

java.lang.Object
de.kamillionlabs.hateoflux.model.hal.HalWrapper<HalListWrapper<ResourceT,EmbeddedT>>
de.kamillionlabs.hateoflux.model.hal.HalListWrapper<ResourceT,EmbeddedT>
Typparameter:
ResourceT - the type of the primary object wrapped within each HalResourceWrapper
EmbeddedT - the type of the embedded resources related to each primary resource, contained within the HalResourceWrapper

public final class HalListWrapper<ResourceT,EmbeddedT> extends HalWrapper<HalListWrapper<ResourceT,EmbeddedT>>
Represents an immutable wrapper class for managing a collection of HalResourceWrapper instances in a hypermedia-driven format, adhering to HAL standards. This class is designed as a container for multiple resource wrappers, facilitating the representation of lists of resources and their associated embedded resources.

The HalListWrapper is a final class, not designed for extension. It maintains a collection of HalResourceWrapper objects, each holding a primary resource and its associated embedded resources. This container supports the structured representation of resource lists in hypermedia responses.

The class can be utilized by instantiating and populating it with HalResourceWrapper instances, accommodating the collective serialization of resources. It can also be enhanced with paging information through the HalPageInfo class, which allows the inclusion of pagination data in the hypermedia response to support scalable data interaction.

  • Methodendetails

    • wrap

      public static <ResourceT, EmbeddedT> HalListWrapper<ResourceT,EmbeddedT> wrap(@NonNull List<HalResourceWrapper<ResourceT,EmbeddedT>> listToWrap)
      Wraps a given list of resources, where each resource needs to be wrapped in a HalResourceWrapper. This method ensures that the list of resources conforms to HAL standards. Each HalResourceWrapper contains a main resource and an optional embedded resource.
      Typparameter:
      ResourceT - the type of the resource to be wrapped
      EmbeddedT - the type of the embedded resource
      Parameter:
      listToWrap - the list of resources to be wrapped
      Gibt zurück:
      a new instance containing the wrapped resources
      Siehe auch:
    • empty

      public static <ResourceT, EmbeddedT> HalListWrapper<ResourceT,EmbeddedT> empty(@NonNull String listName)
      Creates an empty HalListWrapper. This method is intended to be used when there is a need to explicitly communicate an empty result set. A later addition of data to this list is not intended.
      Typparameter:
      ResourceT - the type of the primary object that would be wrapped in HalResourceWrapper
      EmbeddedT - the type of the embedded resources related to the primary object
      Parameter:
      listName - the name of the list, used for identification in the response structure
      Gibt zurück:
      an instance of HalListWrapper with no HalResourceWrapper elements
    • empty

      public static <ResourceT, EmbeddedT> HalListWrapper<ResourceT,EmbeddedT> empty(@NonNull Class<?> listItemTypeAsNameOrigin)
      Creates an empty HalListWrapper. This method is intended to be used when there is a need to explicitly communicate an empty result set. A later addition of data to this list is not intended.
      Typparameter:
      ResourceT - the type of the primary object that would be wrapped in HalResourceWrapper
      EmbeddedT - the type of the embedded resources related to the primary object
      Parameter:
      listItemTypeAsNameOrigin - the class from which the list name is derived (see also Relation)
      Gibt zurück:
      an instance of HalListWrapper with no HalResourceWrapper elements
    • withPageInfo

      public HalListWrapper<ResourceT,EmbeddedT> withPageInfo(HalPageInfo pageInfo)
      Adds pagination details to the HalListWrapper.
      Parameter:
      pageInfo - paging information for the list
      Gibt zurück:
      New HalListWrapper with added pagination information
    • getResourceList

      public List<HalResourceWrapper<ResourceT,EmbeddedT>> getResourceList()
      Returns the held list of resources.
      Gibt zurück:
      the held list of resources.
    • getNameOfResourceList

      public String getNameOfResourceList()
      Name of the list of resources.
      Gibt zurück:
      Name of the list of resources.
    • isEmpty

      public boolean isEmpty()
      Indicates whether the wrapper hold a non-empty list.
      Gibt zurück:
      true if list is non-empty; false otherwise