@Immutable
public abstract static class Metadata.Key<T>
extends java.lang.Object
Only the following ASCII characters are allowed in the names of keys:
0-9
A-Z
(normalized to lower)
a-z
-_.
This is a strict subset of the HTTP field-name rules. Applications may not send or receive metadata with invalid key names. However, the gRPC library may preserve any metadata received even if it does not conform to the above limitations. Additionally, if metadata contains non conforming field names, they will still be sent. In this way, unknown metadata fields are parsed, serialized and preserved, but never interpreted. They are similar to protobuf unknown fields.
Note this has to be the subset of valid HTTP/2 token characters as defined in RFC7230 Section 3.2.6 and RFC5234 Section B.1
Note that a key is immutable but it may not be deeply immutable, because the key depends on its marshaller, and the marshaller can be mutable though not recommended.
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals(java.lang.Object o) |
Returns true if the two objects are both Keys, and their names match (case insensitive).
|
int |
hashCode() |
|
java.lang.String |
name() |
|
static <T> Metadata.Key<T> |
of(java.lang.String name,
Metadata.AsciiMarshaller<T> marshaller) |
Creates a key for an ASCII header.
|
static <T> Metadata.Key<T> |
of(java.lang.String name,
Metadata.BinaryMarshaller<T> marshaller) |
Creates a key for a binary header.
|
java.lang.String |
originalName() |
|
java.lang.String |
toString() |
public static <T> Metadata.Key<T> of(java.lang.String name, Metadata.BinaryMarshaller<T> marshaller)
name
- Must contain only the valid key characters as defined in the class comment. Must
end with Metadata.BINARY_HEADER_SUFFIX
.public static <T> Metadata.Key<T> of(java.lang.String name, Metadata.AsciiMarshaller<T> marshaller)
name
- Must contain only the valid key characters as defined in the class comment. Must
not end with Metadata.BINARY_HEADER_SUFFIX
public final java.lang.String originalName()
public final java.lang.String name()
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object