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