Class Attributes
- java.lang.Object
-
- io.grpc.Attributes
-
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1764") @Immutable public final class Attributes extends Object
An immutable type-safe container of attributes.Annotation semantics
As a convention, annotations such as
Grpc.TransportAttr
is defined to associate attributeAttributes.Key
s and their propagation paths. The annotation may be applied to aKey
definition field, a method that returnsAttributes
, or a variable of typeAttributes
, to indicate that the annotatedAttributes
objects may contain the annotatedKey
.Javadoc users may click "USE" on the navigation bars of the annotation's javadoc page to view references of such annotation.
- Since:
- 1.13.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Attributes.Builder
The helper class to build an Attributes instance.static class
Attributes.Key<T>
Key for an key-value pair.
-
Field Summary
Fields Modifier and Type Field Description static Attributes
EMPTY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object o)
Returns true if the given object is also aAttributes
with an equal attribute values.<T> T
get(Attributes.Key<T> key)
Gets the value for the key, ornull
if it's not present.int
hashCode()
Returns a hash code for the attributes.Set<Attributes.Key<?>>
keys()
Deprecated.This method is being considered for removal, if you feel this method is needed please reach out on this Github issue: grpc-java/issues/1764.static Attributes.Builder
newBuilder()
Create a new builder.static Attributes.Builder
newBuilder(Attributes base)
Deprecated.UsetoBuilder()
on theAttributes
instance instead.Attributes.Builder
toBuilder()
Creates a new builder that is pre-populated with the content of this container.String
toString()
-
-
-
Field Detail
-
EMPTY
public static final Attributes EMPTY
-
-
Method Detail
-
get
@Nullable public <T> T get(Attributes.Key<T> key)
Gets the value for the key, ornull
if it's not present.
-
keys
@Deprecated public Set<Attributes.Key<?>> keys()
Deprecated.This method is being considered for removal, if you feel this method is needed please reach out on this Github issue: grpc-java/issues/1764.Returns set of keys stored in container.- Returns:
- Set of Key objects.
-
newBuilder
@Deprecated public static Attributes.Builder newBuilder(Attributes base)
Deprecated.UsetoBuilder()
on theAttributes
instance instead. This method will be removed in the future.Create a new builder that is pre-populated with the content from a given container.
-
newBuilder
public static Attributes.Builder newBuilder()
Create a new builder.
-
toBuilder
public Attributes.Builder toBuilder()
Creates a new builder that is pre-populated with the content of this container.- Returns:
- a new builder.
-
equals
public boolean equals(Object o)
Returns true if the given object is also aAttributes
with an equal attribute values.Note that if a stored values are mutable, it is possible for two objects to be considered equal at one point in time and not equal at another (due to concurrent mutation of attribute values).
This method is not implemented efficiently and is meant for testing.
- Overrides:
equals
in classObject
- Parameters:
o
- an object.- Returns:
- true if the given object is a
Attributes
equal attributes.
-
hashCode
public int hashCode()
Returns a hash code for the attributes.Note that if a stored values are mutable, it is possible for two objects to be considered equal at one point in time and not equal at another (due to concurrent mutation of attribute values).
-
-