biz.hammurapi.convert
Class ReflectionConverter
java.lang.Object
biz.hammurapi.convert.ReflectionConverter
- All Implemented Interfaces:
- AtomicConverter
public class ReflectionConverter
- extends java.lang.Object
- implements AtomicConverter
Converts one type to another using accessor/constructor combination.
- Author:
- Pavel
Constructor Summary |
ReflectionConverter(java.lang.reflect.Method accessor,
java.lang.reflect.Constructor constructor)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ReflectionConverter
public ReflectionConverter(java.lang.reflect.Method accessor,
java.lang.reflect.Constructor constructor)
- Parameters:
accessor
- Source object method to invoke to get target type or
constructor parameter for the target type. If it is null, then source itself
is passed to constructor. One of parameters may be null, but not both.constructor
- Target class constructor which takes one parameter, either
source type or return type of source type accessor.
convert
public java.lang.Object convert(java.lang.Object source,
Converter master,
Context context)
- Description copied from interface:
AtomicConverter
- Converts object to target type.
- Specified by:
convert
in interface AtomicConverter
- Parameters:
source
- Source object.master
- Master converter to delegate conversion
of object parts.
- Returns:
- Converted object.
getSourceType
public java.lang.Class getSourceType()
- Specified by:
getSourceType
in interface AtomicConverter
- Returns:
- Type which converter converts from.
getTargetType
public java.lang.Class getTargetType()
- Specified by:
getTargetType
in interface AtomicConverter
- Returns:
- Type which converter converts to.
discoverConstructorConverters
public static java.util.Collection discoverConstructorConverters(java.lang.Class target)
- Discovers constructor conversions.
- Parameters:
target
- Target type
- Returns:
- Collection of discovered converters.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
Copyright © 2003 Hammurapi Group. All Rights Reserved.