blob: d98a0128273522d703f060f2483aabe6d9f5aa4d [file] [log] [blame]
/*=========================================================================
* Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
* This product is protected by U.S. and international copyright
* and intellectual property laws. Pivotal products are covered by
* one or more patents listed at http://www.pivotal.io/patents.
*=========================================================================
*/
package com.gemstone.gemfire.internal.concurrent;
/**
* Simple adapter class providing empty default implementations for
* {@link MapCallback}.
*/
public class MapCallbackAdapter<K, V, C, P> implements MapCallback<K, V, C, P> {
/**
* @see MapCallback#newValue
*/
@Override
public V newValue(K key, C context, P createParams, MapResult result) {
return null;
}
/**
* @see MapCallback#updateValue
*/
@Override
public V updateValue(K key, V oldValue, C context, P params) {
return oldValue;
}
/**
* @see MapCallback#afterUpdate
*/
@Override
public void afterUpdate(K key, K mapKey, V newValue, C context) {
}
/**
* @see MapCallback#requiresUpdateValue
*/
@Override
public boolean requiresUpdateValue() {
return false;
}
/**
* @see MapCallback#oldValueRead
*/
@Override
public void oldValueRead(V oldValue) {
}
/**
* @see MapCallback#removeValue
*/
@Override
public Object removeValue(Object key, Object value, V existingValue,
C context, P removeParams) {
if (value != null
&& (value == NO_OBJECT_TOKEN || value.equals(existingValue))) {
return null;
}
else {
return ABORT_REMOVE_TOKEN;
}
}
/**
* @see MapCallback#postRemove
*/
@Override
public void postRemove(Object key, Object value, V existingValue, C context,
P removeParams) {
}
/**
* @see MapCallback#replaceValue
*/
@Override
public V replaceValue(K key, V oldValue, V existingValue, V newValue,
C context, P params) {
if (oldValue != null && oldValue.equals(existingValue)) {
return newValue;
}
else {
return null;
}
}
/**
* @see MapCallback#beforeReplace
*/
@Override
public Object beforeReplace(K mapKey, V newValue, C context, P params) {
return null;
}
/**
* @see MapCallback#afterReplace
*/
@Override
public void afterReplace(K mapKey, V newValue, Object beforeResult,
C context, P params) {
}
/**
* @see MapCallback#onReplaceFailed
*/
@Override
public void onReplaceFailed(K mapKey, V newValue, Object beforeResult,
C context, P params) {
}
/**
* @see MapCallback#onOperationFailed
*/
@Override
public V onOperationFailed(K key, Object oldValue, V updatedValue,
V newValue, C context, P params) {
return null;
}
/**
* @see MapCallback#onToArray
*/
@Override
public void onToArray(C context) {
}
}