Class IndexPropertyList

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList
org.apache.cayenne.util.IndexPropertyList
All Implemented Interfaces:
Serializable, Iterable, Collection, List, ValueHolder

public class IndexPropertyList
extends AbstractList
implements ValueHolder
A List implementation that would maintain its internal ordering based on some object numeric "index" property. When objects are added to the list at a certain index, an "index" property is modified to reflect list order, when objects are removed, their index property is set to the negative number.

For performance reasons this implementation does not guarantee that there is no gaps in the integer ordering sequence (i.e. generally object.getIndexProperty() != list.indexOf(object)). However it guarantees the right ordering based on index property.

Since:
1.2
See Also:
Serialized Form
  • Field Details

    • list

      protected List list
      A list used for the actual objects storage.
    • indexProperty

      protected String indexProperty
  • Constructor Details

    • IndexPropertyList

      public IndexPropertyList​(String indexProperty)
      Creates an empty NumericPropertyOrderedList.
    • IndexPropertyList

      public IndexPropertyList​(String indexProperty, List objects, boolean sortNeeded)
      Creates a NumericPropertyOrderedList that decorates another list. If the list is not known to be properly sorted, caller must set sortNeeded to true. This will result in sorting the original list on first access attempt.
  • Method Details