org.bbottema.javareflection.model.LookupMode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-reflection Show documentation
Show all versions of java-reflection Show documentation
Java Reflection provides a small package with nifty reflection features that will help with finding constructors, methods and value conversions
package org.bbottema.javareflection.model;
import org.bbottema.javareflection.valueconverter.ValueConversionHelper;
/**
* Defines lookup modes for matching Java methods and constructors. Each time a lookup failed on signature type, a less strict lookup
* is performed, in the following order (signature means: the list of parameters defined for a method or constructor):
*
* - exact matching: the given type should exactly match the found types during lookup. This lookup cycle is always performed
* first.
* - autobox matching: the given type should match its boxed/unboxed version.
* - polymorphic interface matching: the given type should match one of the implemented interfaces
* - polymorphic superclass matching: the given type should match one of the super classes (for each superclass, the cycle is
* repeated, so exact and interface matching come first again before the next superclass up in the chain)
* - common conversion matching: if all other lookups fail, one last resort is to try to convert the given type, if a common
* type, to any other common type and then try to find a matching method or constructor. See {@link ValueConversionHelper} for more on the possibilities.
*
*
*/
public enum LookupMode {
/**
* Indicates that looking for methods includes trying to find compatible signatures by autoboxing the specified arguments.
*/
AUTOBOX,
/**
* Indicates that looking for methods includes trying to find compatible signatures by casting the specified arguments to a super type.
*/
CAST_TO_SUPER,
/**
* Indicates that looking for methods includes trying to find compatible signatures by casting the specified arguments to an implemented
* interface.
*/
CAST_TO_INTERFACE,
/**
* Indicates that looking for methods includes trying to find compatible signatures by automatically converting the specified arguments.
*/
COMMON_CONVERT,
/**
* Like {@link #COMMON_CONVERT}, but now takes the registered converters and continues finding a conversion path based on the previous outcomes.
*
* Examples:
*
* - Joda date object -> String -> Java8 date object. This would require only the toJava8 date object converter to work
* - Calendar -> String -> char. Calendar is compatible with String and String with char, but conversion will fail of course.
* - Boolean -> Character -> long. This simply works out of the box, resulting in 0 or 1.
*
*/
SMART_CONVERT
}