com.miginfocom.property
Class ListProperty<T>

java.lang.Object
  extended by com.miginfocom.property.Property<java.util.Collection<T>>
      extended by com.miginfocom.property.CollectionProperty<T>
          extended by com.miginfocom.property.ListProperty<T>
All Implemented Interfaces:
FieldProperty<java.util.Collection<T>>, java.io.Serializable, java.lang.Iterable<T>, CollectionPropertyI<T>, ListPropertyI<T>, PropertyI<java.util.Collection<T>>

public class ListProperty<T>
extends CollectionProperty<T>
implements ListPropertyI<T>

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.miginfocom.property.Property
UNINITIALIZED
 
Constructor Summary
ListProperty()
          Constructor to create a property that is initialized.
ListProperty(java.util.List<T> cols)
          Constructor.
ListProperty(T... values)
          Constructor.
 
Method Summary
 Result<T> add(T value, int ix)
          Adds an element at specified index in the list.
protected  java.util.List<T> create()
          Creates the list.
 T get(int ix)
          Returns the element at the specified index.
protected  java.util.List<T> makeUnmodifiable(java.util.Collection<T> value)
          Makes the value unmodifiable, usually by wrapping it.
 Result<T> removeIndex(int ix)
          Removed the element at the specified index in the list.
 Result<T> set(T value, int ix)
          Sets (exchanges) an element at specified index in the list.
 
Methods inherited from class com.miginfocom.property.CollectionProperty
add, addAll, checkModifyAccess, contains, containsAll, iterator, remove, removeAll, size
 
Methods inherited from class com.miginfocom.property.Property
addPropertyListener, addPropertyListener, checkInit, cloneObject, createInfo, get, getBean, getInfo, getInternal, getName, init, initNotify, isNull, removePropertyListener, set, setInternal, toString, writeReplace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.java.properties.CollectionPropertyI
add, addAll, contains, containsAll, iterator, remove, removeAll, size
 
Methods inherited from interface net.java.properties.PropertyI
get, set
 

Constructor Detail

ListProperty

public ListProperty()
Constructor to create a property that is initialized. If


ListProperty

public ListProperty(java.util.List<T> cols)
Constructor.

Parameters:
cols - The initial collection. NOTE! The reference will be used as the backing collection and will not be cloned! May be null.

ListProperty

public ListProperty(T... values)
Constructor.

Parameters:
values - The initial collection. Will be cloned and changes to the array will not be reflected in this property.
Method Detail

create

protected java.util.List<T> create()
Creates the list. This happens the first time the collection is needed if there was no value sent into the constructor.

Overrides:
create in class CollectionProperty<T>
Returns:
A List. Default is a ArrayList of default size.

makeUnmodifiable

protected java.util.List<T> makeUnmodifiable(java.util.Collection<T> value)
Description copied from class: Property
Makes the value unmodifiable, usually by wrapping it. This is what should be done when the get/set policy is Transfer.UNMODIFIABLE. Should be overridden by collection and map properties to wrap. Other property type can also overrider this to make the value unmidifiable.

Overrides:
makeUnmodifiable in class CollectionProperty<T>
Parameters:
value - The value. May be null in which canse null should be returned.
Returns:
The unmodifiable value.

get

public T get(int ix)
Description copied from interface: ListPropertyI
Returns the element at the specified index.

Specified by:
get in interface ListPropertyI<T>
Parameters:
ix - The index for which to return the element. If >= size or < 0 an IndexOutOfBoundsException will be thrown.
Returns:
The element at ix.

set

public Result<T> set(T value,
                     int ix)
Description copied from interface: ListPropertyI
Sets (exchanges) an element at specified index in the list.

Specified by:
set in interface ListPropertyI<T>
Parameters:
value - The value to set.
ix - The index for which to set the element. If >= size or < 0 an IndexOutOfBoundsException will be thrown.
Returns:
The result of the set.

add

public Result<T> add(T value,
                     int ix)
Description copied from interface: ListPropertyI
Adds an element at specified index in the list.

Specified by:
add in interface ListPropertyI<T>
Parameters:
value - The value to add.
ix - The index that the index will be added at. If > size or < 0 an IndexOutOfBoundsException will be thrown. If ix == size the value will be added last in the list.
Returns:
The result of the add.

removeIndex

public Result<T> removeIndex(int ix)
Description copied from interface: ListPropertyI
Removed the element at the specified index in the list.

Specified by:
removeIndex in interface ListPropertyI<T>
Parameters:
ix - The index for which the element should be removed. If > size or < 0 an IndexOutOfBoundsException will be thrown.
Returns:
The result of the removal.


Copyright © 2007 MiG InfoCom AB. All Rights Reserved.