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

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

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

Model of a Binder.

TODO tchemit 20100225 should have special cases for collections treatment.

Since:
1.1.5
Author:
tchemit
See Also:
Serialized Form

Field Summary
protected  Map<String,Binder<?,?>> binders
          mapping of extra binders to use to copy properties
protected  Map<String,Binder.CollectionStrategy> collectionStrategies
          mapping of collection properties strategies
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
Binder.BinderModel(Class<S> sourceType, Class<T> targetType)
           
 
Method Summary
 void addBinder(String propertyName, Binder<?,?> binder)
           
protected  void addBinding(PropertyDescriptor sourceDescriptor, PropertyDescriptor targetDescriptor)
           
 void addCollectionStrategy(String propertyName, Binder.CollectionStrategy strategy)
           
protected  boolean containsBinderProperty(String propertyName)
           
protected  boolean containsCollectionProperty(String propertyName)
           
protected  boolean containsSourceProperty(String sourceProperty)
           
protected  boolean containsTargetProperty(String targetProperty)
           
 Binder<?,?> getBinder(String sourceProperty)
           
 Binder.CollectionStrategy getCollectionStrategy(String property)
           
 Class<?> getCollectionType(String sourceProperty)
           
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)
           
protected  void removeBinding(String source)
           
 
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)


collectionStrategies

protected Map<String,Binder.CollectionStrategy> collectionStrategies
mapping of collection properties strategies


binders

protected Map<String,Binder<?,?>> binders
mapping of extra binders to use to copy properties

Constructor Detail

Binder.BinderModel

public Binder.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

getCollectionStrategy

public Binder.CollectionStrategy getCollectionStrategy(String property)

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.

getCollectionType

public Class<?> getCollectionType(String sourceProperty)

addCollectionStrategy

public void addCollectionStrategy(String propertyName,
                                  Binder.CollectionStrategy strategy)

addBinder

public void addBinder(String propertyName,
                      Binder<?,?> binder)

containsSourceProperty

protected boolean containsSourceProperty(String sourceProperty)

containsTargetProperty

protected boolean containsTargetProperty(String targetProperty)

containsCollectionProperty

protected boolean containsCollectionProperty(String propertyName)

containsBinderProperty

protected boolean containsBinderProperty(String propertyName)

addBinding

protected void addBinding(PropertyDescriptor sourceDescriptor,
                          PropertyDescriptor targetDescriptor)

removeBinding

protected void removeBinding(String source)

getPropertiesMapping

protected Map<String,String> getPropertiesMapping()

getBinder

public Binder<?,?> getBinder(String sourceProperty)


Copyright © 2004-2011 CodeLutin. All Rights Reserved.