Class Metadata<T extends Enum<T> & MetadataKey>


  • public class Metadata<T extends Enum<T> & MetadataKey>
    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 create new instances using the of(Class), of(Class, Map) and with(Enum, Object)methods.
    • Method Detail

      • empty

        public static <T extends Enum<T> & MetadataKeyMetadata<T> empty()
        Returns an immutable, empty set of metadata.
        Returns:
        the empty instance
      • of

        public static <K extends Enum<K> & MetadataKeyMetadata<K> of​(Class<K> key,
                                                                       Map<K,​Object> metadata)
        Returns an instance of Metadata containing metadata values.
        Type Parameters:
        K - the key type
        Parameters:
        key - the class of the key, must not be null
        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 <K extends Enum<K> & MetadataKeyMetadata<K> of​(Class<K> key)
        Returns an instance of Metadata containing an empty set of values.
        Type Parameters:
        K - the type key type
        Parameters:
        key - the type of metadata, must not be null
        Returns:
        the new metadata
      • with

        public Metadata<T> 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:
        key - the key, must not be null
        item - the metadata to be added, must not be null.
        Returns:
        the new instance of Metadata
      • getMetadata

        public EnumMap<T,​Object> getMetadata()
        Returns:
        the metadata