BinaryValueReader implements ValueReader { @Override public <T> T read(Class<T> valueType, Object value) { if (value == null) { return null; } if (value instanceof byte[]) { return (T) new Binary((byte[]) value); } return (T) new Binary(value.toString().getBytes()); }  @Override boolean test(Class<?> type); @Override T read(Class<T> valueType, Object value);  }
@Test public void shouldConvert() { byte[] bytes = new byte[] {10, 10, 10}; assertEquals(new Binary(bytes), valueReader.read(Binary.class, bytes)); assertEquals(new Binary("hello".getBytes()), valueReader.read(Binary.class, "hello")); }