Class Binder.BinderModel<S,T>

java.lang.Object
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:
Tony Chemit - chemit@codelutin.com
See Also:
  • Field Details

    • 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
    • instanceFactory

      protected InstanceFactory<T> instanceFactory
      factory of target Instance
    • functions

      protected final Map<Class<?>, com.google.common.base.Function<?,?>> functions
      Dictonnary of function to apply by source class type.
  • Constructor Details

    • BinderModel

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

    • 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

      public boolean containsSourceProperty(String sourceProperty)
    • containsTargetProperty

      public boolean containsTargetProperty(String targetProperty)
    • containsCollectionProperty

      public boolean containsCollectionProperty(String propertyName)
    • containsBinderProperty

      public 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)
    • setInstanceFactory

      public void setInstanceFactory(InstanceFactory<T> instanceFactory)
    • getInstanceFactory

      public InstanceFactory<T> getInstanceFactory()
    • getFunction

      public com.google.common.base.Function getFunction(Class<?> aClass)
    • isUseFunctions

      public boolean isUseFunctions()