package org.ehcache.clustered.common.internal.store.operations;
import org.ehcache.spi.serialization.Serializer;
import java.nio.ByteBuffer;
public class ConditionalRemoveOperation<K, V> extends BaseKeyValueOperation<K, V> {
public ConditionalRemoveOperation(final K key, final V value, final long timeStamp) {
super(key, value, timeStamp);
}
ConditionalRemoveOperation(final ByteBuffer buffer, final Serializer<K> keySerializer, final Serializer<V> valueSerializer) {
super(buffer, keySerializer, valueSerializer);
}
@Override
public OperationCode getOpCode() {
return OperationCode.REMOVE_CONDITIONAL;
}
@Override
public Result<K, V> apply(final Result<K, V> previousOperation) {
if (previousOperation == null) {
return null;
} else {
if (getValue().equals(previousOperation.getValue())) {
return null;
} else {
return previousOperation;
}
}
}
}