Package io.smallrye.stork.api
Class Metadata<T extends Enum<T>>
- java.lang.Object
-
- io.smallrye.stork.api.Metadata<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)andwith(Enum, Object)methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMetadata.DefaultMetadataKey
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Metadataempty()Returns an empty set of metadata.EnumMap<T,Object>getMetadata()static Metadataof(Class<?> key)Returns an instance ofMetadatacontaining an empty set of values.static Metadataof(Class<?> key, Map<?,Object> metadata)Returns an instance ofMetadatacontaining metadata values.Metadatawith(T key, Object item)Creates a new instance ofMetadatawith the current entries, plusitem.
-
-
-
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 ofMetadatacontaining metadata values.- Parameters:
metadata- the metadata, must not benull, must not containnull, must not contain multiple objects of the same class- Returns:
- the new metadata
-
of
public static Metadata of(Class<?> key)
Returns an instance ofMetadatacontaining an empty set of values.- Parameters:
key- the type of metadata, must not benull- Returns:
- the new metadata
-
with
public Metadata 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:
item- the metadata to be added, must not benull.- Returns:
- the new instance of
Metadata
-
-