void () { IndexStorage<Key, Value> storage = getStorage(); if (storage instanceof TransientChangesIndexStorage) { ((TransientChangesIndexStorage<Key, Value>)storage).addBufferingStateListener( new TransientChangesIndexStorage.BufferingStateListener() { @Override public void bufferingStateChanged(boolean newState) { myInMemoryMode.set(newState); } @Override public void memoryStorageCleared() { myInMemoryKeysAndValues.clear(); } }); } }