org.ujoframework.extensions
Class ListProperty<UJO extends Ujo,ITEM>

java.lang.Object
  extended by org.ujoframework.extensions.Property<UJO,java.util.List<ITEM>>
      extended by org.ujoframework.extensions.ListProperty<UJO,ITEM>
All Implemented Interfaces:
java.lang.CharSequence, ListUjoProperty<UJO,ITEM>, UjoProperty<UJO,java.util.List<ITEM>>
Direct Known Subclasses:
BeanPropertyList, FieldPropertyList

public class ListProperty<UJO extends Ujo,ITEM>
extends Property<UJO,java.util.List<ITEM>>
implements ListUjoProperty<UJO,ITEM>

The main implementation of the interface ListUjoProperty.

Author:
Pavel Ponec
See Also:
AbstractUjo

Constructor Summary
protected ListProperty(java.lang.Class<ITEM> itemType)
          Protected constructor
protected ListProperty(java.lang.String name, java.lang.Class<ITEM> itemType, int index)
          Protected constructor
 
Method Summary
 boolean addItem(UJO ujo, ITEM value)
          Add Item Value.
 ITEM getItem(UJO ujo, int index)
          Returns a value of property.
 int getItemCount(UJO ujo)
          Returns a count of Items.
 java.lang.Class<ITEM> getItemType()
          Return a Class of the Item.
 java.util.List<ITEM> getList(UJO ujo)
          Returns a not null List.
protected  ListProperty<UJO,ITEM> initList(java.lang.String name, int index, java.lang.Boolean lock)
          List property initialization.
 boolean isDefault(UJO ujo)
          Indicates whether a list of items is null or empty.
 boolean isItemTypeOf(java.lang.Class type)
          Returns true if the item type is a type or subtype of the parameter class.
static
<UJO extends Ujo,ITEM>
ListProperty<UJO,ITEM>
newListProperty(java.lang.String name, java.lang.Class<ITEM> itemType)
          A ListUjoProperty Factory Method assigns a next property index.
static
<UJO extends Ujo,ITEM>
ListProperty<UJO,ITEM>
newListProperty(java.lang.String name, java.lang.Class<ITEM> itemType, int index)
          A ListUjoProperty Factory Method assigns a next property index.
static
<UJO extends Ujo,ITEM>
ListProperty<UJO,ITEM>
newListProperty(java.lang.String name, java.lang.Class<ITEM> itemType, int index, boolean lock)
          A ListUjoProperty Factory Method assigns a next property index.
 boolean removeItem(UJO ujo, ITEM value)
          Removes the first occurrence in this list of the specified element.
 ITEM setItem(UJO ujo, int index, ITEM value)
          Set a property item value.
 void sort(UJO ujo, UjoProperty... properties)
          Sort a list by its properties.
 
Methods inherited from class org.ujoframework.extensions.Property
_nextSequence, add, compareTo, copy, descending, equals, getDefault, getIndex, getName, getType, getValue, charAt, checkAttribs, init, isAscending, isDirect, isTypeOf, length, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, of, setValue, setValueFromDefault, subSequence, toString, writeDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujoframework.UjoProperty
add, copy, descending, equals, getDefault, getIndex, getName, getType, getValue, isAscending, isDirect, isTypeOf, of, setValue, toString
 
Methods inherited from interface java.lang.CharSequence
charAt, length, subSequence
 

Constructor Detail

ListProperty

protected ListProperty(java.lang.Class<ITEM> itemType)
Protected constructor


ListProperty

protected ListProperty(java.lang.String name,
                       java.lang.Class<ITEM> itemType,
                       int index)
Protected constructor

Method Detail

initList

protected final ListProperty<UJO,ITEM> initList(java.lang.String name,
                                                int index,
                                                java.lang.Boolean lock)
List property initialization.

Parameters:
name - Replace the Name of property if the one is NULL.
index - Replace index always, the value -1 invoke a next number from the internal sequencer.
lock - Lock the property.

getItemCount

public int getItemCount(UJO ujo)
Returns a count of Items. If a property value is null, method returns 0.

Specified by:
getItemCount in interface ListUjoProperty<UJO extends Ujo,ITEM>

getItemType

public java.lang.Class<ITEM> getItemType()
Return a Class of the Item.

Specified by:
getItemType in interface ListUjoProperty<UJO extends Ujo,ITEM>

isItemTypeOf

public boolean isItemTypeOf(java.lang.Class type)
Returns true if the item type is a type or subtype of the parameter class.

Specified by:
isItemTypeOf in interface ListUjoProperty<UJO extends Ujo,ITEM>

getItem

public ITEM getItem(UJO ujo,
                    int index)
Returns a value of property. The result is the same, like Ujo#getValue(UjoPropertyList) .get(index) .

Specified by:
getItem in interface ListUjoProperty<UJO extends Ujo,ITEM>

setItem

public ITEM setItem(UJO ujo,
                    int index,
                    ITEM value)
Set a property item value. The action is the same, like Ujo#getValue(UjoPropertyList) .set(indexm, value).

Specified by:
setItem in interface ListUjoProperty<UJO extends Ujo,ITEM>
Returns:
the element previously at the specified position.

addItem

public boolean addItem(UJO ujo,
                       ITEM value)
Add Item Value. If List is null, the method creates an instance.

Specified by:
addItem in interface ListUjoProperty<UJO extends Ujo,ITEM>
Returns:
true (as per the general contract of Collection.add).

removeItem

public boolean removeItem(UJO ujo,
                          ITEM value)
Removes the first occurrence in this list of the specified element.

Specified by:
removeItem in interface ListUjoProperty<UJO extends Ujo,ITEM>
Returns:
true if this list is not null and contains the specified element, otherwise returns false.
Since:
0.81

getList

public java.util.List<ITEM> getList(UJO ujo)
Returns a not null List. If original list value is null, then a new List is created by a property type. If the property type is an interface then the ArrayList instance is used.

Specified by:
getList in interface ListUjoProperty<UJO extends Ujo,ITEM>
See Also:
getItem(Ujo,int)

sort

public void sort(UJO ujo,
                 UjoProperty... properties)
Sort a list by its properties.


isDefault

public boolean isDefault(UJO ujo)
Indicates whether a list of items is null or empty.

Specified by:
isDefault in interface ListUjoProperty<UJO extends Ujo,ITEM>
Specified by:
isDefault in interface UjoProperty<UJO extends Ujo,java.util.List<ITEM>>
Overrides:
isDefault in class Property<UJO extends Ujo,java.util.List<ITEM>>

newListProperty

public static <UJO extends Ujo,ITEM> ListProperty<UJO,ITEM> newListProperty(java.lang.String name,
                                                                            java.lang.Class<ITEM> itemType,
                                                                            int index,
                                                                            boolean lock)
A ListUjoProperty Factory Method assigns a next property index.


newListProperty

public static <UJO extends Ujo,ITEM> ListProperty<UJO,ITEM> newListProperty(java.lang.String name,
                                                                            java.lang.Class<ITEM> itemType,
                                                                            int index)
A ListUjoProperty Factory Method assigns a next property index.


newListProperty

public static <UJO extends Ujo,ITEM> ListProperty<UJO,ITEM> newListProperty(java.lang.String name,
                                                                            java.lang.Class<ITEM> itemType)
A ListUjoProperty Factory Method assigns a next property index.



Copyright © 2010. All Rights Reserved.