Class BeanList<E>
- java.lang.Object
-
- io.ebean.common.BeanList<E>
-
- All Implemented Interfaces:
BeanCollection<E>
,BeanCollectionAdd
,Serializable
,Iterable<E>
,Collection<E>
,List<E>
public final class BeanList<E> extends Object implements List<E>, BeanCollectionAdd
List 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 BeanList()
Uses an ArrayList as the underlying List implementation.BeanList(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName)
Used to create deferred fetch proxy.BeanList(List<E> list)
Specify the underlying List implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, E element)
boolean
add(E o)
boolean
addAll(int index, Collection<? extends E> c)
boolean
addAll(Collection<? extends E> c)
void
addBean(E bean)
Add a bean to the list/set with modifyListen notification.void
addEntityBean(EntityBean bean)
Add a loaded bean to the collection.boolean
checkEmptyLazyLoad()
Check after the lazy load that the underlying collection is not null (handle case where join to many not outer).void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
boolean
equals(Object obj)
Equal if obj is a List and equal in a list sense.E
get(int index)
Collection<E>
getActualDetails()
Returns the underlying collection of beans from the Set, Map or List.Collection<?>
getActualEntries()
Returns the underlying entries so for Maps this is a collection of Map.Entry.List<E>
getActualList()
Return the actual underlying list.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.ModifyListenMode
getModifyListening()
Return the current modify listening mode.BeanCollection.ModifyListenMode
getModifyListenMode()
Return the modify listening mode this collection is using.Set<E>
getModifyRemovals()
Return the list of objects removed from the list set or map.EntityBean
getOwnerBean()
Return the bean that owns this collection.String
getPropertyName()
Return the bean property name this collection represents.BeanCollection<E>
getShallowCopy()
Return a shallow copy of this collection that is modifiable.int
hashCode()
boolean
holdsModifications()
Return true if there are underlying additions or removals.int
indexOf(Object o)
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
isPopulated()
Return true if the underlying list is populated.boolean
isReadOnly()
Return true if the collection should be treated as readOnly and no elements can be added or removed etc.boolean
isReference()
Return true if this is a reference (lazy loading) bean collection.boolean
isRegisteredWithLoadContext()
Return true if the collection has been registered with the batch loading context.boolean
isSkipSave()
Return true if the collection is uninitialised or is empty without any held modifications.Iterator<E>
iterator()
int
lastIndexOf(Object o)
ListIterator<E>
listIterator()
ListIterator<E>
listIterator(int index)
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
modifyReset()
Reset the set of additions and deletions.E
remove(int index)
boolean
remove(Object o)
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<?> retainBeans)
E
set(int index, E element)
void
setActualList(List<?> list)
Set the actual underlying list.void
setDisableLazyLoad(boolean disableLazyLoad)
Set the disableLazyLoad state.void
setFilterMany(ExpressionList<?> filterMany)
Set the filter that was used in building this collection.void
setLoader(BeanCollectionLoader loader)
Set the loader that will be used to lazy/query load this collection.void
setModifyListening(BeanCollection.ModifyListenMode mode)
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.List<E>
subList(int fromIndex, int toIndex)
Object[]
toArray()
<T> T[]
toArray(T[] a)
String
toString()
boolean
wasTouched()
Has been modified by an addition or removal.-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
-
-
-
Constructor Detail
-
BeanList
public BeanList()
Uses an ArrayList as the underlying List implementation.
-
BeanList
public BeanList(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName)
Used to create deferred fetch proxy.
-
-
Method Detail
-
reset
public void reset(EntityBean ownerBean, String propertyName)
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
public void addEntityBean(EntityBean bean)
Description copied from interface:BeanCollectionAdd
Add a loaded bean to the collection.- Specified by:
addEntityBean
in interfaceBeanCollectionAdd
-
loadFrom
public void loadFrom(BeanCollection<?> other)
Description copied from interface:BeanCollection
Load bean from another collection.- Specified by:
loadFrom
in interfaceBeanCollection<E>
-
internalAdd
public void internalAdd(Object bean)
Description copied from interface:BeanCollection
Add the bean to the collection.This is disallowed for BeanMap.
- Specified by:
internalAdd
in interfaceBeanCollection<E>
-
internalAddWithCheck
public void internalAddWithCheck(Object bean)
Description copied from interface:BeanCollection
Add the bean with a check to see if it is already contained.- Specified by:
internalAddWithCheck
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>
-
setActualList
public void setActualList(List<?> list)
Set the actual underlying list.This is primarily for the deferred fetching function.
-
getActualList
public List<E> getActualList()
Return the actual underlying list.
-
getActualDetails
public Collection<E> 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
public Collection<?> 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>
-
isPopulated
public boolean isPopulated()
Return true if the underlying list is populated.- 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>
-
equals
public boolean equals(Object obj)
Equal if obj is a List and equal in a list sense.Specifically obj does not need to be a BeanList but any list. This does not use the FindMany, fetchedMaxRows or finishedFetch properties in the equals test.
-
hashCode
public int hashCode()
-
addBean
public void addBean(E bean)
Description copied from interface:BeanCollection
Add a bean to the list/set with modifyListen notification.- Specified by:
addBean
in interfaceBeanCollection<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
-
addAll
public boolean addAll(int index, Collection<? extends E> c)
-
clear
public void clear()
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<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 interfaceList<E>
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOf
in interfaceList<E>
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIterator
in interfaceList<E>
-
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIterator
in interfaceList<E>
-
removeBean
public void removeBean(E bean)
Description copied from interface:BeanCollection
Remove a bean to the list/set with modifyListen notification.- Specified by:
removeBean
in interfaceBeanCollection<E>
-
removeAll
public boolean removeAll(Collection<?> beans)
-
retainAll
public boolean retainAll(Collection<?> retainBeans)
-
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 interfaceList<E>
-
toArray
public <T> T[] toArray(T[] a)
-
getShallowCopy
public BeanCollection<E> getShallowCopy()
Description copied from interface:BeanCollection
Return a shallow copy of this collection that is modifiable.- Specified by:
getShallowCopy
in interfaceBeanCollection<E>
-
getOwnerBean
public EntityBean getOwnerBean()
Description copied from interface:BeanCollection
Return the bean that owns this collection.- Specified by:
getOwnerBean
in interfaceBeanCollection<E>
-
getPropertyName
public String getPropertyName()
Description copied from interface:BeanCollection
Return the bean property name this collection represents.- Specified by:
getPropertyName
in interfaceBeanCollection<E>
-
getFilterMany
public ExpressionList<?> 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
public void setFilterMany(ExpressionList<?> filterMany)
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
public void setLoader(BeanCollectionLoader loader)
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>
-
getModifyListening
public BeanCollection.ModifyListenMode 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
public void setModifyListening(BeanCollection.ModifyListenMode mode)
set modifyListening to be on or off.- Specified by:
setModifyListening
in 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: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
public void modifyRemoval(Object bean)
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
public Set<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
public Set<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>
-
-