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

org.apache.geode.cache.InterestResultPolicy Maven / Gradle / Ivy

Go to download

Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing

There is a newer version: 1.15.1
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You 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.
 */


package org.apache.geode.cache;

import org.apache.geode.internal.cache.tier.sockets.InterestResultPolicyImpl;
import java.io.ObjectStreamException;
import java.io.Serializable;

/**
 * Class InterestResultPolicy is an enumerated type for a register interest result. The
 * result of a call to Region.registerInterest can be the keys and current values, just the keys or
 * nothing.
 *
 *
 * @see org.apache.geode.cache.Region#registerInterest(Object)
 * @see org.apache.geode.cache.Region#registerInterestRegex(String)
 *
 * @since GemFire 4.2.3
 */
public class InterestResultPolicy implements Serializable {
  private static final long serialVersionUID = -4993765891973030160L;

  private static byte nextOrdinal = 0;

  private static final InterestResultPolicy[] VALUES = new InterestResultPolicy[3];

  public static final InterestResultPolicy NONE = new InterestResultPolicyImpl("NONE");
  public static final InterestResultPolicy KEYS = new InterestResultPolicyImpl("KEYS");
  public static final InterestResultPolicy KEYS_VALUES =
      new InterestResultPolicyImpl("KEYS_VALUES");

  /**
   * The InterestResultPolicy used by default; it is {@link #KEYS_VALUES}.
   */
  public static final InterestResultPolicy DEFAULT = KEYS_VALUES;


  /** The name of this InterestResultPolicy. */
  private final transient String name;

  /** The ordinal representing this InterestResultPolicy. */
  public final byte ordinal;

  protected Object readResolve() throws ObjectStreamException {
    return VALUES[ordinal]; // Canonicalize
  }


  /** should only be called from InterestResultPolicyImpl */
  protected InterestResultPolicy(String name) {
    this.name = name;
    this.ordinal = nextOrdinal++;
    VALUES[this.ordinal] = this;
  }

  /** Returns the InterestResultPolicy represented by specified ordinal */
  public static InterestResultPolicy fromOrdinal(byte ordinal) {
    return VALUES[ordinal];
  }

  /**
   * Returns the ordinal value.
   * 
   * @since GemFire 5.0
   */
  public byte getOrdinal() {
    return this.ordinal;
  }

  /**
   * Returns true if this InterestResultPolicy is {@link #NONE}.
   * 
   * @return true if this InterestResultPolicy is {@link #NONE}.
   */
  public boolean isNone() {
    return this == NONE;
  }

  /**
   * Returns true if this InterestResultPolicy is {@link #KEYS}.
   * 
   * @return true if this InterestResultPolicy is {@link #KEYS}.
   */
  public boolean isKeys() {
    return this == KEYS;
  }

  /**
   * Returns true if this InterestResultPolicy is {@link #KEYS_VALUES}.
   * 
   * @return true if this InterestResultPolicy is {@link #KEYS_VALUES}.
   */
  public boolean isKeysValues() {
    return this == KEYS_VALUES;
  }

  /**
   * Returns true if this InterestResultPolicy is the default.
   * 
   * @return true if this InterestResultPolicy is the default.
   */
  public boolean isDefault() {
    return this == DEFAULT;
  }

  /**
   * Returns a string representation for this InterestResultPolicy.
   * 
   * @return the name of this data policy.
   */
  @Override // GemStoneAddition
  public String toString() {
    return this.name;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy