MCPcopy Create free account
hub / github.com/grpc/grpc-java / TrustedAsciiKey

Class TrustedAsciiKey

api/src/main/java/io/grpc/Metadata.java:993–1017  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

991 }
992
993 private static final class TrustedAsciiKey<T> extends Key<T> {
994 private final TrustedAsciiMarshaller<T> marshaller;
995
996 /** Keys have a name and an ASCII marshaller used for serialization. */
997 private TrustedAsciiKey(String name, boolean pseudo, TrustedAsciiMarshaller<T> marshaller) {
998 super(name, pseudo, marshaller);
999 Preconditions.checkArgument(
1000 !name.endsWith(BINARY_HEADER_SUFFIX),
1001 "ASCII header is named %s. Only binary headers may end with %s",
1002 name,
1003 BINARY_HEADER_SUFFIX);
1004 this.marshaller = Preconditions.checkNotNull(marshaller, "marshaller");
1005 }
1006
1007 @Override
1008 byte[] toBytes(T value) {
1009 return Preconditions.checkNotNull(
1010 marshaller.toAsciiString(value), "null marshaller.toAsciiString()");
1011 }
1012
1013 @Override
1014 T parseBytes(byte[] serialized) {
1015 return marshaller.parseAsciiString(serialized);
1016 }
1017 }
1018
1019 /**
1020 * A specialized plain ASCII marshaller. Both input and output are assumed to be valid header

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected