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