001package io.ebean.event;
002
003import io.ebean.EbeanServer;
004import io.ebean.Transaction;
005import io.ebean.ValuePair;
006
007import java.util.Map;
008import java.util.Set;
009
010/**
011 * Holds the information available for a bean persist (insert, update or
012 * delete).
013 * <p>
014 * This is made available for the BeanPersistControllers.
015 * </p>
016 */
017public interface BeanPersistRequest<T> {
018
019  /**
020   * Return the server processing the request.
021   */
022  EbeanServer getEbeanServer();
023
024  /**
025   * Return the Transaction associated with this request.
026   */
027  Transaction getTransaction();
028
029  /**
030   * For an update or delete of a partially populated bean this is the set of
031   * loaded properties and otherwise returns null.
032   */
033  Set<String> getLoadedProperties();
034
035  /**
036   * For an update this is the set of properties that where updated.
037   * <p>
038   * Note that hasDirtyProperty() is a more efficient check than this method and
039   * should be preferred if it satisfies the requirement.
040   * </p>
041   */
042  Set<String> getUpdatedProperties();
043
044  /**
045   * Return true for an update request if at least one of dirty properties is contained
046   * in the given set of property names.
047   * <p>
048   * This method will produce less GC compared with getUpdatedProperties() and should
049   * be preferred if it satisfies the requirement.
050   * </p>
051   * <p>
052   * Note that this method is used by the default ChangeLogFilter mechanism for when
053   * the <code>@ChangeLog</code> updatesThatInclude attribute has been specified.
054   * </p>
055   *
056   * @param propertyNames a set of property names which we are checking to see if at least
057   *                      one of them is dirty.
058   */
059  boolean hasDirtyProperty(Set<String> propertyNames);
060
061  /**
062   * Returns the bean being inserted updated or deleted.
063   */
064  T getBean();
065
066  /**
067   * Returns a map of the properties that have changed and their new and old values.
068   */
069  Map<String, ValuePair> getUpdatedValues();
070
071}