ExplicitCacheEntrySerializer extends MatchingSerializer<ExplicitCacheEntry<?, ?>> { @Override public Object readID(final ByteBuffer buffer) { buffer.clear(); Object id = DecoratedKryo.readPropertyValue( kryo, cachedProperties[0], buffer ); buffer.clear(); return id; } ExplicitCacheEntrySerializer(final DecoratedKryo kryo); @SuppressWarnings({ "unchecked", "rawtypes" }) @Override ExplicitCacheEntry<?, ?> read(final ByteBuffer buffer); @Override void write(final ByteBuffer buffer,
                      final ExplicitCacheEntry<?, ?> object); @Override Object readID(final ByteBuffer buffer); @Override Class<?> getType();  }
@SuppressWarnings("unchecked") @Test public void canReadId() { TestEntity1 entity1 = new TestEntity1(); entity1.afterPropertiesSet(); ExplicitCacheEntry<String, TestEntity1> explicitCacheEntry1 = new ExplicitCacheEntry<String, TestEntity1>( entity1.getUniqueIdentifier(), entity1 ); ObjectBuffer objectBuffer = new ObjectBuffer( kryo ); byte[] data = objectBuffer.writeObjectData( explicitCacheEntry1 ); assertThat( (String) serializer.readID( ByteBuffer.wrap( data ) ), is( entity1.getUniqueIdentifier() ) ); ExplicitCacheEntry<Long, TestEntity1> explicitCacheEntry2 = objectBuffer.readObjectData( data, ExplicitCacheEntry.class ); explicitCacheEntry1.getBean().assertMatch( explicitCacheEntry2.getBean() ); }