001package io.ebean.event;
002
003import io.ebean.config.DatabaseConfig;
004
005/**
006 * A no operation implementation of BeanPersistController. Objects extending
007 * this need to only override the methods they want to.
008 * <p>
009 * A BeanPersistAdapter is either found automatically via class path search or
010 * can be added programmatically via
011 * {@link DatabaseConfig#add(BeanPersistController)} or
012 * {@link DatabaseConfig#setPersistControllers(java.util.List)}.
013 * </p>
014 */
015public abstract class BeanPersistAdapter implements BeanPersistController {
016
017  @Override
018  public abstract boolean isRegisterFor(Class<?> cls);
019
020  /**
021   * Returns 10 - override this to control the order in which
022   * BeanPersistController's are executed when there is multiple of them
023   * registered for a given entity type (class).
024   */
025  @Override
026  public int getExecutionOrder() {
027    return 10;
028  }
029
030  /**
031   * Returns true indicating normal processing should continue.
032   */
033  @Override
034  public boolean preDelete(BeanPersistRequest<?> request) {
035    return true;
036  }
037
038  /**
039   * Returns true indicating normal processing should continue.
040   */
041  @Override
042  public boolean preInsert(BeanPersistRequest<?> request) {
043    return true;
044  }
045
046  /**
047   * Returns true indicating normal processing should continue.
048   */
049  @Override
050  public boolean preUpdate(BeanPersistRequest<?> request) {
051    return true;
052  }
053
054  /**
055   * Returns true indicating normal processing should continue.
056   */
057  @Override
058  public boolean preSoftDelete(BeanPersistRequest<?> request) {
059    return true;
060  }
061
062  /**
063   * Does nothing by default.
064   */
065  @Override
066  public void postDelete(BeanPersistRequest<?> request) {
067  }
068
069  /**
070   * Does nothing by default.
071   */
072  @Override
073  public void postInsert(BeanPersistRequest<?> request) {
074  }
075
076  /**
077   * Does nothing by default.
078   */
079  @Override
080  public void postUpdate(BeanPersistRequest<?> request) {
081  }
082
083  /**
084   * Does nothing by default.
085   */
086  @Override
087  public void postSoftDelete(BeanPersistRequest<?> request) {
088  }
089
090  /**
091   * Does nothing by default.
092   */
093  @Override
094  public void preDelete(BeanDeleteIdRequest request) {
095
096  }
097}