Top Description Inners Fields Constructors Methods
io.grpc

public final Class Attributes

extends Object
Class Inheritance
Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1764
@Immutable
Static Imports
com.google.common.base.Preconditions.checkNotNull

An immutable type-safe container of attributes.

Annotation semantics

As a convention, annotations such as Grpc.TransportAttr is defined to associate attribute Keys 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.

Since
1.13.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Attributes.Builder

The helper class to build an Attributes instance.

public static class
Attributes.Key<
type of the value in the key-value pair
T
>

Key for an key-value pair.

Field Summary

Modifier and TypeField and Description
private final IdentityHashMap<Attributes.Key<?>, Object>
public static final Attributes
private static final IdentityHashMap<Attributes.Key<?>, Object>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the given object is a Attributes equal attributes.
equals
(Object
an object.
o
)

Overrides java.lang.Object.equals.

Returns true if the given object is also a Attributes with an equal attribute values.
public <T> T
get(Attributes.Key<T> key)

Gets the value for the key, or null if it's not present.

public int

Returns:

a hash code for the attributes map.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code for the attributes.
public Set<Attributes.Key<?>>

Returns:

Set of Key objects.
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.
pack-priv Set<Attributes.Key<?>>
public static Attributes.Builder
newBuilder(Attributes base)

Deprecated Use Attributes#toBuilder() on the Attributes instance instead.
Create a new builder that is pre-populated with the content from a given container.
public static Attributes.Builder
newBuilder()

Create a new builder.

public Attributes.Builder

Returns:

a new builder.
toBuilder
()

Creates a new builder that is pre-populated with the content of this container.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

databack to summary
private final IdentityHashMap<Attributes.Key<?>, Object> data
EMPTYback to summary
public static final Attributes EMPTY
EMPTY_MAPback to summary
private static final IdentityHashMap<Attributes.Key<?>, Object> EMPTY_MAP

Constructor Detail

Attributesback to summary
private Attributes(IdentityHashMap<Attributes.Key<?>, Object> data)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Returns true if the given object is also a 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.

Parameters
o:Object

an object.

Returns:boolean

true if the given object is a Attributes equal attributes.

Annotations
@Override
getback to summary
public <T> T get(Attributes.Key<T> key)

Gets the value for the key, or null if it's not present.

Annotations
@SuppressWarnings:unchecked
@Nullable
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.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).

Returns:int

a hash code for the attributes map.

Annotations
@Override
keysback to summary
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<Attributes.Key<?>>

Set of Key objects.

Annotations
@Deprecated
keysForTestback to summary
pack-priv Set<Attributes.Key<?>> keysForTest()
newBuilderback to summary
public static Attributes.Builder newBuilder(Attributes base)

Deprecated

Use Attributes#toBuilder() on the Attributes 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.

Annotations
@Deprecated
newBuilderback to summary
public static Attributes.Builder newBuilder()

Create a new builder.

toBuilderback to summary
public Attributes.Builder toBuilder()

Creates a new builder that is pre-populated with the content of this container.

Returns:Attributes.Builder

a new builder.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
io.grpc back to summary

public final Class Attributes.Builder

extends Object
Class Inheritance

The helper class to build an Attributes instance.

Field Summary

Modifier and TypeField and Description
private Attributes
private IdentityHashMap<Attributes.Key<?>, Object>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Attributes
build()

Build the attributes.

private IdentityHashMap<Attributes.Key<?>, Object>
data(int size)

public <T> Attributes.Builder

Returns:

this
discard
(Attributes.Key<T>
The key to remove
key
)

Removes the key and associated value from the attribtues.

public <T> Attributes.Builder
set(Attributes.Key<T> key, T value)

public Attributes.Builder
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseback to summary
private Attributes base
newdataback to summary
private IdentityHashMap<Attributes.Key<?>, Object> newdata

Constructor Detail

Builderback to summary
private Builder(Attributes base)

Method Detail

buildback to summary
public Attributes build()

Build the attributes.

databack to summary
private IdentityHashMap<Attributes.Key<?>, Object> data(int size)
discardback to summary
public <T> Attributes.Builder discard(Attributes.Key<T> key)

Removes the key and associated value from the attribtues.

Parameters
key:Attributes.Key<T>

The key to remove

Returns:Attributes.Builder

this

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/5777
Since
1.22.0
setback to summary
public <T> Attributes.Builder set(Attributes.Key<T> key, T value)
setAllback to summary
public Attributes.Builder setAll(Attributes other)
io.grpc back to summary

public final Class Attributes.Key<T>

extends Object
Class Inheritance
Annotations
@Immutable
@SuppressWarnings:UnusedTypeParameter
Type Parameters
<T>
type of the value in the key-value pair

Key for an key-value pair. Uses reference equality.

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
private
Key(String debugString)

Method Summary

Modifier and TypeMethod and Description
public static <
Key type
T
>
Attributes.Key<T>

Returns:

Key object
create
(String
a string used to describe the key, used for debugging.
debugString
)

Factory method for creating instances of Key.

public static <
Key type
T
>
Attributes.Key<T>

Returns:

Key object
of
(String
a string used to describe the key, used for debugging.
debugString
)

Deprecated use create instead. This method will be removed in the future.
Factory method for creating instances of Key.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

debugStringback to summary
private final String debugString

Constructor Detail

Keyback to summary
private Key(String debugString)

Method Detail

createback to summary
public static <T> Attributes.Key<T> create(String debugString)

Factory method for creating instances of Key.

Parameters
<T>
Key type
debugString:String

a string used to describe the key, used for debugging.

Returns:Attributes.Key<T>

Key object

ofback to summary
public static <T> Attributes.Key<T> of(String debugString)

Deprecated

use create instead. This method will be removed in the future.

Factory method for creating instances of Key.

Parameters
<T>
Key type
debugString:String

a string used to describe the key, used for debugging.

Returns:Attributes.Key<T>

Key object

Annotations
@Deprecated
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override