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:
java.io.Serializable, Loador<E>
Direct Known Subclasses:
EntityLoador

public class BeanPropertyLoador<E>
extends java.lang.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  java.beans.PropertyDescriptor[] descriptors
           
protected  java.lang.Class<E> klass
           
protected  java.util.List<java.lang.String> properties
           
protected static java.lang.Integer ZERO
           
protected static java.lang.Byte ZEROB
           
protected static java.lang.Double ZEROD
           
protected static java.lang.Float ZEROF
           
protected static java.lang.Long ZEROL
           
 
Constructor Summary
protected BeanPropertyLoador(java.lang.Class<E> klass, java.lang.String... properties)
           
 
Method Summary
protected  void checkProperties()
           
 java.beans.PropertyDescriptor[] getDescriptors()
           
protected static java.lang.Object getNullValue(java.lang.Class<?> type)
          Deprecated. use TopiaEntityHelper.getNullValue(Class)
 java.util.List<java.lang.String> getProperties()
           
static boolean isNullValue(java.lang.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(java.lang.Class<E> klass, java.lang.String... properties)
           
 java.util.Map<java.lang.String,java.lang.Object> obtainProgperties(E from)
          Deprecated. 
 java.util.Map<java.lang.String,java.lang.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, java.beans.PropertyDescriptor descriptor, java.lang.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 java.lang.Integer ZERO

ZEROF

protected static final java.lang.Float ZEROF

ZEROL

protected static final java.lang.Long ZEROL

ZEROD

protected static final java.lang.Double ZEROD

ZEROB

protected static final java.lang.Byte ZEROB

properties

protected java.util.List<java.lang.String> properties

descriptors

protected transient java.beans.PropertyDescriptor[] descriptors

klass

protected java.lang.Class<E> klass
Constructor Detail

BeanPropertyLoador

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

newLoador

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

getProperties

public java.util.List<java.lang.String> getProperties()

getDescriptors

public java.beans.PropertyDescriptor[] getDescriptors()

obtainProperties

public java.util.Map<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.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,
                           java.beans.PropertyDescriptor descriptor,
                           java.lang.Object value)

getNullValue

@Deprecated
protected static java.lang.Object getNullValue(java.lang.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(java.lang.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-2009 CodeLutin. All Rights Reserved.