@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1764") @Immutable public final class Attributes extends Object
As a convention, annotations such as Grpc.TransportAttr
is defined to associate
attribute Attributes.Key
s and their propagation paths. The annotation may be applied to a Key
definition field, a method that returns Attributes
, or a variable of type Attributes
, to indicate that the annotated Attributes
objects may contain the annotated
Key
.
Javadoc users may click "USE" on the navigation bars of the annotation's javadoc page to view references of such annotation.
Modifier and Type | Class and Description |
---|---|
static class |
Attributes.Builder
The helper class to build an Attributes instance.
|
static class |
Attributes.Key<T>
Key for an key-value pair.
|
Modifier and Type | Field and Description |
---|---|
static Attributes |
EMPTY |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Returns true if the given object is also a
Attributes with an equal attribute values. |
<T> T |
get(Attributes.Key<T> key)
Gets the value for the key, or
null 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.
Use
toBuilder() on the Attributes instance instead.
This method will be removed in the future. |
Attributes.Builder |
toBuilder()
Creates a new builder that is pre-populated with the content of this container.
|
String |
toString() |
public static final Attributes EMPTY
@Nullable public <T> T get(Attributes.Key<T> key)
null
if it's not present.@Deprecated public Set<Attributes.Key<?>> keys()
@Deprecated public static Attributes.Builder newBuilder(Attributes base)
toBuilder()
on the Attributes
instance instead.
This method will be removed in the future.public static Attributes.Builder newBuilder()
public Attributes.Builder toBuilder()
public boolean equals(Object o)
Attributes
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.
equals
in class Object
o
- an object.Attributes
equal attributes.public int hashCode()
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).