org.omnaest.utils.structure.table.adapter
Class TableToTypeListAdapter<B>

java.lang.Object
  extended by org.omnaest.utils.structure.collection.CollectionAbstract<E>
      extended by org.omnaest.utils.structure.collection.list.ListAbstract<B>
          extended by org.omnaest.utils.structure.table.adapter.TableToTypeListAdapter<B>
Type Parameters:
B - Java Bean type
All Implemented Interfaces:
Serializable, Iterable<B>, Collection<B>, List<B>, TableAdapter<List<B>,Object>

public class TableToTypeListAdapter<B>
extends ListAbstract<B>
implements TableAdapter<List<B>,Object>


A TableToTypeListAdapter treats the horizontal Table.Rows of the Table as Java Beans. The Table.Column titles of the Table have to be equal to (all or a subset) of the property names of the given Table, since the property values of the Java Bean object will be written to the Table.Column with the respective title.

Author:
Omnaest
See Also:
TableAdapter, newInstance(Table, Class), Serialized Form

Field Summary
protected  Class<B> beanClass
           
protected  Table<Object> table
           
 
Constructor Summary
  TableToTypeListAdapter(Class<? extends B> beanClass)
          Creates a new TableAdapter for use with TableAdaptable.TableAdapterProvider.adapter(TableAdapter) only.
protected TableToTypeListAdapter(Table<? extends Object> table, Class<? extends B> beanClass)
          Creates a new TableToTypeListAdapter with the given Table as underlying Table object.
 
Method Summary
 boolean add(B e)
           
 void add(int index, B element)
           
 B addRow(int rowIndexPosition, B bean)
          Adds a new Table.Row to the underlying Table based on the values of the given Java Bean at the given row index position.
 void clear()
           
 B get(int rowIndexPosition)
          Returns the Table.Row for the given row index position as Java Bean.
 Table<Object> getTable()
          Returns the underlying Table data structure.
 int indexOf(Object o)
           
 List<B> initializeAdapter(Table<Object> table)
          Returns an adapter for the given Table
 int lastIndexOf(Object o)
           
static
<B> TableToTypeListAdapter<B>
newInstance(Table<?> table, Class<? extends B> beanClass)
          Factory methods which creates a new TableToTypeListAdapter instance for the given Java Bean Class and Table .
 B remove(int index)
           
 B set(int rowIndexPosition, B bean)
          Sets the Table.Row of the underling Table to the values of the given Java Bean.
 int size()
           
 
Methods inherited from class org.omnaest.utils.structure.collection.list.ListAbstract
addAll, contains, isValidIndex, iterator, listIterator, listIterator, remove, subList
 
Methods inherited from class org.omnaest.utils.structure.collection.CollectionAbstract
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Field Detail

table

protected Table<Object> table

beanClass

protected Class<B> beanClass
Constructor Detail

TableToTypeListAdapter

protected TableToTypeListAdapter(Table<? extends Object> table,
                                 Class<? extends B> beanClass)
Creates a new TableToTypeListAdapter with the given Table as underlying Table object.

Parameters:
table -
beanClass -
See Also:
newInstance(Table, Class)

TableToTypeListAdapter

public TableToTypeListAdapter(Class<? extends B> beanClass)
Creates a new TableAdapter for use with TableAdaptable.TableAdapterProvider.adapter(TableAdapter) only. For normal usage see newInstance(Table, Class) instead.

Parameters:
table -
beanClass -
See Also:
newInstance(Table, Class), initializeAdapter(Table), newInstance(Table, Class)
Method Detail

newInstance

public static <B> TableToTypeListAdapter<B> newInstance(Table<?> table,
                                                        Class<? extends B> beanClass)
Factory methods which creates a new TableToTypeListAdapter instance for the given Java Bean Class and Table .

Type Parameters:
B -
Parameters:
table -
beanClass -
Returns:

getTable

public Table<Object> getTable()
Returns the underlying Table data structure.

Returns:

size

public int size()
Specified by:
size in interface Collection<B>
Specified by:
size in interface List<B>

add

public boolean add(B e)
Specified by:
add in interface Collection<B>
Specified by:
add in interface List<B>

addRow

public B addRow(int rowIndexPosition,
                B bean)
Adds a new Table.Row to the underlying Table based on the values of the given Java Bean at the given row index position.

Parameters:
rowIndexPosition -
bean -
Returns:
managed Java Bean instance, which reflects all changes to the new created Table.Row immediately and vice versa.

clear

public void clear()
Specified by:
clear in interface Collection<B>
Specified by:
clear in interface List<B>
Overrides:
clear in class CollectionAbstract<B>

get

public B get(int rowIndexPosition)
Returns the Table.Row for the given row index position as Java Bean. All changes to this Java Bean will be reflected within the Table.Row of the Table

Specified by:
get in interface List<B>
Parameters:
rowIndexPosition -
Returns:

set

public B set(int rowIndexPosition,
             B bean)
Sets the Table.Row of the underling Table to the values of the given Java Bean.

Specified by:
set in interface List<B>
Parameters:
rowIndexPosition -
bean -
Returns:
a new managed bean instance with the same values which act as proxy for the addressed Table.Row. This means changes to this instance will be reflected immediately to the Table.Row and vice versa.

add

public void add(int index,
                B element)
Specified by:
add in interface List<B>

remove

public B remove(int index)
Specified by:
remove in interface List<B>

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List<B>

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List<B>

initializeAdapter

public List<B> initializeAdapter(Table<Object> table)
Description copied from interface: TableAdapter
Returns an adapter for the given Table

Specified by:
initializeAdapter in interface TableAdapter<List<B>,Object>
Returns:


Copyright © 2011. All Rights Reserved.