org.omnaest.utils.beans.adapter
Class ListToTypeAdapter<T,L extends List<?>>

java.lang.Object
  extended by org.omnaest.utils.beans.adapter.ListToTypeAdapter<T,L>
Type Parameters:
T -
L -

public class ListToTypeAdapter<T,L extends List<?>>
extends Object

This class creates a proxy implementation for a given Java Bean type which is used as a facade to an underlying List<?>. Be aware of the fact that only the declared fields of the Class or interface type will affect the List and no access on properties declared by supertypes.

Author:
Omnaest
See Also:
newInstance(List, Class)

Nested Class Summary
protected  class ListToTypeAdapter.ClassAdapterMethodInterceptor
          A MethodInterceptor implementation special for this ListToTypeAdapter
static interface ListToTypeAdapter.UnderlyingListAware<L extends List<?>>
          This interface makes a derivative type aware of an underlying map implementation.
 
Field Summary
protected  T classAdapter
           
protected  Class<? extends T> clazz
           
protected  boolean hasAccessToUnderlyingData
           
protected  List<Object> list
           
protected  List<String> propertynameList
           
 
Constructor Summary
protected ListToTypeAdapter(L list, Class<T> clazz, Comparator<String> comparatorPropertyname, List<String> propertynameList, boolean underlyingListAware)
           
 
Method Summary
protected  void ensureListSize()
          Initializes the given List to match the size of the list of declared methods of the underlying Class.
protected  void initializeClassAdapter(Class<? extends T> clazz, boolean underlyingListAware)
          Creates the stub
static
<T> T
newInstance(List<?> list, Class<T> clazz)
          Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade.
static
<T> T
newInstance(List<?> list, Class<T> clazz, boolean underlyingListAware)
          Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade.
static
<T> T
newInstance(List<?> list, Class<T> clazz, Comparator<String> comparatorPropertyname, boolean underlyingListAware)
          Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade.
protected static
<T> T
newInstance(List<?> list, Class<T> clazz, Comparator<String> comparatorPropertyname, List<String> propertynameList, boolean underlyingListAware)
          Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade.
static
<T> T
newInstance(List<?> list, Class<T> clazz, List<String> propertynameList, boolean underlyingListAware)
          Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

list

protected List<Object> list

classAdapter

protected T classAdapter

clazz

protected Class<? extends T> clazz

propertynameList

protected List<String> propertynameList

hasAccessToUnderlyingData

protected boolean hasAccessToUnderlyingData
Constructor Detail

ListToTypeAdapter

protected ListToTypeAdapter(L list,
                            Class<T> clazz,
                            Comparator<String> comparatorPropertyname,
                            List<String> propertynameList,
                            boolean underlyingListAware)
Parameters:
list -
clazz -
comparatorPropertyname - : optional
propertynameList - : optional
underlyingListAware -
Method Detail

newInstance

public static <T> T newInstance(List<?> list,
                                Class<T> clazz,
                                Comparator<String> comparatorPropertyname,
                                boolean underlyingListAware)
Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade. The list will contain as many elements as properties are possible and for each property an immutable index position is reserved. Within the list the objects will be stored in the order the property names have after invoking the given Comparator on them.

Parameters:
list -
clazz -
comparatorPropertyname -
underlyingListAware - : true > returned stub implements ListToTypeAdapter.UnderlyingListAware
Returns:
new
See Also:
newInstance(List, Class)

newInstance

public static <T> T newInstance(List<?> list,
                                Class<T> clazz,
                                List<String> propertynameList,
                                boolean underlyingListAware)
Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade. The list will contain as many elements as properties are possible and for each property an immutable index position is reserved. The objects will be stored in the order of the given List of property names.

Parameters:
list -
clazz -
underlyingListAware - : true > returned stub implements ListToTypeAdapter.UnderlyingListAware
Returns:
new
See Also:
newInstance(List, Class)

newInstance

public static <T> T newInstance(List<?> list,
                                Class<T> clazz,
                                boolean underlyingListAware)
Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade. The list will contain as many elements as properties are possible and for each property an immutable index position is reserved. The objects will be stored in no particular order within the List.

Parameters:
list -
clazz -
underlyingListAware - : true > returned stub implements ListToTypeAdapter.UnderlyingListAware
Returns:
new
See Also:
newInstance(List, Class)

newInstance

public static <T> T newInstance(List<?> list,
                                Class<T> clazz)
Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade. The list will contain as many elements as properties are possible and for each property an immutable index position is reserved. The objects will be stored in no particular order within the List.

Parameters:
list -
clazz -
Returns:
new
See Also:
newInstance(List, Class, boolean), newInstance(List, Class, List, boolean), *

newInstance

protected static <T> T newInstance(List<?> list,
                                   Class<T> clazz,
                                   Comparator<String> comparatorPropertyname,
                                   List<String> propertynameList,
                                   boolean underlyingListAware)
Factory method to create a new ListToTypeAdapter for a given List with the given Class as facade.

Parameters:
list -
clazz -
comparatorPropertyname -
propertynameList -
underlyingListAware -
Returns:
new
See Also:
newInstance(List, Class), newInstance(List, Class, Comparator, boolean), newInstance(List, Class, List, boolean)

ensureListSize

protected void ensureListSize()
Initializes the given List to match the size of the list of declared methods of the underlying Class.


initializeClassAdapter

protected void initializeClassAdapter(Class<? extends T> clazz,
                                      boolean underlyingListAware)
Creates the stub

Parameters:
clazz -
underlyingListAware -


Copyright © 2013. All Rights Reserved.