类 BeanMorpher

java.lang.Object
com.sh.json.ezmorph.bean.BeanMorpher
所有已实现的接口:
Morpher, ObjectMorpher

public final class BeanMorpher extends Object implements ObjectMorpher
Converts a JavaBean into another JavaBean or DynaBean.
This Morpher will try to match every property from the target JavaBean's class to the properties of the source JavaBean. If any target property differs in type from the source property, it will try to morph it. If a Morpher is not found for that type, the conversion will be aborted with a MorphException; this may be changed by setting the Morpher to be lenient, in that way it will ignore the property (the resulting value will be null).
  • 构造器详细资料

    • BeanMorpher

      public BeanMorpher(Class<?> beanClass, MorpherRegistry morpherRegistry)
      参数:
      beanClass - the target class to morph to
      morpherRegistry - a registry of morphers
    • BeanMorpher

      public BeanMorpher(Class<?> beanClass, MorpherRegistry morpherRegistry, boolean lenient)
      参数:
      beanClass - the target class to morph to
      morpherRegistry - a registry of morphers
      lenient - if an exception should be raised if no morpher is found for a target property
  • 方法详细资料

    • morph

      public Object morph(Object sourceBean)
      从接口复制的说明: ObjectMorpher
      Morphs the input object into an output object of the supported type.
      指定者:
      morph 在接口中 ObjectMorpher
      参数:
      sourceBean - The input value to be morphed
    • morphsTo

      public Class<?> morphsTo()
      从接口复制的说明: Morpher
      Returns the target Class for conversion.
      指定者:
      morphsTo 在接口中 Morpher
      返回:
      the target Class for conversion.
    • supports

      public boolean supports(Class<?> clazz)
      从接口复制的说明: Morpher
      Returns true if the Morpher supports conversion from this Class.
      指定者:
      supports 在接口中 Morpher
      参数:
      clazz - the source Class
      返回:
      true if clazz is supported by this morpher, false otherwise.