Package de.hybris.platform.core
Class LazyLoadItemList<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- de.hybris.platform.core.internal.BaseLazyLoadItemList<E>
-
- de.hybris.platform.core.LazyLoadItemList<E>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<E>,java.util.Collection<E>,java.util.List<E>
- Direct Known Subclasses:
AbstractLazyLoadValueList,LazyLoadItemListInternalTest.TestPKLazyLoadItemList,LazyLoadModelList,MonitoredLazyLoadItemList
public class LazyLoadItemList<E> extends BaseLazyLoadItemList<E>
Class to store PKs instead of Items. These items are lazy loaded when the list elements are read.List is thread safe for accessing it elements via
get(int).- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classLazyLoadItemList.BufferedPage<T>Thread safe (hopefully) abstraction for paged result objects list with information at which index this page starts.
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PREFETCH_SIZEThe value forDEFAULT_PREFETCH_SIZEis read from the configuration properties.static intDEFUALT_PREFETCH_SIZEDeprecated.since agesstatic LazyLoadItemListEMPTY_LISTStatic, light-weight empty list instance.static java.lang.StringPREFETCH_SIZE_PROPERTY-
Fields inherited from class de.hybris.platform.core.internal.BaseLazyLoadItemList
DEFAULT_CONFIG_PREFETCH_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description LazyLoadItemList()This constructor usees as prefetch sizeDEFAULT_PREFETCH_SIZE.LazyLoadItemList(java.util.Set<PK> prefetchLanguages, java.util.List<PK> pks, int prefetchSize)LazyLoadItemList Constructor.protectedLazyLoadItemList(java.util.Set<PK> prefetchLanguages, java.util.List<PK> pks, int prefetchSize, boolean modifable)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(int index, java.lang.Object element)voidclear()Eget(int index)protected EgetBuffered(int listPos)Gets an object of type E for absolute global givenlistPos.protected LazyLoadItemList.BufferedPage<E>getBufferedPageIfLoaded(int totalIndex)Returns aLazyLoadItemList.BufferedPagefor the giventotalIndexor null if it is not in range ofcurrentBufferedPage.protected LazyLoadItemList.BufferedPage<E>getCurrentBufferedPage()protected LazyLoadItemList.BufferedPage<E>getOrSwitchBufferedPage(int totalIndex)Returns aLazyLoadItemList.BufferedPagefor the giventotalIndexor creates a newLazyLoadItemList.BufferedPageif it is not in range ofcurrentBufferedPage.protected voidinvalidateBuffer()Invalidates acurrentBufferedPage's .booleanisIgnoreMissing()Deprecated.since 4.8protected java.util.List<E>loadPage(java.util.List<PK> pks)Override this method to provide a resolving mechanism for generating values for the pre-fetchedBaseLazyLoadItemList.pkListentries.Eremove(int index)Does not completely fulfill the remove() contract.Eset(int index, java.lang.Object element)Does not completely fulfill the set() contract.voidsetIgnoreMissing(boolean ignoreMissing)Deprecated.since 4.8voidsetModifiable(boolean modifiable)Deprecated.since 4.8 set modifiable during creation - by default is truevoidsetPreFetchSize(int preFetchSize)Deprecated.since 4.8 does not have a counter part - set a prefetch size in constructorprotected LazyLoadItemList.BufferedPage<E>switchBufferedPage(int totalIndex)protected LazyLoadItemList.BufferedPage<E>switchBufferedPageNoLock(int totalIndex)protected LazyLoadItemList.BufferedPage<E>switchBufferedPageSynchronized(int totalIndex)protected LazyLoadItemList.BufferedPage<E>switchPage(int listPos)Not thread safe switch page method.-
Methods inherited from class de.hybris.platform.core.internal.BaseLazyLoadItemList
assureIndex, contains, equals, getConfig, getPK, getPKList, getPKListInternal, getPrefetchLanguages, getPreFetchSize, hashCode, isModifiable, iterator, size, toString
-
Methods inherited from class java.util.AbstractList
add, addAll, indexOf, lastIndexOf, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
-
-
-
-
Field Detail
-
PREFETCH_SIZE_PROPERTY
public static final java.lang.String PREFETCH_SIZE_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_PREFETCH_SIZE
public static final int DEFAULT_PREFETCH_SIZE
The value forDEFAULT_PREFETCH_SIZEis read from the configuration properties. The key islazy.pkcollection.prefetchsize.- See Also:
- Constant Field Values
-
EMPTY_LIST
public static final LazyLoadItemList EMPTY_LIST
Static, light-weight empty list instance. Should be used where an empty list stub is needed.
-
DEFUALT_PREFETCH_SIZE
@Deprecated public static final int DEFUALT_PREFETCH_SIZE
Deprecated.since agesdeprecated, use DEFAULT_PREFETCH_SIZE instead (without typo)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LazyLoadItemList
public LazyLoadItemList()
This constructor usees as prefetch sizeDEFAULT_PREFETCH_SIZE.
-
LazyLoadItemList
public LazyLoadItemList(java.util.Set<PK> prefetchLanguages, java.util.List<PK> pks, int prefetchSize)
LazyLoadItemList Constructor.- Parameters:
prefetchLanguages-pks-prefetchSize- use postive values only orDEFAULT_PREFETCH_SIZEfor reading the value from the configuration properties.
-
-
Method Detail
-
get
public E get(int index) throws java.lang.IndexOutOfBoundsException
- Specified by:
getin interfacejava.util.List<E>- Specified by:
getin classBaseLazyLoadItemList<E>- Throws:
java.lang.IndexOutOfBoundsException
-
getBuffered
protected E getBuffered(int listPos)
Gets an object of type E for absolute global givenlistPos. Internally it checks if this index is accessible for the current page if not appropriate page is loaded.Method ensured by change of volatile
currentBufferedPageto retrieve consistent result for given index in multi-threaded environment.
-
invalidateBuffer
protected void invalidateBuffer()
Invalidates acurrentBufferedPage's .
-
switchPage
protected LazyLoadItemList.BufferedPage<E> switchPage(int listPos)
Not thread safe switch page method.
-
loadPage
protected java.util.List<E> loadPage(java.util.List<PK> pks)
Override this method to provide a resolving mechanism for generating values for the pre-fetchedBaseLazyLoadItemList.pkListentries.
-
set
public E set(int index, java.lang.Object element)
Does not completely fulfill the set() contract. To make sure this method does not instantiate the item at the given index, always null is returned.- Specified by:
setin interfacejava.util.List<E>- Overrides:
setin classBaseLazyLoadItemList<E>
-
add
public void add(int index, java.lang.Object element)
-
remove
public E remove(int index)
Does not completely fulfill the remove() contract. To make sure this method does not instantiate the item at the given index, always null is returned.- Specified by:
removein interfacejava.util.List<E>- Overrides:
removein classBaseLazyLoadItemList<E>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<E>- Specified by:
clearin interfacejava.util.List<E>- Overrides:
clearin classBaseLazyLoadItemList<E>
-
setPreFetchSize
@Deprecated public void setPreFetchSize(int preFetchSize)
Deprecated.since 4.8 does not have a counter part - set a prefetch size in constructorIf you wish to use the prefetch value from the configuration properties, preferDEFAULT_PREFETCH_SIZEinstead of -1. Other negative values are interpreted as -1. If you add a negative or invalid value to the configuration property keylazy.pkcollection.prefetchsize, the prefetch size is set to 100. If you do not wish to use the value from the configuration properties, use positive values only.- Parameters:
preFetchSize- the size of the prefetched elements for the list. Has to be a positive value.
-
isIgnoreMissing
@Deprecated public boolean isIgnoreMissing()
Deprecated.since 4.8- Returns:
- the ignoreMissing
-
setIgnoreMissing
@Deprecated public void setIgnoreMissing(boolean ignoreMissing)
Deprecated.since 4.8- Parameters:
ignoreMissing- the ignoreMissing to set
-
setModifiable
@Deprecated public void setModifiable(boolean modifiable)
Deprecated.since 4.8 set modifiable during creation - by default is true- Parameters:
modifiable- the modifiable to set
-
getCurrentBufferedPage
protected LazyLoadItemList.BufferedPage<E> getCurrentBufferedPage()
-
getOrSwitchBufferedPage
protected LazyLoadItemList.BufferedPage<E> getOrSwitchBufferedPage(int totalIndex)
Returns aLazyLoadItemList.BufferedPagefor the giventotalIndexor creates a newLazyLoadItemList.BufferedPageif it is not in range ofcurrentBufferedPage.
-
getBufferedPageIfLoaded
protected LazyLoadItemList.BufferedPage<E> getBufferedPageIfLoaded(int totalIndex)
Returns aLazyLoadItemList.BufferedPagefor the giventotalIndexor null if it is not in range ofcurrentBufferedPage.
-
switchBufferedPage
protected LazyLoadItemList.BufferedPage<E> switchBufferedPage(int totalIndex)
-
switchBufferedPageSynchronized
protected final LazyLoadItemList.BufferedPage<E> switchBufferedPageSynchronized(int totalIndex)
-
switchBufferedPageNoLock
protected final LazyLoadItemList.BufferedPage<E> switchBufferedPageNoLock(int totalIndex)
-
-