Klasse HalEmbeddedWrapper<EmbeddedT>

java.lang.Object
de.kamillionlabs.hateoflux.model.hal.HalWrapper<HalEmbeddedWrapper<EmbeddedT>>
de.kamillionlabs.hateoflux.model.hal.HalEmbeddedWrapper<EmbeddedT>
Typparameter:
EmbeddedT - the type of the objects being wrapped, which represent embedded resources related to the main data

public final class HalEmbeddedWrapper<EmbeddedT> extends HalWrapper<HalEmbeddedWrapper<EmbeddedT>>
Represents an immutable wrapper class for encapsulating embedded resources in a hypermedia-driven format, adhering to HAL standards. This class complements the HalResourceWrapper and HalListWrapper by focusing specifically on the management of embedded resources associated with the main resource.

The HalEmbeddedWrapper is a final class and is not intended for extension. It is designed to hold an instance of EmbeddedT, representing embedded resources that provide additional context or related data to the primary resource. This wrapper ensures that embedded resources are correctly serialized within their designated namespace in the output structure.

Instantiation of this class is usually not required by hand, as the many embed method HalResourceWrapper and HalListWrapper do this automatically (e.g. HalResourceWrapper.withEmbeddedResource(HalEmbeddedWrapper).

  • Methodendetails

    • isEmpty

      public boolean isEmpty()
      Indicates whether the wrapper holds a resource.
      Gibt zurück:
      true if the wrapper holds no resource; false otherwise
    • empty

      public static <EmbeddedT> HalEmbeddedWrapper<EmbeddedT> empty()
      Creates an empty instance.
      Typparameter:
      EmbeddedT - Type of the embedded resource
      Gibt zurück:
      the created empty instance
    • wrap

      public static <EmbeddedT> HalEmbeddedWrapper<EmbeddedT> wrap(EmbeddedT resourceToWrap)
      Wrapper for any given resource that is desired to be put as an embedded resource in either a HalListWrapper or a HalResourceWrapper, ensuring it conforms to HAL standards. When serialized, the resource is placed into the _embedded node.

      To comply with HAL, EmbeddedT must not be a collection or iterable. This enforcement helps maintain the rule that collections of HalEmbeddedWrapper are created, rather than a single wrapper containing multiple resources.

      Hint:
      Be aware that manual wrapping of an embedded resource is not required. When using a withEmbeddedXYZ() method from HalResourceWrapper or HalListWrapper, the wrapping of the embedded resource is automatically handled by these methods.

      Typparameter:
      EmbeddedT - the type of the resource to be wrapped
      Parameter:
      resourceToWrap - the object to wrap
      Gibt zurück:
      a new instance containing the wrapped resource
      Löst aus:
      IllegalArgumentException - if resourceToWrap is an iterable