Class Entity<T>

  • Type Parameters:
    T - entity type.


    public final class Entity<T>
    extends java.lang.Object
    Encapsulates message entity including the associated variant information.
    • Method Detail

      • entity

        public static <T> Entity<T> entity​(T entity,
                                           MediaType mediaType)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        mediaType - entity content type.
        Returns:
        entity instance.
      • entity

        public static <T> Entity<T> entity​(T entity,
                                           MediaType mediaType,
                                           java.lang.annotation.Annotation[] annotations)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        mediaType - entity content type.
        annotations - entity annotations.
        Returns:
        entity instance.
      • entity

        public static <T> Entity<T> entity​(T entity,
                                           java.lang.String mediaType)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        mediaType - entity content type.
        Returns:
        entity instance.
        Throws:
        java.lang.IllegalArgumentException - if the supplied string cannot be parsed or is null.
      • entity

        public static <T> Entity<T> entity​(T entity,
                                           Variant variant)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        variant - entity variant information.
        Returns:
        entity instance.
      • entity

        public static <T> Entity<T> entity​(T entity,
                                           Variant variant,
                                           java.lang.annotation.Annotation[] annotations)
        Create an entity using a supplied content media type.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        variant - entity variant information.
        annotations - entity annotations.
        Returns:
        entity instance.
      • text

        public static <T> Entity<T> text​(T entity)
        Create a "text/plain" entity.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        Returns:
        "text/plain" entity instance.
      • xml

        public static <T> Entity<T> xml​(T entity)
        Create an "application/xml" entity.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        Returns:
        "application/xml" entity instance.
      • json

        public static <T> Entity<T> json​(T entity)
        Create an "application/json" entity.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        Returns:
        "application/json" entity instance.
      • html

        public static <T> Entity<T> html​(T entity)
        Create a "text/html" entity.
        Type Parameters:
        T - entity Java type.
        Parameters:
        entity - entity data.
        Returns:
        "text/html" entity instance.
      • getVariant

        public Variant getVariant​()
        Get entity variant information.
        Returns:
        entity variant information.
      • getMediaType

        public MediaType getMediaType​()
        Get entity media type.
        Returns:
        entity media type.
      • getEncoding

        public java.lang.String getEncoding​()
        Get entity encoding.
        Returns:
        entity encoding.
      • getLanguage

        public java.util.Locale getLanguage​()
        Get entity language.
        Returns:
        entity language.
      • getEntity

        public T getEntity​()
        Get entity data.
        Returns:
        entity data.
      • getAnnotations

        public java.lang.annotation.Annotation[] getAnnotations​()
        Get the entity annotations.
        Returns:
        entity annotations if set, an empty annotation array if no entity annotations have been specified.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode​()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object