/** * Call toUrlSafe() on the underlying Key. You can reconstitute a {@code Key<?>} using the * constructor that takes a string. Note that toString() is only useful for debugging; * it cannot be used to create a key with Key.create(String). */ public String toUrlSafe() { return this.raw.toUrlSafe(); }
private String toCacheKey(final Key key) { return key.toUrlSafe(); }
@Test public void testToAndFromUrlSafe() throws Exception { Key key = Key.newBuilder("d", "k", "n").build(); String urlSafe = key.toUrlSafe(); Key copy = Key.fromUrlSafe(urlSafe); assertEquals(key, copy); } }
@Override public void serialize(final Key value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeFieldName(value.toUrlSafe()); } }
@Override public void serialize(final Key value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeString(value.toUrlSafe()); } }
/** * This is an alias for toLegacyUrlSafe() and exists solely for backwards compatibility. * * @deprecated Use toLegacyUrlSafe(), or if you aren't trying to generate old-style keys, use * toUrlSafe(). */ @Deprecated public String toWebSafeString() { return this.raw.toUrlSafe(); }
@Override public String getEncoded() { return key.toUrlSafe(); }
@Override public String toString() { return key.toUrlSafe(); }