org.nuiton.util.beans
Class BinderModel<S,T>

java.lang.Object
  extended by org.nuiton.util.beans.BinderModel<S,T>
Type Parameters:
S - the source type
T - the target type
All Implemented Interfaces:
Serializable

public class BinderModel<S,T>
extends Object
implements Serializable

Model of a Binder. TODO-TC20100225 should have special cases for collections treatment.

Since:
1.1.5
Author:
tchemit < chemit@codelutin.com >
See Also:
Serialized Form

Field Summary
protected  Map<String,String> propertiesMapping
          properties mapping (key are source properties, value are destination properties)
protected  Map<String,PropertyDescriptor> sourceDescriptors
          source type descriptors (key are property names)
protected  Class<S> sourceType
          source type
protected  Map<String,PropertyDescriptor> targetDescriptors
          destination descriptors (key are property names)
protected  Class<T> targetType
          destination type
 
Constructor Summary
BinderModel(Class<S> sourceType, Class<T> targetType)
           
 
Method Summary
protected  void addBinding(PropertyDescriptor sourceDescriptor, PropertyDescriptor targetDescriptor)
           
protected  boolean containsSourceProperty(String sourceProperty)
           
protected  boolean containsTargetProperty(String targetProperty)
           
protected  Map<String,String> getPropertiesMapping()
           
 PropertyDescriptor getSourceDescriptor(String sourceProperty)
          Gets the bean descriptor of the source type for the given destination property.
 String[] getSourceDescriptors()
          Gets all registred property names of the binder's source type.
 Method getSourceReadMethod(String srcProperty)
           
 Class<S> getSourceType()
          Gets the type of the binder's source.
 Method getSourceWriteMethod(String sourceProperty)
           
 PropertyDescriptor getTargetDescriptor(String targetProperty)
          Gets the bean descriptor of the destination type for the given destination property.
 String[] getTargetDescriptors()
          Gets all registred property names of the binder's destination type.
 String getTargetProperty(String sourceProperty)
          Gets the destination property name given the
 Method getTargetReadMethod(String targetProperty)
           
 Class<T> getTargetType()
          Gets the type of the binder's destination
 Method getTargetWriteMethod(String targetProperty)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceType

protected final Class<S> sourceType
source type


targetType

protected final Class<T> targetType
destination type


sourceDescriptors

protected final Map<String,PropertyDescriptor> sourceDescriptors
source type descriptors (key are property names)


targetDescriptors

protected final Map<String,PropertyDescriptor> targetDescriptors
destination descriptors (key are property names)


propertiesMapping

protected final Map<String,String> propertiesMapping
properties mapping (key are source properties, value are destination properties)

Constructor Detail

BinderModel

public BinderModel(Class<S> sourceType,
                   Class<T> targetType)
Method Detail

getSourceType

public Class<S> getSourceType()
Gets the type of the binder's source.

Returns:
the type of the source object in the binder

getTargetType

public Class<T> getTargetType()
Gets the type of the binder's destination

Returns:
the type of the destination object in the binder

getSourceDescriptors

public String[] getSourceDescriptors()
Gets all registred property names of the binder's source type.

Returns:
the array of all source object properties names to bind

getTargetDescriptors

public String[] getTargetDescriptors()
Gets all registred property names of the binder's destination type.

Returns:
the array of all source object properties names to bind

getTargetProperty

public String getTargetProperty(String sourceProperty)
Gets the destination property name given the

Parameters:
sourceProperty - the name of the source property to bind
Returns:
the name of the destination object property to bind, or null if propertySrc is unknown in the model

getSourceDescriptor

public PropertyDescriptor getSourceDescriptor(String sourceProperty)
Gets the bean descriptor of the source type for the given destination property.

Parameters:
sourceProperty - name of the source type property name
Returns:
the descriptor or null if not found.

getSourceReadMethod

public Method getSourceReadMethod(String srcProperty)
Parameters:
srcProperty - the name of a property of the source object.
Returns:
the method to read in a source object for the given property.

getSourceWriteMethod

public Method getSourceWriteMethod(String sourceProperty)
Parameters:
sourceProperty - the name of a property of the source object.
Returns:
the method to write in a source object for the given property.

getTargetDescriptor

public PropertyDescriptor getTargetDescriptor(String targetProperty)
Gets the bean descriptor of the destination type for the given destination property.

Parameters:
targetProperty - name of the destination type property name
Returns:
the descriptor or null if not found.

getTargetReadMethod

public Method getTargetReadMethod(String targetProperty)
Parameters:
targetProperty - the name of a property of the destination object.
Returns:
the method to read in a destination object for the given property.

getTargetWriteMethod

public Method getTargetWriteMethod(String targetProperty)
Parameters:
targetProperty - the name of a property of the destination object.
Returns:
the method to write in a destination object for the given property.

containsSourceProperty

protected boolean containsSourceProperty(String sourceProperty)

containsTargetProperty

protected boolean containsTargetProperty(String targetProperty)

addBinding

protected void addBinding(PropertyDescriptor sourceDescriptor,
                          PropertyDescriptor targetDescriptor)

getPropertiesMapping

protected Map<String,String> getPropertiesMapping()


Copyright © 2004-2010 CodeLutin. All Rights Reserved.