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  default String[] _ebean_getPropertyNames() {
020    throw new NotEnhancedException();
021  }
022
023  /**
024   * Return the property name at the given position.
025   */
026  default String _ebean_getPropertyName(int pos) {
027    throw new NotEnhancedException();
028  }
029
030  /**
031   * Create and return a new entity bean instance.
032   */
033  default Object _ebean_newInstance() {
034    throw new NotEnhancedException();
035  }
036
037  /**
038   * Generated method that sets the loaded state on all the embedded beans on
039   * this entity bean by using EntityBeanIntercept.setEmbeddedLoaded(Object o);
040   */
041  default void _ebean_setEmbeddedLoaded() {
042    throw new NotEnhancedException();
043  }
044
045  /**
046   * Return true if any embedded beans are new or dirty.
047   */
048  default boolean _ebean_isEmbeddedNewOrDirty() {
049    throw new NotEnhancedException();
050  }
051
052  /**
053   * Return the intercept for this object.
054   */
055  default EntityBeanIntercept _ebean_getIntercept() {
056    throw new NotEnhancedException();
057  }
058
059  /**
060   * Similar to _ebean_getIntercept() except it checks to see if the intercept
061   * field is null and will create it if required.
062   * <p>
063   * This is really only required when transientInternalFields=true as an
064   * enhancement option. In this case the intercept field is transient and will
065   * be null after a bean has been deserialised.
066   * </p>
067   * <p>
068   * This transientInternalFields=true option was to support some serialization
069   * frameworks that can't take into account our ebean fields.
070   * </p>
071   */
072  default EntityBeanIntercept _ebean_intercept() {
073    throw new NotEnhancedException();
074  }
075
076  /**
077   * Set the value of a field of an entity bean of this type.
078   * <p>
079   * Note that using this method bypasses any interception that otherwise occurs
080   * on entity beans. That means lazy loading and oldValues creation.
081   * </p>
082   */
083  default void _ebean_setField(int fieldIndex, Object value) {
084    throw new NotEnhancedException();
085  }
086
087  /**
088   * Set the field value with interception.
089   */
090  default void _ebean_setFieldIntercept(int fieldIndex, Object value) {
091    throw new NotEnhancedException();
092  }
093
094  /**
095   * Return the value of a field from an entity bean of this type.
096   * <p>
097   * Note that using this method bypasses any interception that otherwise occurs
098   * on entity beans. That means lazy loading.
099   * </p>
100   */
101  default Object _ebean_getField(int fieldIndex) {
102    throw new NotEnhancedException();
103  }
104
105  /**
106   * Return the field value with interception.
107   */
108  default Object _ebean_getFieldIntercept(int fieldIndex) {
109    throw new NotEnhancedException();
110  }
111
112}