protected <T> Function<T, T> updateProxyInterceptor(final EntityOperations context, final ProxyInterceptor<T> interceptor, final Object entity, final Object primaryKey) {
return new Function<T, T>() {
@Override
public T apply(T freshEntity) {
if (freshEntity == null) {
throw new AchillesStaleObjectStateException("The entity '" + entity + "' with primary_key '" + primaryKey + "' no longer exists in Cassandra");
}
interceptor.setTarget(freshEntity);
interceptor.getAlreadyLoaded().clear();
interceptor.getAlreadyLoaded().addAll(context.getAllGettersExceptCounters());
return freshEntity;