com.avaje.ebean.common
Class BeanList<E>

java.lang.Object
  extended by com.avaje.ebean.common.AbstractBeanCollection<E>
      extended by com.avaje.ebean.common.BeanList<E>
All Implemented Interfaces:
BeanCollection<E>, BeanCollectionAdd, Serializable, Iterable<E>, Collection<E>, List<E>

public final class BeanList<E>
extends AbstractBeanCollection<E>

    
implements List<E>, BeanCollectionAdd

    

List capable of lazy loading.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.avaje.ebean.bean.BeanCollection
BeanCollection.ModifyListenMode
 
Field Summary
 
Fields inherited from interface com.avaje.ebean.bean.BeanCollection
DEFAULT, READONLY, SHARED
 
Constructor Summary
BeanList()
          Uses an ArrayList as the underlying List implementation.
BeanList(BeanCollectionLoader loader, Object ownerBean, String propertyName)
          Used to create deferred fetch proxy.
BeanList(List<E> list)
          Specify the underlying List implementation.
 
Method Summary
 boolean add(E o)
           
 void add(int index, E element)
           
 boolean addAll(Collection<? extends E> c)
           
 boolean addAll(int index, Collection<? extends E> c)
           
 void addBean(Object 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)
           
 Object getActualCollection()
          Returns the underlying list.
 Collection<E> getActualDetails()
          Returns the underlying details as an iterator.
 List<E> getActualList()
          Return the actual underlying list.
 int hashCode()
           
 int indexOf(Object o)
           
 void internalAdd(Object bean)
          Add the bean to the collection.
 boolean isEmpty()
          Return true if the List Set or Map is empty.
 boolean isPopulated()
          Return true if the underlying list is populated.
 Iterator<E> iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator<E> listIterator()
           
 ListIterator<E> listIterator(int index)
           
 E remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 E set(int index, E element)
           
 void setActualList(List<?> list)
          Set the actual underlying list.
 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()
           
 
Methods inherited from class com.avaje.ebean.common.AbstractBeanCollection
backgroundFetchWait, backgroundFetchWait, getFilterMany, getLoaderIndex, getModifyAdditions, getModifyRemovals, getOwnerBean, getPropertyName, hasMoreRows, isFinishedFetch, isReadOnly, isSharedInstance, modifyAddition, modifyRemoval, modifyReset, setBackgroundFetch, setBeanCollectionTouched, setFilterMany, setFinishedFetch, setHasMoreRows, setLoader, setModifyListening, setReadOnly, setSharedInstance
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeanList

public BeanList(List<E> list)
Specify the underlying List implementation.


BeanList

public BeanList()
Uses an ArrayList as the underlying List implementation.


BeanList

public BeanList(BeanCollectionLoader loader,
                Object ownerBean,
                String propertyName)
Used to create deferred fetch proxy.

Method Detail

addBean

public void addBean(Object bean)
Description copied from interface: BeanCollectionAdd
Add a loaded bean to the collection.

Specified by:
addBean in interface BeanCollectionAdd

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 interface BeanCollection<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 interface BeanCollection<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 details as an iterator.

Note that for maps this returns the entrySet as we need the keys of the map.

Specified by:
getActualDetails in interface BeanCollection<E>

getActualCollection

public Object getActualCollection()
Returns the underlying list.

Specified by:
getActualCollection in interface BeanCollection<E>

isPopulated

public boolean isPopulated()
Return true if the underlying list is populated.

Specified by:
isPopulated in interface BeanCollection<E>

toString

public String toString()
Overrides:
toString in class Object

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.

Specified by:
equals in interface Collection<E>
Specified by:
equals in interface List<E>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<E>
Specified by:
hashCode in interface List<E>
Overrides:
hashCode in class Object

add

public void add(int index,
                E element)
Specified by:
add in interface List<E>

add

public boolean add(E o)
Specified by:
add in interface Collection<E>
Specified by:
add in interface List<E>

addAll

public boolean addAll(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface List<E>

addAll

public boolean addAll(int index,
                      Collection<? extends E> c)
Specified by:
addAll in interface List<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>
Specified by:
contains in interface List<E>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<E>
Specified by:
containsAll in interface List<E>

get

public E get(int index)
Specified by:
get in interface List<E>

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List<E>

isEmpty

public boolean isEmpty()
Description copied from interface: BeanCollection
Return true if the List Set or Map is empty.

Specified by:
isEmpty in interface BeanCollection<E>
Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface List<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface List<E>

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List<E>

listIterator

public ListIterator<E> listIterator()
Specified by:
listIterator in interface List<E>

listIterator

public ListIterator<E> listIterator(int index)
Specified by:
listIterator in interface List<E>

remove

public E remove(int index)
Specified by:
remove in interface List<E>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface List<E>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface List<E>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface List<E>

set

public E set(int index,
             E element)
Specified by:
set in interface List<E>

size

public int size()
Description copied from interface: BeanCollection
Return the number of elements in the List Set or Map.

Specified by:
size in interface BeanCollection<E>
Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>

subList

public List<E> subList(int fromIndex,
                       int toIndex)
Specified by:
subList in interface List<E>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>


Copyright © 2010. All Rights Reserved.