biz.hammurapi.convert
Class DuckConverterFactory
java.lang.Object
biz.hammurapi.convert.DuckConverterFactory
public class DuckConverterFactory
- extends java.lang.Object
Creates converters which use "duck" typing.
- Author:
- Pavel
Method Summary |
static int |
classAffinity(java.lang.Class subClass,
java.lang.Class superClass)
Calculates how close is subclass to superclass in class hierarchy. |
static Converter |
getConverter(java.lang.Class sourceClass,
java.lang.Class targetInterface)
|
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DuckConverterFactory
public DuckConverterFactory()
getConverter
public static Converter getConverter(java.lang.Class sourceClass,
java.lang.Class targetInterface)
- Parameters:
sourceClass
- targetInterface
-
- Returns:
- Converter which can "duck-type" instance of source class to target interface or null if conversion is not possible.
Methods are mapped as follows: return types shall be compatible, arguments shall be compatible, exception declarations are ignored.
classAffinity
public static int classAffinity(java.lang.Class subClass,
java.lang.Class superClass)
- Calculates how close is subclass to superclass in class hierarchy.
- Parameters:
subClass
- superClass
-
- Returns:
- affinity, or Integer.MAX_VALUE if classes don't belong to the same class hierarchy.
main
public static void main(java.lang.String[] args)
Copyright © 2003 Hammurapi Group. All Rights Reserved.