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
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
ConstructorDescriptionBeanSet()
Create using an underlying LinkedHashSet.BeanSet
(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) Create with a specific Set implementation. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> addCollection) void
Add a bean to the list/set with modifyListen notification.void
addEntityBean
(EntityBean bean) Add a loaded bean to the collection.boolean
Check after the lazy load that the underlying collection is not null (handle case where join to many not outer).void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
Equal 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.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.boolean
isEmpty()
Return true if the List Set or Map is empty.boolean
Returns true if the underlying set has its data.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.iterator()
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.boolean
boolean
removeAll
(Collection<?> beans) 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.boolean
retainAll
(Collection<?> beans) void
setActualSet
(Set<?> set) Set the underlying set (used for lazy fetch).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.Object[]
toArray()
<T> T[]
toArray
(T[] a) toString()
void
toString
(ToStringBuilder builder) Append to the ToStringBuilder.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.Collection
parallelStream, removeIf, stream, toArray
Methods 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: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<E>
-
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<E>
-
addEntityBean
Description copied from interface:BeanCollectionAdd
Add a loaded bean to the collection.- Specified by:
addEntityBean
in interfaceBeanCollectionAdd
-
loadFrom
Description copied from interface:BeanCollection
Load bean from another collection.- Specified by:
loadFrom
in interfaceBeanCollection<E>
-
internalAddWithCheck
Description copied from interface:BeanCollection
Add the bean with a check to see if it is already contained.- Specified by:
internalAddWithCheck
in interfaceBeanCollection<E>
-
internalAdd
Description copied from interface:BeanCollection
Add the bean to the collection. This is disallowed for BeanMap.- Specified by:
internalAdd
in interfaceBeanCollection<E>
-
isPopulated
public boolean isPopulated()Returns true if the underlying set has its data.- Specified by:
isPopulated
in 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:
isReference
in interfaceBeanCollection<E>
-
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<E>
-
setActualSet
Set the underlying set (used for lazy fetch). -
getActualSet
Return the actual underlying set. -
getActualDetails
Description copied from interface:BeanCollection
Returns the underlying collection of beans from the Set, Map or List.- Specified by:
getActualDetails
in interfaceBeanCollection<E>
-
getActualEntries
Description copied from interface:BeanCollection
Returns 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:
getActualEntries
in 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:BeanCollection
Add a bean to the list/set with modifyListen notification.- Specified by:
addBean
in interfaceBeanCollection<E>
-
removeBean
Description copied from interface:BeanCollection
Remove a bean to the list/set with modifyListen notification.- Specified by:
removeBean
in interfaceBeanCollection<E>
-
add
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
isEmpty
public boolean isEmpty()Description copied from interface:BeanCollection
Return true if the List Set or Map is empty.- Specified by:
isEmpty
in interfaceBeanCollection<E>
- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
-
iterator
-
remove
-
removeAll
-
retainAll
-
size
public int size()Description copied from interface:BeanCollection
Return the number of elements in the List Set or Map.- Specified by:
size
in interfaceBeanCollection<E>
- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
getShallowCopy
Description copied from interface:BeanCollection
Return a shallow copy of this collection that is modifiable.- Specified by:
getShallowCopy
in interfaceBeanCollection<E>
-
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()
-