Package io.ebean.common
Class BeanMap<K,E>
- java.lang.Object
-
- io.ebean.common.BeanMap<K,E>
-
- All Implemented Interfaces:
BeanCollection<E>,Serializable,Map<K,E>
public final class BeanMap<K,E> extends Object implements Map<K,E>
Map capable of lazy loading.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.ebean.bean.BeanCollection
BeanCollection.ModifyListenMode
-
-
Constructor Summary
Constructors Constructor Description BeanMap()Create using a underlying LinkedHashMap.BeanMap(BeanCollectionLoader ebeanServer, EntityBean ownerBean, String propertyName)BeanMap(Map<K,E> map)Create with a given Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBean(E bean)Add a bean to the list/set with modifyListen notification.booleancheckEmptyLazyLoad()Check after the lazy load that the underlying collection is not null (handle case where join to many not outer).voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,E>>entrySet()booleanequals(Object obj)Equal if obj is a Map and equal in a Map sense.Eget(Object key)Collection<E>getActualDetails()Returns the collection of beans (map values).Collection<?>getActualEntries()Returns the map entrySet.Map<K,E>getActualMap()Return the actual underlying map.ExpressionList<?>getFilterMany()Return the filter (if any) that was used in building this collection.Set<E>getModifyAdditions()Return the list of objects added to the list set or map.BeanCollection.ModifyListenModegetModifyListening()Return the current modify listening mode.BeanCollection.ModifyListenModegetModifyListenMode()Return the modify listening mode this collection is using.Set<E>getModifyRemovals()Return the list of objects removed from the list set or map.EntityBeangetOwnerBean()Return the bean that owns this collection.StringgetPropertyName()Return the bean property name this collection represents.BeanCollection<E>getShallowCopy()Return a shallow copy of this collection that is modifiable.inthashCode()booleanholdsModifications()Return true if there are underlying additions or removals.voidinternalAdd(Object bean)Add the bean to the collection.voidinternalAddWithCheck(Object bean)Add the bean with a check to see if it is already contained.voidinternalPut(Object key, Object bean)voidinternalPutNull()voidinternalPutWithCheck(Object key, Object bean)booleanisEmpty()Return true if the List Set or Map is empty.booleanisPopulated()Return true if the underlying map has been populated.booleanisReadOnly()Return true if the collection should be treated as readOnly and no elements can be added or removed etc.booleanisReference()Return true if this is a reference (lazy loading) bean collection.booleanisRegisteredWithLoadContext()Return true if the collection has been registered with the batch loading context.booleanisSkipSave()Return true if the collection is uninitialised or is empty without any held modifications.Set<K>keySet()voidloadFrom(BeanCollection<?> other)Load bean from another collection.voidmodifyAddition(E bean)Add an object to the additions list.voidmodifyRemoval(Object bean)Add an object to the deletions list.voidmodifyReset()Reset the set of additions and deletions.Eput(K key, E value)voidputAll(Map<? extends K,? extends E> puts)Eremove(Object key)voidremoveBean(E bean)Remove a bean to the list/set with modifyListen notification.voidreset(EntityBean ownerBean, String propertyName)Reset the collection back to an empty state ready for reloading.voidsetActualMap(Map<?,?> map)Set the actual underlying map.voidsetDisableLazyLoad(boolean disableLazyLoad)Set the disableLazyLoad state.voidsetFilterMany(ExpressionList<?> filterMany)Set the filter that was used in building this collection.voidsetLoader(BeanCollectionLoader loader)Set the loader that will be used to lazy/query load this collection.voidsetModifyListening(BeanCollection.ModifyListenMode mode)set modifyListening to be on or off.voidsetReadOnly(boolean readOnly)Set to true if you want the BeanCollection to be treated as read only.intsize()Return the number of elements in the List Set or Map.StringtoString()Collection<E>values()booleanwasTouched()Has been modified by an addition or removal.-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
BeanMap
public BeanMap()
Create using a underlying LinkedHashMap.
-
BeanMap
public BeanMap(BeanCollectionLoader ebeanServer, EntityBean ownerBean, String propertyName)
-
-
Method Detail
-
reset
public void reset(EntityBean ownerBean, String propertyName)
Description copied from interface:BeanCollectionReset the collection back to an empty state ready for reloading.This is done as part of bean refresh.
- Specified by:
resetin interfaceBeanCollection<K>
-
isSkipSave
public boolean isSkipSave()
Description copied from interface:BeanCollectionReturn 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:
isSkipSavein interfaceBeanCollection<K>
-
loadFrom
public void loadFrom(BeanCollection<?> other)
Description copied from interface:BeanCollectionLoad bean from another collection.- Specified by:
loadFromin interfaceBeanCollection<K>
-
internalPutNull
public void internalPutNull()
-
internalPut
public void internalPut(Object key, Object bean)
-
internalPutWithCheck
public void internalPutWithCheck(Object key, Object bean)
-
internalAddWithCheck
public void internalAddWithCheck(Object bean)
Description copied from interface:BeanCollectionAdd the bean with a check to see if it is already contained.- Specified by:
internalAddWithCheckin interfaceBeanCollection<K>
-
internalAdd
public void internalAdd(Object bean)
Description copied from interface:BeanCollectionAdd the bean to the collection.This is disallowed for BeanMap.
- Specified by:
internalAddin 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:
isPopulatedin 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:
isReferencein interfaceBeanCollection<K>
-
checkEmptyLazyLoad
public boolean checkEmptyLazyLoad()
Description copied from interface:BeanCollectionCheck 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:
checkEmptyLazyLoadin interfaceBeanCollection<K>
-
setActualMap
public void setActualMap(Map<?,?> map)
Set the actual underlying map. Used for performing lazy fetch.
-
getActualMap
public Map<K,E> getActualMap()
Return the actual underlying map.
-
getActualDetails
public Collection<E> getActualDetails()
Returns the collection of beans (map values).- Specified by:
getActualDetailsin interfaceBeanCollection<K>
-
getActualEntries
public Collection<?> getActualEntries()
Returns the map entrySet.This is because the key values may need to be set against the details (so they don't need to be set twice).
- Specified by:
getActualEntriesin interfaceBeanCollection<K>
-
hashCode
public int hashCode()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,E>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,E>
-
isEmpty
public boolean isEmpty()
Description copied from interface:BeanCollectionReturn true if the List Set or Map is empty.
-
addBean
public void addBean(E bean)
Description copied from interface:BeanCollectionAdd a bean to the list/set with modifyListen notification.- Specified by:
addBeanin interfaceBeanCollection<K>
-
removeBean
public void removeBean(E bean)
Description copied from interface:BeanCollectionRemove a bean to the list/set with modifyListen notification.- Specified by:
removeBeanin interfaceBeanCollection<K>
-
size
public int size()
Description copied from interface:BeanCollectionReturn the number of elements in the List Set or Map.
-
getShallowCopy
public BeanCollection<E> getShallowCopy()
Description copied from interface:BeanCollectionReturn a shallow copy of this collection that is modifiable.- Specified by:
getShallowCopyin interfaceBeanCollection<K>
-
getOwnerBean
public EntityBean getOwnerBean()
Description copied from interface:BeanCollectionReturn the bean that owns this collection.- Specified by:
getOwnerBeanin interfaceBeanCollection<E>
-
getPropertyName
public String getPropertyName()
Description copied from interface:BeanCollectionReturn the bean property name this collection represents.- Specified by:
getPropertyNamein interfaceBeanCollection<E>
-
getFilterMany
public ExpressionList<?> getFilterMany()
Description copied from interface:BeanCollectionReturn the filter (if any) that was used in building this collection.This is so that the filter can be applied on refresh.
- Specified by:
getFilterManyin interfaceBeanCollection<E>
-
setFilterMany
public void setFilterMany(ExpressionList<?> filterMany)
Description copied from interface:BeanCollectionSet the filter that was used in building this collection.- Specified by:
setFilterManyin interfaceBeanCollection<E>
-
setDisableLazyLoad
public void setDisableLazyLoad(boolean disableLazyLoad)
Description copied from interface:BeanCollectionSet the disableLazyLoad state.- Specified by:
setDisableLazyLoadin interfaceBeanCollection<E>
-
isRegisteredWithLoadContext
public boolean isRegisteredWithLoadContext()
Description copied from interface:BeanCollectionReturn true if the collection has been registered with the batch loading context.- Specified by:
isRegisteredWithLoadContextin interfaceBeanCollection<E>
-
setLoader
public void setLoader(BeanCollectionLoader loader)
Description copied from interface:BeanCollectionSet 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:
setLoaderin interfaceBeanCollection<E>
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:BeanCollectionReturn true if the collection should be treated as readOnly and no elements can be added or removed etc.- Specified by:
isReadOnlyin interfaceBeanCollection<E>
-
setReadOnly
public void setReadOnly(boolean readOnly)
Description copied from interface:BeanCollectionSet 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:
setReadOnlyin interfaceBeanCollection<E>
-
getModifyListening
public BeanCollection.ModifyListenMode getModifyListening()
Description copied from interface:BeanCollectionReturn the current modify listening mode. Can be null for on newly created beans.- Specified by:
getModifyListeningin interfaceBeanCollection<E>
-
setModifyListening
public void setModifyListening(BeanCollection.ModifyListenMode mode)
set modifyListening to be on or off.- Specified by:
setModifyListeningin interfaceBeanCollection<E>
-
getModifyListenMode
public BeanCollection.ModifyListenMode getModifyListenMode()
Return the modify listening mode this collection is using.
-
modifyAddition
public void modifyAddition(E bean)
Description copied from interface:BeanCollectionAdd an object to the additions list.This will potentially end up as an insert into a intersection table for a ManyToMany.
- Specified by:
modifyAdditionin interfaceBeanCollection<E>
-
modifyRemoval
public void modifyRemoval(Object bean)
Description copied from interface:BeanCollectionAdd an object to the deletions list.This will potentially end up as an delete from an intersection table for a ManyToMany.
- Specified by:
modifyRemovalin interfaceBeanCollection<E>
-
modifyReset
public void modifyReset()
Description copied from interface:BeanCollectionReset the set of additions and deletions. This is called after the additions and removals have been processed.- Specified by:
modifyResetin interfaceBeanCollection<E>
-
getModifyAdditions
public Set<E> getModifyAdditions()
Description copied from interface:BeanCollectionReturn 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:
getModifyAdditionsin interfaceBeanCollection<E>
-
getModifyRemovals
public Set<E> getModifyRemovals()
Description copied from interface:BeanCollectionReturn 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:
getModifyRemovalsin interfaceBeanCollection<E>
-
holdsModifications
public boolean holdsModifications()
Return true if there are underlying additions or removals.- Specified by:
holdsModificationsin interfaceBeanCollection<E>
-
wasTouched
public boolean wasTouched()
Description copied from interface:BeanCollectionHas been modified by an addition or removal.- Specified by:
wasTouchedin interfaceBeanCollection<E>
-
-