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

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

public final class BeanSet<E>
extends AbstractBeanCollection<E>
implements Set<E>, BeanCollectionAdd

Set 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
BeanSet()
          Create using an underlying LinkedHashSet.
BeanSet(BeanCollectionLoader loader, Object ownerBean, String propertyName)
           
BeanSet(Set<E> set)
          Create with a specific Set implementation.
 
Method Summary
 boolean add(E o)
           
 boolean addAll(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 Set and equal in a Set sense.
 Object getActualCollection()
          Returns the underlying set.
 Collection<E> getActualDetails()
          Returns the underlying details as an iterator.
 Set<E> getActualSet()
          Return the actual underlying set.
 int hashCode()
           
 void internalAdd(Object bean)
          Add the bean to the collection.
 boolean isEmpty()
          Return true if the List Set or Map is empty.
 boolean isPopulated()
          Returns true if the underlying set has its data.
 Iterator<E> iterator()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 void setActualSet(Set<?> set)
          Set the underlying set (used for lazy fetch).
 int size()
          Return the number of elements in the List Set or Map.
 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

BeanSet

public BeanSet(Set<E> set)
Create with a specific Set implementation.


BeanSet

public BeanSet()
Create using an underlying LinkedHashSet.


BeanSet

public BeanSet(BeanCollectionLoader loader,
               Object ownerBean,
               String propertyName)
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>

isPopulated

public boolean isPopulated()
Returns true if the underlying set has its data.

Specified by:
isPopulated 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>

setActualSet

public void setActualSet(Set<?> set)
Set the underlying set (used for lazy fetch).


getActualSet

public Set<E> getActualSet()
Return the actual underlying set.


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 set.

Specified by:
getActualCollection in interface BeanCollection<E>

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Equal if obj is a Set and equal in a Set sense.

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

hashCode

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

add

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

addAll

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

clear

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

contains

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

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<E>
Specified by:
containsAll in interface Set<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 Set<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 Set<E>

remove

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

removeAll

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

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface Set<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 Set<E>

toArray

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

toArray

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


Copyright © 2010. All Rights Reserved.