Class Metadata<T extends Enum<T>>


  • public class Metadata<T extends Enum<T>>
    extends Object
    Service Instance metadata.

    This class stores service instance metadata that can be used by the load balancer to select the service instance to use.

    Instances of this class are immutable. Modification operations return new instances.

    You can creates new instances using the of(Class), of(Class, Map) and with(Enum, Object)methods.

    • Method Detail

      • empty

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

        public static Metadata of​(Class<?> key,
                                  Map<?,​Object> metadata)
        Returns an instance of Metadata containing metadata values.
        Parameters:
        metadata - the metadata, must not be null, must not contain null, must not contain multiple objects of the same class
        Returns:
        the new metadata
      • of

        public static Metadata of​(Class<?> key)
        Returns an instance of Metadata containing an empty set of values.
        Parameters:
        key - the type of metadata, must not be null
        Returns:
        the new metadata
      • with

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