Package io.ebeaninternal.server.core
Class DefaultBeanState
- java.lang.Object
-
- io.ebeaninternal.server.core.DefaultBeanState
-
- All Implemented Interfaces:
BeanState
public class DefaultBeanState extends Object implements BeanState
Default implementation of BeanState.
-
-
Constructor Summary
Constructors Constructor Description DefaultBeanState(EntityBean entityBean)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>
getChangedProps()
Return the set of changed properties.Map<String,ValuePair>
getDirtyValues()
Return a map of the updated properties and their new and old values.Set<String>
getLoadedProps()
For partially populated beans returns the properties that are loaded on the bean.Map<String,Exception>
getLoadErrors()
Returns a map with load erros.boolean
isDirty()
Return true if the bean has been changed but not yet saved.boolean
isDisableLazyLoad()
Return true if the bean has lazy loading disabled.boolean
isNew()
Return true if the bean is new (and not yet saved).boolean
isNewOrDirty()
Return true if the bean is new or dirty (and probably needs to be saved).boolean
isReadOnly()
Return true if the bean is readOnly.boolean
isReference()
Return true if this is a lazy loading reference bean.void
resetForInsert()
Reset the bean putting it into NEW state such that a save() results in an insert.void
setDisableLazyLoad(boolean disableLazyLoading)
This can be called with true to disable lazy loading on the bean.void
setLoaded()
Advanced - Used to programmatically build a partially or fully loaded entity bean.void
setPropertyLoaded(String propertyName, boolean loaded)
Set the loaded state of the property given it's name.void
setReadOnly(boolean readOnly)
Set the readOnly status for the bean.
-
-
-
Constructor Detail
-
DefaultBeanState
public DefaultBeanState(EntityBean entityBean)
-
-
Method Detail
-
setPropertyLoaded
public void setPropertyLoaded(String propertyName, boolean loaded)
Description copied from interface:BeanState
Set the loaded state of the property given it's name.Typically this would be used to set the loaded state of a property to false to ensure that the specific property is excluded from a stateless update.
// populate a bean via say JSON User user = ...; // set loaded state on the email property to false so that // the email property is not included in a stateless update DB.getBeanState(user).setPropertyLoaded("email", false); user.update();
This will throw an IllegalArgumentException if the property is unknown.
- Specified by:
setPropertyLoaded
in interfaceBeanState
-
isReference
public boolean isReference()
Description copied from interface:BeanState
Return true if this is a lazy loading reference bean.If so the this bean only holds the Id property and will invoke lazy loading if any other property is get or set.
- Specified by:
isReference
in interfaceBeanState
-
isNew
public boolean isNew()
Description copied from interface:BeanState
Return true if the bean is new (and not yet saved).
-
isNewOrDirty
public boolean isNewOrDirty()
Description copied from interface:BeanState
Return true if the bean is new or dirty (and probably needs to be saved).- Specified by:
isNewOrDirty
in interfaceBeanState
-
isDirty
public boolean isDirty()
Description copied from interface:BeanState
Return true if the bean has been changed but not yet saved.
-
getLoadedProps
public Set<String> getLoadedProps()
Description copied from interface:BeanState
For partially populated beans returns the properties that are loaded on the bean.Accessing another property will cause lazy loading to occur.
- Specified by:
getLoadedProps
in interfaceBeanState
-
getChangedProps
public Set<String> getChangedProps()
Description copied from interface:BeanState
Return the set of changed properties.- Specified by:
getChangedProps
in interfaceBeanState
-
getDirtyValues
public Map<String,ValuePair> getDirtyValues()
Description copied from interface:BeanState
Return a map of the updated properties and their new and old values.- Specified by:
getDirtyValues
in interfaceBeanState
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:BeanState
Return true if the bean is readOnly.If a setter is called on a readOnly bean it will throw an exception.
- Specified by:
isReadOnly
in interfaceBeanState
-
setReadOnly
public void setReadOnly(boolean readOnly)
Description copied from interface:BeanState
Set the readOnly status for the bean.- Specified by:
setReadOnly
in interfaceBeanState
-
setLoaded
public void setLoaded()
Description copied from interface:BeanState
Advanced - Used to programmatically build a partially or fully loaded entity bean. First create an entity bean viaDatabase.createEntityBean(Class)
, then populate its properties and then call this method specifying which properties where loaded or null for a fully loaded entity bean.
-
setDisableLazyLoad
public void setDisableLazyLoad(boolean disableLazyLoading)
Description copied from interface:BeanState
This can be called with true to disable lazy loading on the bean.- Specified by:
setDisableLazyLoad
in interfaceBeanState
-
isDisableLazyLoad
public boolean isDisableLazyLoad()
Description copied from interface:BeanState
Return true if the bean has lazy loading disabled.- Specified by:
isDisableLazyLoad
in interfaceBeanState
-
resetForInsert
public void resetForInsert()
Description copied from interface:BeanState
Reset the bean putting it into NEW state such that a save() results in an insert.- Specified by:
resetForInsert
in interfaceBeanState
-
getLoadErrors
public Map<String,Exception> getLoadErrors()
Description copied from interface:BeanState
Returns a map with load erros.- Specified by:
getLoadErrors
in interfaceBeanState
-
-