Class LazyLoadItemList<E>

All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, 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:
  • Field Details

    • PREFETCH_SIZE_PROPERTY

      public static final String PREFETCH_SIZE_PROPERTY
      See Also:
    • DEFAULT_PREFETCH_SIZE

      public static final int DEFAULT_PREFETCH_SIZE
      The value for DEFAULT_PREFETCH_SIZE is read from the configuration properties. The key is lazy.pkcollection.prefetchsize.
      See Also:
    • 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(since="ages", forRemoval=true) public static final int DEFUALT_PREFETCH_SIZE
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
      deprecated, use DEFAULT_PREFETCH_SIZE instead (without typo)
      See Also:
  • Constructor Details

    • LazyLoadItemList

      public LazyLoadItemList()
      This constructor usees as prefetch size DEFAULT_PREFETCH_SIZE.
    • LazyLoadItemList

      public LazyLoadItemList(Set<PK> prefetchLanguages, List<PK> pks, int prefetchSize)
      LazyLoadItemList Constructor.
      Parameters:
      prefetchLanguages -
      pks -
      prefetchSize - use postive values only or DEFAULT_PREFETCH_SIZE for reading the value from the configuration properties.
    • LazyLoadItemList

      protected LazyLoadItemList(Set<PK> prefetchLanguages, List<PK> pks, int prefetchSize, boolean modifable)
  • Method Details

    • get

      public E get(int index) throws IndexOutOfBoundsException
      Specified by:
      get in interface List<E>
      Specified by:
      get in class BaseLazyLoadItemList<E>
      Throws:
      IndexOutOfBoundsException
    • getBuffered

      protected E getBuffered(int listPos)
      Gets an object of type E for absolute global given listPos. Internally it checks if this index is accessible for the current page if not appropriate page is loaded.

      Method ensured by change of volatile currentBufferedPage to retrieve consistent result for given index in multi-threaded environment.

    • invalidateBuffer

      protected void invalidateBuffer()
      Invalidates a currentBufferedPage's .
    • switchPage

      protected LazyLoadItemList.BufferedPage<E> switchPage(int listPos)
      Not thread safe switch page method.
    • loadPage

      protected List<E> loadPage(List<PK> pks)
      Override this method to provide a resolving mechanism for generating values for the pre-fetched BaseLazyLoadItemList.pkList entries.
    • set

      public E set(int index, 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:
      set in interface List<E>
      Overrides:
      set in class BaseLazyLoadItemList<E>
    • add

      public void add(int index, Object element)
      Specified by:
      add in interface List<E>
      Overrides:
      add in class AbstractList<E>
    • 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:
      remove in interface List<E>
      Overrides:
      remove in class BaseLazyLoadItemList<E>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<E>
      Specified by:
      clear in interface List<E>
      Overrides:
      clear in class BaseLazyLoadItemList<E>
    • setPreFetchSize

      @Deprecated(since="4.8", forRemoval=true) public void setPreFetchSize(int preFetchSize)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 4.8 does not have a counter part - set a prefetch size in constructor
      If you wish to use the prefetch value from the configuration properties, prefer DEFAULT_PREFETCH_SIZE instead of -1. Other negative values are interpreted as -1. If you add a negative or invalid value to the configuration property key lazy.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(since="4.8", forRemoval=true) public boolean isIgnoreMissing()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 4.8
      Returns:
      the ignoreMissing
    • setIgnoreMissing

      @Deprecated(since="4.8", forRemoval=true) public void setIgnoreMissing(boolean ignoreMissing)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 4.8
      Parameters:
      ignoreMissing - the ignoreMissing to set
    • setModifiable

      @Deprecated(since="4.8", forRemoval=true) public void setModifiable(boolean modifiable)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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 a LazyLoadItemList.BufferedPage for the given totalIndex or creates a new LazyLoadItemList.BufferedPage if it is not in range of currentBufferedPage.
    • getBufferedPageIfLoaded

      protected LazyLoadItemList.BufferedPage<E> getBufferedPageIfLoaded(int totalIndex)
      Returns a LazyLoadItemList.BufferedPage for the given totalIndex or null if it is not in range of currentBufferedPage.
    • 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)