org.nuiton.topia.persistence.util
Class BeanPropertyLoador<E>

java.lang.Object
  extended by org.nuiton.topia.persistence.util.BeanPropertyLoador<E>
Type Parameters:
E - type of bean to bind
All Implemented Interfaces:
Serializable, Loador<E>
Direct Known Subclasses:
EntityLoador

public class BeanPropertyLoador<E>
extends Object
implements Loador<E>

A implementation fo the Loador contract using PropertyDescriptor.

Some factory methods are defined to simplify the generic cast, prefer used them instead of the (protected) constructor.

Author:
chemit
See Also:
Serialized Form

Field Summary
protected  PropertyDescriptor[] descriptors
           
protected  Class<E> klass
           
protected  List<String> properties
           
protected static Integer ZERO
           
protected static Byte ZEROB
           
protected static Double ZEROD
           
protected static Float ZEROF
           
protected static Long ZEROL
           
 
Constructor Summary
protected BeanPropertyLoador(Class<E> klass, String... properties)
           
 
Method Summary
protected  void checkProperties()
           
 PropertyDescriptor[] getDescriptors()
           
protected static Object getNullValue(Class<?> type)
          Deprecated. use TopiaEntityHelper.getNullValue(Class)
 List<String> getProperties()
           
static boolean isNullValue(Object value)
          Deprecated. use TopiaEntityHelper.isNullValue(Object)
 void load(E from, E dst, boolean tech)
          Bind an entity to another.
static
<E> BeanPropertyLoador<E>
newLoador(Class<E> klass, String... properties)
           
 Map<String,Object> obtainProgperties(E from)
          Deprecated. 
 Map<String,Object> obtainProperties(E from)
          Obtain from an entity all data to bind to another one according the definition of the loador.
protected  void setProperty(E dst, PropertyDescriptor descriptor, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

protected static final Integer ZERO

ZEROF

protected static final Float ZEROF

ZEROL

protected static final Long ZEROL

ZEROD

protected static final Double ZEROD

ZEROB

protected static final Byte ZEROB

properties

protected List<String> properties

descriptors

protected transient PropertyDescriptor[] descriptors

klass

protected Class<E> klass
Constructor Detail

BeanPropertyLoador

protected BeanPropertyLoador(Class<E> klass,
                             String... properties)
Method Detail

newLoador

public static <E> BeanPropertyLoador<E> newLoador(Class<E> klass,
                                                  String... properties)

getProperties

public List<String> getProperties()

getDescriptors

public PropertyDescriptor[] getDescriptors()

obtainProperties

public Map<String,Object> obtainProperties(E from)
Description copied from interface: Loador
Obtain from an entity all data to bind to another one according the definition of the loador.

This method is usefull when you can not directly used the Loador.load(Object, Object, boolean) method.

For example, when an entity has a immutable business key (says with an hibernate naturalId for example), and that you want to create the data in a db, you must give all the properties at the create time so this method allow you to do it).

Specified by:
obtainProperties in interface Loador<E>
Parameters:
from - the entity to bind
Returns:
the map of properties to bind from the given entity.

obtainProgperties

@Deprecated
public Map<String,Object> obtainProgperties(E from)
Deprecated. 

Specified by:
obtainProgperties in interface Loador<E>

load

public void load(E from,
                 E dst,
                 boolean tech)
Description copied from interface: Loador
Bind an entity to another.

Specified by:
load in interface Loador<E>
Parameters:
from - the source entity
dst - the destination entity
tech - a flag to bind or not the technical values of the entity (says TopiaId, TopiaVersion and TopiaCreateDate).

setProperty

protected void setProperty(E dst,
                           PropertyDescriptor descriptor,
                           Object value)

getNullValue

@Deprecated
protected static Object getNullValue(Class<?> type)
Deprecated. use TopiaEntityHelper.getNullValue(Class)

Parameters:
type - type to test
Returns:
the null value for the given type

isNullValue

@Deprecated
public static boolean isNullValue(Object value)
Deprecated. use TopiaEntityHelper.isNullValue(Object)

Parameters:
value - the value to test
Returns:
true if value is null

checkProperties

protected void checkProperties()


Copyright © 2004-2010 CodeLutin. All Rights Reserved.