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

io.ebeaninternal.server.cache.CacheChangeBeanRemove Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.cache;

import io.ebeaninternal.server.deploy.BeanDescriptor;

import java.util.ArrayList;
import java.util.Collection;

/**
 * Change to remove bean from L2 cache.
 */
final class CacheChangeBeanRemove implements CacheChange {

  private final BeanDescriptor descriptor;
  private final Collection ids;

  CacheChangeBeanRemove(Object id, BeanDescriptor descriptor) {
    this.descriptor = descriptor;
    this.ids = new ArrayList<>();
    ids.add(id);
  }

  CacheChangeBeanRemove(BeanDescriptor descriptor, Collection ids) {
    this.descriptor = descriptor;
    this.ids = ids;
  }

  @Override
  public void apply() {
    descriptor.cacheApplyInvalidate(ids);
  }

  /**
   * Add more id values.
   */
  public void addIds(Collection moreIds) {
    ids.addAll(moreIds);
  }

  /**
   * Add another id value.
   */
  public void addId(Object id) {
    ids.add(id);
  }
}