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 eachHalResourceWrapperEmbeddedT- the type of the embedded resources related to each primary resource, contained within theHalResourceWrapper
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.
-
Feldübersicht
Von Klasse geerbte Felder de.kamillionlabs.hateoflux.model.hal.HalWrapper
links -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic <ResourceT,EmbeddedT>
HalListWrapper<ResourceT, EmbeddedT> Creates an emptyHalListWrapper.static <ResourceT,EmbeddedT>
HalListWrapper<ResourceT, EmbeddedT> Creates an emptyHalListWrapper.Name of the list of resources.Returns the held list of resources.booleanisEmpty()Indicates whether the wrapper hold a non-empty list.withPageInfo(HalPageInfo pageInfo) Adds pagination details to theHalListWrapper.static <ResourceT,EmbeddedT>
HalListWrapper<ResourceT, EmbeddedT> wrap(List<HalResourceWrapper<ResourceT, EmbeddedT>> listToWrap) Wraps a given list of resources, where each resource needs to be wrapped in aHalResourceWrapper.Von Klasse geerbte Methoden de.kamillionlabs.hateoflux.model.hal.HalWrapper
add, add, determineCollectionRelationName, determineRelationNameForObject, determineResourceRelationName, getLink, getLink, getLinks, getRequiredLink, getRequiredLink, isScalar, withLinks, withLinks
-
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 aHalResourceWrapper. This method ensures that the list of resources conforms to HAL standards. EachHalResourceWrappercontains a main resource and an optional embedded resource.- Typparameter:
ResourceT- the type of the resource to be wrappedEmbeddedT- 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 emptyHalListWrapper. 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 inHalResourceWrapperEmbeddedT- 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
HalListWrapperwith noHalResourceWrapperelements
-
empty
public static <ResourceT,EmbeddedT> HalListWrapper<ResourceT,EmbeddedT> empty(@NonNull Class<?> listItemTypeAsNameOrigin) Creates an emptyHalListWrapper. 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 inHalResourceWrapperEmbeddedT- the type of the embedded resources related to the primary object- Parameter:
listItemTypeAsNameOrigin- the class from which the list name is derived (see alsoRelation)- Gibt zurück:
- an instance of
HalListWrapperwith noHalResourceWrapperelements
-
withPageInfo
Adds pagination details to theHalListWrapper.- Parameter:
pageInfo- paging information for the list- Gibt zurück:
- New
HalListWrapperwith added pagination information
-
getResourceList
Returns the held list of resources.- Gibt zurück:
- the held list of resources.
-
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:
trueif list is non-empty;falseotherwise
-