@Test public void keyEqualsHashNameWorks() { Key<?> k1 = Key.of("case", Metadata.ASCII_STRING_MARSHALLER); Key<?> k2 = Key.of("CASE", Metadata.ASCII_STRING_MARSHALLER); assertEquals(k1, k1); assertNotEquals(k1, null); assertNotEquals(k1, new Object(){}); assertEquals(k1, k2); assertEquals(k1.hashCode(), k2.hashCode()); assertEquals("CASE", k2.originalName()); assertEquals("case", k2.name()); }
private byte[] name(int i) { return namesAndValues[i * 2]; }
Metadata { private byte[] name(int i) { return namesAndValues[i * 2]; } }
Metadata { private byte[] name(int i) { return namesAndValues[i * 2]; } Metadata(byte[]... binaryValues);   Metadata(int usedNames, byte[]... binaryValues);  Metadata(); }
Metadata { private byte[] name(int i) { return namesAndValues[i * 2]; } Metadata(byte[]... binaryValues);   Metadata(int usedNames, byte[]... binaryValues);  Metadata(); boolean containsKey(Key<?> key); @Nullable T get(Key<T> key); @Nullable Iterable<T> getAll(final Key<T> key); @SuppressWarnings("deprecation") // The String ctor is deprecated, but fast. Set<String> keys(); void put(Key<T> key, T value); boolean remove(Key<T> key, T value); Iterable<T> removeAll(Key<T> key); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4691") void discardAll(Key<T> key); void merge(Metadata other); void merge(Metadata other, Set<Key<?>> keys); @SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0 @Override String toString(); }
Metadata { private byte[] name(int i) { return namesAndValues[i * 2]; } Metadata(byte[]... binaryValues);   Metadata(int usedNames, byte[]... binaryValues);  Metadata(); boolean containsKey(Key<?> key); @Nullable T get(Key<T> key); @Nullable Iterable<T> getAll(final Key<T> key); @SuppressWarnings("deprecation") // The String ctor is deprecated, but fast. Set<String> keys(); void put(Key<T> key, T value); boolean remove(Key<T> key, T value); Iterable<T> removeAll(Key<T> key); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4691") void discardAll(Key<T> key); void merge(Metadata other); void merge(Metadata other, Set<Key<?>> keys); @SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0 @Override String toString(); static final String BINARY_HEADER_SUFFIX; static final BinaryMarshaller<byte[]> BINARY_BYTE_MARSHALLER; static final AsciiMarshaller<String> ASCII_STRING_MARSHALLER; }