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 * Flags set for dirty properties (used by ElasticSearch integration). 046 */ 047 boolean[] getDirtyProperties(); 048 049 /** 050 * Return true for an update request if at least one of dirty properties is contained 051 * in the given set of property names. 052 * <p> 053 * This method will produce less GC compared with getUpdatedProperties() and should 054 * be preferred if it satisfies the requirement. 055 * </p> 056 * <p> 057 * Note that this method is used by the default ChangeLogFilter mechanism for when 058 * the <code>@ChangeLog</code> updatesThatInclude attribute has been specified. 059 * </p> 060 * 061 * @param propertyNames a set of property names which we are checking to see if at least 062 * one of them is dirty. 063 */ 064 boolean hasDirtyProperty(Set<String> propertyNames); 065 066 /** 067 * Returns the bean being inserted updated or deleted. 068 */ 069 T getBean(); 070 071 /** 072 * Returns a map of the properties that have changed and their new and old values. 073 */ 074 Map<String, ValuePair> getUpdatedValues(); 075 076}