001package com.avaje.ebean.bean;
002
003import java.beans.PropertyChangeListener;
004import java.io.Serializable;
005
006/**
007 * Bean that is aware of EntityBeanIntercept.
008 * <p>
009 * This interface and implementation of these methods is added to Entity Beans
010 * via instrumentation. These methods have a funny _ebean_ prefix to avoid any
011 * clash with normal methods these beans would have. These methods are not for
012 * general application consumption.
013 * </p>
014 */
015public interface EntityBean extends Serializable {
016
017  String[] _ebean_getPropertyNames();
018  
019  String _ebean_getPropertyName(int pos);
020  
021  /**
022   * Return the enhancement marker value.
023   * <p>
024   * This is the class name of the enhanced class and used to check that all
025   * entity classes are enhanced (specifically not just a super class).
026   * </p>
027   */
028  String _ebean_getMarker();
029
030  /**
031   * Create and return a new entity bean instance.
032   */
033  Object _ebean_newInstance();
034
035  /**
036   * Add a PropertyChangeListener to this bean.
037   */
038  void addPropertyChangeListener(PropertyChangeListener listener);
039
040  /**
041   * Remove a PropertyChangeListener from this bean.
042   */
043  void removePropertyChangeListener(PropertyChangeListener listener);
044
045  /**
046   * Generated method that sets the loaded state on all the embedded beans on
047   * this entity bean by using EntityBeanIntercept.setEmbeddedLoaded(Object o);
048   */
049  void _ebean_setEmbeddedLoaded();
050
051  /**
052   * Return true if any embedded beans are new or dirty.
053   */
054  boolean _ebean_isEmbeddedNewOrDirty();
055
056  /**
057   * Return the intercept for this object.
058   */
059  EntityBeanIntercept _ebean_getIntercept();
060
061  /**
062   * Similar to _ebean_getIntercept() except it checks to see if the intercept
063   * field is null and will create it if required.
064   * <p>
065   * This is really only required when transientInternalFields=true as an
066   * enhancement option. In this case the intercept field is transient and will
067   * be null after a bean has been deserialised.
068   * </p>
069   * <p>
070   * This transientInternalFields=true option was to support some serialization
071   * frameworks that can't take into account our ebean fields.
072   * </p>
073   */
074  EntityBeanIntercept _ebean_intercept();
075
076  /**
077   * Create a copy of this entity bean.
078   * <p>
079   * This occurs when a bean is changed. The copy represents the bean as it was
080   * initially (oldValues) before any changes where made. This is used for
081   * optimistic concurrency control.
082   * </p>
083   */
084  Object _ebean_createCopy();
085
086  /**
087   * Set the value of a field of an entity bean of this type.
088   * <p>
089   * Note that using this method bypasses any interception that otherwise occurs
090   * on entity beans. That means lazy loading and oldValues creation.
091   * </p>
092   */
093  void _ebean_setField(int fieldIndex, Object value);
094
095  /**
096   * Set the field value with interception.
097   */
098  void _ebean_setFieldIntercept(int fieldIndex, Object value);
099
100  /**
101   * Return the value of a field from an entity bean of this type.
102   * <p>
103   * Note that using this method bypasses any interception that otherwise occurs
104   * on entity beans. That means lazy loading.
105   * </p>
106   */
107  Object _ebean_getField(int fieldIndex);
108
109  /**
110   * Return the field value with interception.
111   */
112  Object _ebean_getFieldIntercept(int fieldIndex);
113
114}