@Test(expectedExceptions = IllegalArgumentException.class) public void testKeyToStringWithDefaultTransformerForNonSerializableObject() { NonSerializableKey key = new NonSerializableKey("test"); keyTransformationHandler.keyToString(key); }
public String keyToString(Object key) { if (key instanceof byte[]) return "A:" + Base64.getEncoder().encodeToString((byte[]) key); if (key instanceof String) return "S:" + key; else if (key instanceof Integer) return "I:" + key; else if (key instanceof Boolean) return "B:" + key; else if (key instanceof Long) return "L:" + key; else if (key instanceof Float) return "F:" + key; else if (key instanceof Double) return "D:" + key; else if (key instanceof Short) return "X:" + key; else if (key instanceof Byte) return "Y:" + key; else if (key instanceof Character) return "C:" + key; else if (key instanceof UUID) return "U:" + key; else { Transformer t = getTransformer(key.getClass()); if (t != null) { return "T:" + key.getClass().getName() + ":" + t.toString(key); } else { throw CONTAINER.noTransformerForKey(key.getClass().getName()); } } }
KeyTransformationHandler { public String keyToString(Object key) { if (key instanceof byte[]) return "A:" + Base64.getEncoder().encodeToString((byte[]) key); if (key instanceof String) return "S:" + key; else if (key instanceof Integer) return "I:" + key; else if (key instanceof Boolean) return "B:" + key; else if (key instanceof Long) return "L:" + key; else if (key instanceof Float) return "F:" + key; else if (key instanceof Double) return "D:" + key; else if (key instanceof Short) return "X:" + key; else if (key instanceof Byte) return "Y:" + key; else if (key instanceof Character) return "C:" + key; else if (key instanceof UUID) return "U:" + key; else { Transformer t = getTransformer(key.getClass()); if (t != null) { return "T:" + key.getClass().getName() + ":" + t.toString(key); } else { throw CONTAINER.noTransformerForKey(key.getClass().getName()); } } } }
KeyTransformationHandler { public String keyToString(Object key) { if (key instanceof byte[]) return "A:" + Base64.getEncoder().encodeToString((byte[]) key); if (key instanceof String) return "S:" + key; else if (key instanceof Integer) return "I:" + key; else if (key instanceof Boolean) return "B:" + key; else if (key instanceof Long) return "L:" + key; else if (key instanceof Float) return "F:" + key; else if (key instanceof Double) return "D:" + key; else if (key instanceof Short) return "X:" + key; else if (key instanceof Byte) return "Y:" + key; else if (key instanceof Character) return "C:" + key; else if (key instanceof UUID) return "U:" + key; else { Transformer t = getTransformer(key.getClass()); if (t != null) { return "T:" + key.getClass().getName() + ":" + t.toString(key); } else { throw CONTAINER.noTransformerForKey(key.getClass().getName()); } } } KeyTransformationHandler(ClassLoader classLoader); }
KeyTransformationHandler { public String keyToString(Object key) { if (key instanceof byte[]) return "A:" + Base64.getEncoder().encodeToString((byte[]) key); if (key instanceof String) return "S:" + key; else if (key instanceof Integer) return "I:" + key; else if (key instanceof Boolean) return "B:" + key; else if (key instanceof Long) return "L:" + key; else if (key instanceof Float) return "F:" + key; else if (key instanceof Double) return "D:" + key; else if (key instanceof Short) return "X:" + key; else if (key instanceof Byte) return "Y:" + key; else if (key instanceof Character) return "C:" + key; else if (key instanceof UUID) return "U:" + key; else { Transformer t = getTransformer(key.getClass()); if (t != null) { return "T:" + key.getClass().getName() + ":" + t.toString(key); } else { throw CONTAINER.noTransformerForKey(key.getClass().getName()); } } } KeyTransformationHandler(ClassLoader classLoader); Object stringToKey(String s); String keyToString(Object key); void registerTransformer(Class<?> keyClass, Class<? extends Transformer> transformerClass); }
KeyTransformationHandler { public String keyToString(Object key) { if (key instanceof byte[]) return "A:" + Base64.getEncoder().encodeToString((byte[]) key); if (key instanceof String) return "S:" + key; else if (key instanceof Integer) return "I:" + key; else if (key instanceof Boolean) return "B:" + key; else if (key instanceof Long) return "L:" + key; else if (key instanceof Float) return "F:" + key; else if (key instanceof Double) return "D:" + key; else if (key instanceof Short) return "X:" + key; else if (key instanceof Byte) return "Y:" + key; else if (key instanceof Character) return "C:" + key; else if (key instanceof UUID) return "U:" + key; else { Transformer t = getTransformer(key.getClass()); if (t != null) { return "T:" + key.getClass().getName() + ":" + t.toString(key); } else { throw CONTAINER.noTransformerForKey(key.getClass().getName()); } } } KeyTransformationHandler(ClassLoader classLoader); Object stringToKey(String s); String keyToString(Object key); void registerTransformer(Class<?> keyClass, Class<? extends Transformer> transformerClass);  }