java.lang.Object
io.ebean.common.BeanMap<K,E>
- All Implemented Interfaces:
BeanCollection<E>
,ToStringAware
,Serializable
,Map<K,
E>
Map capable of lazy loading.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.ebean.bean.BeanCollection
BeanCollection.ModifyListenMode
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected String
protected ExpressionList<?>
protected BeanCollectionLoader
The Database this is associated with.protected final ReentrantLock
protected io.ebean.common.ModifyHolder<E>
protected boolean
protected BeanCollection.ModifyListenMode
protected EntityBean
The owning bean (used for lazy fetch).protected String
The name of this property in the owning bean (used for lazy fetch).protected boolean
protected boolean
Flag set when registered with the batch loading context. -
Constructor Summary
ConstructorDescriptionBeanMap()
Create using a underlying LinkedHashMap.BeanMap
(BeanCollectionLoader ebeanServer, EntityBean ownerBean, String propertyName) Create with a given Map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a bean to the list/set with modifyListen notification.boolean
Check after the lazy load that the underlying collection is not null (handle case where join to many not outer).void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
Equal if object is a Map and equal in a Map sense.Returns the collection of beans (map values).Collection<?>
Returns the map entrySet.Return the actual underlying map.Return the filter (if any) that was used in building this collection.Return the list of objects added to the list set or map.Return the current modify listening mode.Return the modify listening mode this collection is using.Return the list of objects removed from the list set or map.Return the bean that owns this collection.Return the bean property name this collection represents.Return a shallow copy of this collection that is modifiable.int
hashCode()
boolean
Return true if the collection is modify listening and has modifications.boolean
Return true if there are underlying additions or removals.void
internalAdd
(Object bean) Add the bean to the collection.void
internalAddWithCheck
(Object bean) Add the bean with a check to see if it is already contained.void
internalPut
(Object key, Object bean) void
void
internalPutWithCheck
(Object key, Object bean) boolean
isEmpty()
Return true if the List Set or Map is empty.boolean
Return true if the underlying map has been populated.boolean
Return true if the collection should be treated as readOnly and no elements can be added or removed etc.boolean
Return true if this is a reference (lazy loading) bean collection.boolean
Return true if the collection has been registered with the batch loading context.boolean
Return true if the collection is uninitialised or is empty without any held modifications.keySet()
void
loadFrom
(BeanCollection<?> other) Load bean from another collection.void
modifyAddition
(E bean) Add an object to the additions list.void
modifyRemoval
(Object bean) Add an object to the deletions list.void
Reset the set of additions and deletions.void
void
removeBean
(E bean) Remove a bean to the list/set with modifyListen notification.void
reset
(EntityBean ownerBean, String propertyName) Reset the collection back to an empty state ready for reloading.void
setActualMap
(Map<?, ?> map) Set the actual underlying map.void
setDisableLazyLoad
(boolean disableLazyLoad) Set the disableLazyLoad state.void
setFilterMany
(ExpressionList<?> filterMany) Set the filter that was used in building this collection.protected void
setFromOriginal
(io.ebean.common.AbstractBeanCollection<E> other) Copies all relevant properties for a clone.void
setLoader
(BeanCollectionLoader loader) Set the loader that will be used to lazy/query load this collection.void
set modifyListening to be on or off.void
setReadOnly
(boolean readOnly) Set to true if you want the BeanCollection to be treated as read only.int
size()
Return the number of elements in the List Set or Map.toString()
void
toString
(ToStringBuilder builder) Append to the ToStringBuilder.values()
boolean
Has been modified by an addition or removal.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
lock
-
readOnly
protected boolean readOnly -
disableLazyLoad
protected boolean disableLazyLoad -
loader
The Database this is associated with. (used for lazy fetch). -
filterMany
-
registeredWithLoadContext
protected boolean registeredWithLoadContextFlag set when registered with the batch loading context. -
ebeanServerName
-
ownerBean
The owning bean (used for lazy fetch). -
propertyName
The name of this property in the owning bean (used for lazy fetch). -
modifyHolder
-
modifyListenMode
-
modifyListening
protected boolean modifyListening
-
-
Constructor Details
-
BeanMap
Create with a given Map. -
BeanMap
public BeanMap()Create using a underlying LinkedHashMap. -
BeanMap
-
-
Method Details
-
toString
Description copied from interface:ToStringAware
Append to the ToStringBuilder.- Specified by:
toString
in interfaceToStringAware
-
reset
Description copied from interface:BeanCollection
Reset the collection back to an empty state ready for reloading.This is done as part of bean refresh.
- Specified by:
reset
in interfaceBeanCollection<K>
-
isSkipSave
public boolean isSkipSave()Description copied from interface:BeanCollection
Return true if the collection is uninitialised or is empty without any held modifications.Returning true means can safely skip cascade save for this bean collection.
- Specified by:
isSkipSave
in interfaceBeanCollection<K>
-
loadFrom
Description copied from interface:BeanCollection
Load bean from another collection.- Specified by:
loadFrom
in interfaceBeanCollection<K>
-
internalPutNull
public void internalPutNull() -
internalPut
-
internalPutWithCheck
-
internalAddWithCheck
Description copied from interface:BeanCollection
Add the bean with a check to see if it is already contained.- Specified by:
internalAddWithCheck
in interfaceBeanCollection<K>
-
internalAdd
Description copied from interface:BeanCollection
Add the bean to the collection. This is disallowed for BeanMap.- Specified by:
internalAdd
in interfaceBeanCollection<K>
-
isPopulated
public boolean isPopulated()Return true if the underlying map has been populated. Returns false if it has a deferred fetch pending.- Specified by:
isPopulated
in interfaceBeanCollection<K>
-
isReference
public boolean isReference()Return true if this is a reference (lazy loading) bean collection. This is the same as !isPopulated();- Specified by:
isReference
in interfaceBeanCollection<K>
-
checkEmptyLazyLoad
public boolean checkEmptyLazyLoad()Description copied from interface:BeanCollection
Check after the lazy load that the underlying collection is not null (handle case where join to many not outer).That is, if the collection was not loaded due to filterMany predicates etc then make sure the collection is set to empty.
- Specified by:
checkEmptyLazyLoad
in interfaceBeanCollection<K>
-
setActualMap
Set the actual underlying map. Used for performing lazy fetch. -
getActualMap
Return the actual underlying map. -
getActualDetails
Returns the collection of beans (map values).- Specified by:
getActualDetails
in interfaceBeanCollection<K>
-
getActualEntries
Returns the map entrySet.- Specified by:
getActualEntries
in interfaceBeanCollection<K>
-
toString
-
equals
Equal if object is a Map and equal in a Map sense. -
hashCode
public int hashCode() -
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
E>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
E>
-
entrySet
-
get
-
isEmpty
public boolean isEmpty()Description copied from interface:BeanCollection
Return true if the List Set or Map is empty. -
keySet
-
put
-
putAll
-
addBean
Description copied from interface:BeanCollection
Add a bean to the list/set with modifyListen notification.- Specified by:
addBean
in interfaceBeanCollection<K>
-
removeBean
Description copied from interface:BeanCollection
Remove a bean to the list/set with modifyListen notification.- Specified by:
removeBean
in interfaceBeanCollection<K>
-
remove
-
size
public int size()Description copied from interface:BeanCollection
Return the number of elements in the List Set or Map. -
values
-
getShallowCopy
Description copied from interface:BeanCollection
Return a shallow copy of this collection that is modifiable.- Specified by:
getShallowCopy
in interfaceBeanCollection<K>
-
getOwnerBean
Description copied from interface:BeanCollection
Return the bean that owns this collection.- Specified by:
getOwnerBean
in interfaceBeanCollection<E>
-
getPropertyName
Description copied from interface:BeanCollection
Return the bean property name this collection represents.- Specified by:
getPropertyName
in interfaceBeanCollection<E>
-
getFilterMany
Description copied from interface:BeanCollection
Return the filter (if any) that was used in building this collection.This is so that the filter can be applied on refresh.
- Specified by:
getFilterMany
in interfaceBeanCollection<E>
-
setFilterMany
Description copied from interface:BeanCollection
Set the filter that was used in building this collection.- Specified by:
setFilterMany
in interfaceBeanCollection<E>
-
setDisableLazyLoad
public void setDisableLazyLoad(boolean disableLazyLoad) Description copied from interface:BeanCollection
Set the disableLazyLoad state.- Specified by:
setDisableLazyLoad
in interfaceBeanCollection<E>
-
isRegisteredWithLoadContext
public boolean isRegisteredWithLoadContext()Description copied from interface:BeanCollection
Return true if the collection has been registered with the batch loading context.- Specified by:
isRegisteredWithLoadContext
in interfaceBeanCollection<E>
-
setLoader
Description copied from interface:BeanCollection
Set the loader that will be used to lazy/query load this collection.This is effectively the batch loading context this collection is registered with.
- Specified by:
setLoader
in interfaceBeanCollection<E>
-
isReadOnly
public boolean isReadOnly()Description copied from interface:BeanCollection
Return true if the collection should be treated as readOnly and no elements can be added or removed etc.- Specified by:
isReadOnly
in interfaceBeanCollection<E>
-
setReadOnly
public void setReadOnly(boolean readOnly) Description copied from interface:BeanCollection
Set to true if you want the BeanCollection to be treated as read only. This means no elements can be added or removed etc.- Specified by:
setReadOnly
in interfaceBeanCollection<E>
-
hasModifications
public boolean hasModifications()Description copied from interface:BeanCollection
Return true if the collection is modify listening and has modifications.- Specified by:
hasModifications
in interfaceBeanCollection<E>
-
getModifyListening
Description copied from interface:BeanCollection
Return the current modify listening mode. Can be null for on newly created beans.- Specified by:
getModifyListening
in interfaceBeanCollection<E>
-
setModifyListening
set modifyListening to be on or off.- Specified by:
setModifyListening
in interfaceBeanCollection<E>
-
getModifyListenMode
Return the modify listening mode this collection is using. -
modifyAddition
Description copied from interface:BeanCollection
Add an object to the additions list.This will potentially end up as an insert into a intersection table for a ManyToMany.
- Specified by:
modifyAddition
in interfaceBeanCollection<E>
-
modifyRemoval
Description copied from interface:BeanCollection
Add an object to the deletions list.This will potentially end up as an delete from an intersection table for a ManyToMany.
- Specified by:
modifyRemoval
in interfaceBeanCollection<E>
-
modifyReset
public void modifyReset()Description copied from interface:BeanCollection
Reset the set of additions and deletions. This is called after the additions and removals have been processed.- Specified by:
modifyReset
in interfaceBeanCollection<E>
-
getModifyAdditions
Description copied from interface:BeanCollection
Return the list of objects added to the list set or map. These will used to insert rows into the intersection table of a ManyToMany.- Specified by:
getModifyAdditions
in interfaceBeanCollection<E>
-
getModifyRemovals
Description copied from interface:BeanCollection
Return the list of objects removed from the list set or map. These will used to delete rows from the intersection table of a ManyToMany.- Specified by:
getModifyRemovals
in interfaceBeanCollection<E>
-
holdsModifications
public boolean holdsModifications()Return true if there are underlying additions or removals.- Specified by:
holdsModifications
in interfaceBeanCollection<E>
-
wasTouched
public boolean wasTouched()Description copied from interface:BeanCollection
Has been modified by an addition or removal.- Specified by:
wasTouched
in interfaceBeanCollection<E>
-
setFromOriginal
Copies all relevant properties for a clone. SeeBeanCollection.getShallowCopy()
-