Class Metadata

  • All Implemented Interfaces:
    Iterable<Object>

    public class Metadata
    extends Object
    implements Iterable<Object>
    Message metadata containers.

    This class stores message metadata that can be related to the transport layer or to the business / application.

    Instances of this class are immutable. Modification operation returned new instances. Contained instances are not constrained, but should be immutable. Only one instance of each class can be stored, as the class is used to retrieve the metadata.

    You can creates new instances using the of(Object...) and from(Iterable)methods.

    IMPORTANT: Experimental.

    • Method Detail

      • empty

        public static Metadata empty()
        Returns an empty set of metadata.
        Returns:
        the empty instance
      • of

        public static Metadata of​(Object... metadata)
        Returns an instance of Metadata containing multiple values.
        Parameters:
        metadata - the metadata, must not be null, must not contain null. The contained metadata must not have the same class.
        Returns:
        the new metadata
      • with

        public Metadata with​(Object meta)
        Creates a new instance of Metadata with the current entries, plus meta. If the current set of metadata contains already an instance of the class of meta, the value is replaced in the returned Metadata.
        Parameters:
        meta - the metadata to be added, must not be null.
        Returns:
        the new instance of Metadata
      • without

        public Metadata without​(Class<?> clazz)
        Creates a new instance of Metadata with the current entries, minus the entry associated with the given class. If there is no instance of the class in the current set of metadata, the same entries are composing returned instance of metadata.
        Parameters:
        clazz - instance from this class are removed from the metadata.
        Returns:
        the new instance of Metadata
      • copy

        public Metadata copy()
        Copies the current Metadata instance.
        Returns:
        the new instance.
      • iterator

        public Iterator<Object> iterator()
        Specified by:
        iterator in interface Iterable<Object>
        Returns:
        an iterator to traverse the set of metadata. This method will never return null.