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

com.cedarsoft.utils.DeletionProcessorsSupport Maven / Gradle / Ivy

The newest version!
package com.cedarsoft.utils;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Support for deletion processors.
 */
public class DeletionProcessorsSupport {
  @NotNull
  private final List> deletionProcessors = new ArrayList>();

  /**
   * Sets the deletion processors
   *
   * @param deletionProcessors the processors
   */
  public void setDeletionProcessors( @NotNull List> deletionProcessors ) {
    this.deletionProcessors.clear();
    this.deletionProcessors.addAll( deletionProcessors );
  }

  @NotNull
  public List> getDeletionProcessors() {
    return Collections.unmodifiableList( deletionProcessors );
  }

  public void addDeletionProcessor( @NotNull DeletionProcessor processor ) {
    this.deletionProcessors.add( processor );
  }

  public void removeDeletionProcessor( @NotNull DeletionProcessor processor ) {
    this.deletionProcessors.remove( processor );
  }

  /**
   * Notifes all registered processors that the given object will be deleted
   *
   * @param object the object that will be deleted
   */
  public void notifyWillBeDeleted( @NotNull T object ) {
    for ( DeletionProcessor processor : deletionProcessors ) {
      processor.willBeDeleted( object );
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy