Package io.smallrye.stork.api
Class Metadata<T extends Enum<T> & MetadataKey>
- java.lang.Object
-
- io.smallrye.stork.api.Metadata<T>
-
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 theof(Class),of(Class, Map)andwith(Enum, Object)methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMetadata.DefaultMetadataKeyThe default metadata key.static classMetadata.NoMetadataKey
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T extends Enum<T> & MetadataKey>
Metadata<T>empty()Returns an immutable, empty set of metadata.EnumMap<T,Object>getMetadata()static <K extends Enum<K> & MetadataKey>
Metadata<K>of(Class<K> key)Returns an instance ofMetadatacontaining an empty set of values.static <K extends Enum<K> & MetadataKey>
Metadata<K>of(Class<K> key, Map<K,Object> metadata)Returns an instance ofMetadatacontaining metadata values.Metadata<T>with(T key, Object item)Creates a new instance ofMetadatawith the current entries, plusitem.
-
-
-
Method Detail
-
empty
public static <T extends Enum<T> & MetadataKey> Metadata<T> empty()
Returns an immutable, empty set of metadata.- Returns:
- the empty instance
-
of
public static <K extends Enum<K> & MetadataKey> Metadata<K> of(Class<K> key, Map<K,Object> metadata)
Returns an instance ofMetadatacontaining metadata values.- Type Parameters:
K- the key type- Parameters:
key- the class of the key, must not benullmetadata- the metadata, must not benull, must not containnull, must not contain multiple objects of the same class- Returns:
- the new metadata
-
of
public static <K extends Enum<K> & MetadataKey> Metadata<K> of(Class<K> key)
Returns an instance ofMetadatacontaining an empty set of values.- Type Parameters:
K- the type key type- Parameters:
key- the type of metadata, must not benull- Returns:
- the new metadata
-
with
public Metadata<T> with(T key, Object item)
Creates a new instance ofMetadatawith the current entries, plusitem. If the current set of metadata contains already an instance of the class ofitem, the value is replaced in the returnedMetadata.- Parameters:
key- the key, must not benullitem- the metadata to be added, must not benull.- Returns:
- the new instance of
Metadata
-
-