All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gemstone.gemfire.internal.concurrent.MapCallbackAdapter Maven / Gradle / Ivy

There is a newer version: 2.0-BETA
Show newest version
/*
 * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You
 * may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License. See accompanying
 * LICENSE file.
 */

package com.gemstone.gemfire.internal.concurrent;

/**
 * Simple adapter class providing empty default implementations for
 * {@link MapCallback}.
 */
public class MapCallbackAdapter implements MapCallback {

  /**
   * @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) {
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy