spring-framework / org.springframework.util / AutoPopulatingList

AutoPopulatingList

open class AutoPopulatingList<E : Any> : MutableList<E>, Serializable

Simple List wrapper class that allows for elements to be automatically populated as they are requested. This is particularly useful for data binding to List, allowing for elements to be created and added to the List in a "just in time" fashion.

Note: This class is not thread-safe. To create a thread-safe version, use the java.util.Collections#synchronizedList utility methods.

Inspired by LazyList from Commons Collections.

Author
Rob Harrop

Author
Juergen Hoeller

Since
2.0

Constructors

<init>

AutoPopulatingList(elementClass: Class<out E>)

Creates a new AutoPopulatingList that is backed by a standard ArrayList and adds new instances of the supplied Class to the backing List on demand.

AutoPopulatingList(backingList: MutableList<E>, elementClass: Class<out E>)

Creates a new AutoPopulatingList that is backed by the supplied List and adds new instances of the supplied Class to the backing List on demand.

AutoPopulatingList(elementFactory: ElementFactory)

Creates a new AutoPopulatingList that is backed by a standard ArrayList and creates new elements on demand using the supplied ElementFactory.

AutoPopulatingList(backingList: MutableList<E>, elementFactory: ElementFactory)

Creates a new AutoPopulatingList that is backed by the supplied List and creates new elements on demand using the supplied ElementFactory.

Properties

size

open val size: Int

Functions

add

open fun add(index: Int, element: E): Unit
open fun add(element: E): Boolean

addAll

open fun addAll(elements: Collection<E>): Boolean
open fun addAll(index: Int, elements: Collection<E>): Boolean

clear

open fun clear(): Unit

contains

open fun contains(element: E): Boolean

containsAll

open fun containsAll(elements: Collection<E>): Boolean

equals

open fun equals(other: Any?): Boolean

get

open fun get(index: Int): E

Get the element at the supplied index, creating it if there is no element at that index.

hashCode

open fun hashCode(): Int

indexOf

open fun indexOf(element: E): Int

isEmpty

open fun isEmpty(): Boolean

iterator

open fun iterator(): MutableIterator<E>

lastIndexOf

open fun lastIndexOf(element: E): Int

listIterator

open fun listIterator(): MutableListIterator<E>
open fun listIterator(index: Int): MutableListIterator<E>

remove

open fun remove(element: E): Boolean

removeAll

open fun removeAll(elements: Collection<E>): Boolean

removeAt

open fun removeAt(index: Int): E

retainAll

open fun retainAll(elements: Collection<E>): Boolean

set

open fun set(index: Int, element: E): E

subList

open fun subList(fromIndex: Int, toIndex: Int): MutableList<E>

toArray

open fun toArray(): Array<Any>
open fun <T : Any> toArray(a: Array<T>): Array<T>