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

javax.cache.expiry.EternalExpiryPolicy Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package javax.cache.expiry;

import javax.cache.Cache;
import javax.cache.configuration.Factory;
import javax.cache.configuration.FactoryBuilder;
import java.io.Serializable;

import static javax.cache.expiry.Duration.ETERNAL;

/**
 * The eternal {@link ExpiryPolicy} specifies that Cache Entries
 * won't expire.  This however doesn't mean they won't be expired if an
 * underlying implementation needs to free-up resources where by it may
 * choose to expire entries that are not due to expire.
 *
 * @param  the type of cache keys
 * @param  the type of cache values
 */
public final class EternalExpiryPolicy implements ExpiryPolicy, Serializable {

  /**
   * The serialVersionUID required for {@link java.io.Serializable}.
   */
  public static final long serialVersionUID = 201305101603L;

  /**
   * Obtains a {@link javax.cache.configuration.Factory} for an Eternal {@link ExpiryPolicy}.
   *
   * @return a {@link javax.cache.configuration.Factory} for an Eternal {@link ExpiryPolicy}.
   */
  public static  Factory> factoryOf() {
    return new FactoryBuilder.SingletonFactory>(new EternalExpiryPolicy());
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public Duration getExpiryForCreatedEntry(Cache.Entry entry) {
    return ETERNAL;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public Duration getExpiryForAccessedEntry(Cache.Entry entry) {
    return null;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public Duration getExpiryForModifiedEntry(Cache.Entry entry) {
    return null;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public int hashCode() {
    return EternalExpiryPolicy.class.hashCode();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public boolean equals(Object other) {
    return other instanceof EternalExpiryPolicy;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy