java.lang.Object
io.ebean.common.BeanSet<E>
- All Implemented Interfaces:
BeanCollection<E>,BeanCollectionAdd,ToStringAware,Serializable,Iterable<E>,Collection<E>,Set<E>
Set capable of lazy loading.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.ebean.bean.BeanCollection
BeanCollection.ModifyListenMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Stringprotected ExpressionList<?>protected BeanCollectionLoaderThe Database this is associated with.protected final ReentrantLockprotected io.ebean.common.ModifyHolder<E>protected booleanprotected BeanCollection.ModifyListenModeprotected EntityBeanThe owning bean (used for lazy fetch).protected StringThe name of this property in the owning bean (used for lazy fetch).protected booleanprotected booleanFlag set when registered with the batch loading context. -
Constructor Summary
ConstructorsConstructorDescriptionBeanSet()Create using an underlying LinkedHashSet.BeanSet(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) Create with a specific Set implementation. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> addCollection) voidAdd a bean to the list/set with modifyListen notification.voidaddEntityBean(EntityBean bean) Add a loaded bean to the collection.booleanCheck after the lazy load that the underlying collection is not null (handle case where join to many not outer).voidclear()booleanbooleancontainsAll(Collection<?> c) booleanEqual if obj is a Set and equal in a Set sense.Returns the underlying collection of beans from the Set, Map or List.Collection<?>Returns the underlying entries so for Maps this is a collection of Map.Entry.Return the actual underlying set.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.inthashCode()booleanReturn true if the collection is modify listening and has modifications.booleanReturn 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.booleanisEmpty()Return true if the List Set or Map is empty.booleanReturns true if the underlying set has its data.booleanReturn true if the collection should be treated as readOnly and no elements can be added or removed etc.booleanReturn true if this is a reference (lazy loading) bean collection.booleanReturn true if the collection has been registered with the batch loading context.booleanReturn true if the collection is uninitialised or is empty without any held modifications.iterator()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.voidReset the set of additions and deletions.booleanbooleanremoveAll(Collection<?> beans) 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.booleanretainAll(Collection<?> beans) voidsetActualSet(Set<?> set) Set the underlying set (used for lazy fetch).voidsetDisableLazyLoad(boolean disableLazyLoad) Set the disableLazyLoad state.voidsetFilterMany(ExpressionList<?> filterMany) Set the filter that was used in building this collection.protected voidsetFromOriginal(io.ebean.common.AbstractBeanCollection<E> other) Copies all relevant properties for a clone.voidsetLoader(BeanCollectionLoader loader) Set the loader that will be used to lazy/query load this collection.voidset 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.Object[]toArray()<T> T[]toArray(T[] a) toString()voidtoString(ToStringBuilder builder) Append to the ToStringBuilder.booleanHas been modified by an addition or removal.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
spliterator
-
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
-
BeanSet
Create with a specific Set implementation. -
BeanSet
public BeanSet()Create using an underlying LinkedHashSet. -
BeanSet
-
-
Method Details
-
toString
Description copied from interface:ToStringAwareAppend to the ToStringBuilder.- Specified by:
toStringin interfaceToStringAware
-
reset
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<E>
-
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<E>
-
addEntityBean
Description copied from interface:BeanCollectionAddAdd a loaded bean to the collection.- Specified by:
addEntityBeanin interfaceBeanCollectionAdd
-
loadFrom
Description copied from interface:BeanCollectionLoad bean from another collection.- Specified by:
loadFromin interfaceBeanCollection<E>
-
internalAddWithCheck
Description copied from interface:BeanCollectionAdd the bean with a check to see if it is already contained.- Specified by:
internalAddWithCheckin interfaceBeanCollection<E>
-
internalAdd
Description copied from interface:BeanCollectionAdd the bean to the collection. This is disallowed for BeanMap.- Specified by:
internalAddin interfaceBeanCollection<E>
-
isPopulated
public boolean isPopulated()Returns true if the underlying set has its data.- Specified by:
isPopulatedin interfaceBeanCollection<E>
-
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<E>
-
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<E>
-
setActualSet
Set the underlying set (used for lazy fetch). -
getActualSet
Return the actual underlying set. -
getActualDetails
Description copied from interface:BeanCollectionReturns the underlying collection of beans from the Set, Map or List.- Specified by:
getActualDetailsin interfaceBeanCollection<E>
-
getActualEntries
Description copied from interface:BeanCollectionReturns the underlying entries so for Maps this is a collection of Map.Entry.For maps this returns the entrySet as we need the keys of the map.
- Specified by:
getActualEntriesin interfaceBeanCollection<E>
-
toString
-
equals
Equal if obj is a Set and equal in a Set sense. -
hashCode
public int hashCode() -
addBean
Description copied from interface:BeanCollectionAdd a bean to the list/set with modifyListen notification.- Specified by:
addBeanin interfaceBeanCollection<E>
-
removeBean
Description copied from interface:BeanCollectionRemove a bean to the list/set with modifyListen notification.- Specified by:
removeBeanin interfaceBeanCollection<E>
-
add
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>
-
isEmpty
public boolean isEmpty()Description copied from interface:BeanCollectionReturn true if the List Set or Map is empty.- Specified by:
isEmptyin interfaceBeanCollection<E>- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceSet<E>
-
iterator
-
remove
-
removeAll
-
retainAll
-
size
public int size()Description copied from interface:BeanCollectionReturn the number of elements in the List Set or Map.- Specified by:
sizein interfaceBeanCollection<E>- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
getShallowCopy
Description copied from interface:BeanCollectionReturn a shallow copy of this collection that is modifiable.- Specified by:
getShallowCopyin interfaceBeanCollection<E>
-
getOwnerBean
Description copied from interface:BeanCollectionReturn the bean that owns this collection.- Specified by:
getOwnerBeanin interfaceBeanCollection<E>
-
getPropertyName
Description copied from interface:BeanCollectionReturn the bean property name this collection represents.- Specified by:
getPropertyNamein interfaceBeanCollection<E>
-
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
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
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>
-
hasModifications
public boolean hasModifications()Description copied from interface:BeanCollectionReturn true if the collection is modify listening and has modifications.- Specified by:
hasModificationsin interfaceBeanCollection<E>
-
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
set modifyListening to be on or off.- Specified by:
setModifyListeningin interfaceBeanCollection<E>
-
getModifyListenMode
Return the modify listening mode this collection is using. -
modifyAddition
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
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
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
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>
-
setFromOriginal
Copies all relevant properties for a clone. SeeBeanCollection.getShallowCopy()
-