5656 * </p>
5757 */
5858@ NotThreadSafe
59- public abstract class Metadata {
59+ public class Metadata {
6060
6161 /**
6262 * All binary headers should have this suffix in their names. Vice versa.
@@ -108,7 +108,7 @@ public Integer parseAsciiString(String serialized) {
108108 * Constructor called by the transport layer when it receives binary metadata.
109109 */
110110 // TODO(louiscryan): Convert to use ByteString so we can cache transformations
111- private Metadata (byte []... binaryValues ) {
111+ public Metadata (byte []... binaryValues ) {
112112 for (int i = 0 ; i < binaryValues .length ; i ++) {
113113 String name = new String (binaryValues [i ], US_ASCII );
114114 storeAdd (name , new MetadataEntry (name .endsWith (BINARY_HEADER_SUFFIX ), binaryValues [++i ]));
@@ -118,7 +118,7 @@ private Metadata(byte[]... binaryValues) {
118118 /**
119119 * Constructor called by the application layer when it wants to send metadata.
120120 */
121- private Metadata () {}
121+ public Metadata () {}
122122
123123 private void storeAdd (String name , MetadataEntry value ) {
124124 List <MetadataEntry > values = store .get (name );
@@ -286,6 +286,11 @@ public void merge(Metadata other, Set<Key<?>> keys) {
286286 }
287287 }
288288
289+ @ Override
290+ public String toString () {
291+ return "Metadata(" + toStringInternal () + ")" ;
292+ }
293+
289294 private String toStringInternal () {
290295 return store .toString ();
291296 }
@@ -375,31 +380,19 @@ public String toString() {
375380 /**
376381 * Concrete instance for metadata attached to the end of the call. Only provided by
377382 * servers.
383+ *
384+ * @deprecated use Metadata instead.
378385 */
386+ @ Deprecated
379387 public static class Trailers extends Metadata {
380- /**
381- * Called by the transport layer to create trailers from their binary serialized values.
382- *
383- * <p>This method does not copy the provided byte arrays. The byte arrays must not be mutated.
384- */
385- public Trailers (byte []... headers ) {
386- super (headers );
387- }
388-
389388 /**
390389 * Called by the application layer to construct trailers prior to passing them to the
391390 * transport for serialization.
392391 */
393392 public Trailers () {
394393 }
395-
396- @ Override
397- public String toString () {
398- return "Trailers(" + super .toStringInternal () + ")" ;
399- }
400394 }
401395
402-
403396 /**
404397 * Marshaller for metadata values that are serialized into raw binary.
405398 */
0 commit comments