com.avaje.ebean.common
Class BeanMap<K,E>

java.lang.Object
  extended by com.avaje.ebean.common.AbstractBeanCollection<E>
      extended by com.avaje.ebean.common.BeanMap<K,E>
All Implemented Interfaces:
BeanCollection<E>, Serializable, Map<K,E>

public final class BeanMap<K,E>
extends AbstractBeanCollection<E>
implements Map<K,E>

Map capable of lazy loading.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
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
BeanMap()
          Create using a underlying LinkedHashMap.
BeanMap(BeanCollectionLoader ebeanServer, Object ownerBean, String propertyName)
           
BeanMap(Map<K,E> map)
          Create with a given Map.
 
Method Summary
 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 containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,E>> entrySet()
           
 boolean equals(Object obj)
          Equal if obj is a Map and equal in a Map sense.
 E get(Object key)
           
 Object getActualCollection()
          Returns the underlying map.
 Collection<E> getActualDetails()
          Returns the map entrySet iterator.
 Map<K,E> getActualMap()
          Return the actual underlying map.
 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()
          Return true if the underlying map has been populated.
 Set<K> keySet()
           
 E put(K key, E value)
           
 void putAll(Map<? extends K,? extends E> t)
           
 E remove(Object key)
           
 void setActualMap(Map<?,?> map)
          Set the actual underlying map.
 int size()
          Return the number of elements in the List Set or Map.
 String toString()
           
 Collection<E> values()
           
 
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

BeanMap

public BeanMap(Map<K,E> map)
Create with a given Map.


BeanMap

public BeanMap()
Create using a underlying LinkedHashMap.


BeanMap

public BeanMap(BeanCollectionLoader ebeanServer,
               Object ownerBean,
               String propertyName)
Method Detail

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()
Return true if the underlying map has been populated. Returns false if it has a deferred fetch pending.

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>

setActualMap

public void setActualMap(Map<?,?> map)
Set the actual underlying map. Used for performing lazy fetch.


getActualMap

public Map<K,E> getActualMap()
Return the actual underlying map.


getActualDetails

public Collection<E> getActualDetails()
Returns the map entrySet iterator.

This is because the key values may need to be set against the details (so they don't need to be set twice).

Specified by:
getActualDetails in interface BeanCollection<E>

getActualCollection

public Object getActualCollection()
Returns the underlying map.

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 Map and equal in a Map sense.

Specified by:
equals in interface Map<K,E>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Map<K,E>
Overrides:
hashCode in class Object

clear

public void clear()
Specified by:
clear in interface Map<K,E>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,E>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,E>

entrySet

public Set<Map.Entry<K,E>> entrySet()
Specified by:
entrySet in interface Map<K,E>

get

public E get(Object key)
Specified by:
get in interface Map<K,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 Map<K,E>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,E>

put

public E put(K key,
             E value)
Specified by:
put in interface Map<K,E>

putAll

public void putAll(Map<? extends K,? extends E> t)
Specified by:
putAll in interface Map<K,E>

remove

public E remove(Object key)
Specified by:
remove in interface Map<K,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 Map<K,E>

values

public Collection<E> values()
Specified by:
values in interface Map<K,E>


Copyright © 2010. All Rights Reserved.