Class IntrospectionUtils

java.lang.Object
org.apache.velocity.util.introspection.IntrospectionUtils

public class IntrospectionUtils extends Object
Since:
1.6
Version:
$Id: IntrospectionUtils.java 476785 2006-11-19 10:06:21Z henning $
Author:
Jason van Zyl, Bob McWhirter, Christoph Reck, Geir Magnusson Jr., Attila Szegedi, Nathan Bubna, Claude Brisson
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Class<?>
    returns boxed type (or input type if not a primitive type)
    static Class<?>
    returns the Class corresponding to a Type, if possible
    static Class<?>
    returns unboxed type (or input type if not successful)
    static boolean
    isMethodInvocationConvertible(Type formal, Class<?> actual, boolean possibleVarArg)
    Determines whether a type represented by a class object is convertible to another type represented by a class object using a method invocation conversion, treating object types of primitive types as if they were primitive types (that is, a Boolean actual parameter type matches boolean primitive formal type).
    static boolean
    isStrictMethodInvocationConvertible(Type formal, Class<?> actual, boolean possibleVarArg)
    Determines whether a type represented by a class object is convertible to another type represented by a class object using a method invocation conversion, without matching object and primitive types.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IntrospectionUtils

      public IntrospectionUtils()
  • Method Details

    • getBoxedClass

      public static Class<?> getBoxedClass(Class clazz)
      returns boxed type (or input type if not a primitive type)
      Parameters:
      clazz - input class
      Returns:
      boxed class
    • getUnboxedClass

      public static Class<?> getUnboxedClass(Class clazz)
      returns unboxed type (or input type if not successful)
      Parameters:
      clazz - input class
      Returns:
      unboxed class
    • getTypeClass

      public static Class<?> getTypeClass(Type type)
      returns the Class corresponding to a Type, if possible
      Parameters:
      type - the input Type
      Returns:
      found Class, if any
    • isMethodInvocationConvertible

      public static boolean isMethodInvocationConvertible(Type formal, Class<?> actual, boolean possibleVarArg)
      Determines whether a type represented by a class object is convertible to another type represented by a class object using a method invocation conversion, treating object types of primitive types as if they were primitive types (that is, a Boolean actual parameter type matches boolean primitive formal type). This behavior is because this method is used to determine applicable methods for an actual parameter list, and primitive types are represented by their object duals in reflective method calls.
      Parameters:
      formal - the formal parameter type to which the actual parameter type should be convertible
      actual - the actual parameter type.
      possibleVarArg - whether or not we're dealing with the last parameter in the method declaration
      Returns:
      true if either formal type is assignable from actual type, or formal is a primitive type and actual is its corresponding object type or an object type of a primitive type that can be converted to the formal type.
    • isStrictMethodInvocationConvertible

      public static boolean isStrictMethodInvocationConvertible(Type formal, Class<?> actual, boolean possibleVarArg)
      Determines whether a type represented by a class object is convertible to another type represented by a class object using a method invocation conversion, without matching object and primitive types. This method is used to determine the more specific type when comparing signatures of methods.
      Parameters:
      formal - the formal parameter type to which the actual parameter type should be convertible
      actual - the actual parameter type.
      possibleVarArg - whether or not we're dealing with the last parameter in the method declaration
      Returns:
      true if either formal type is assignable from actual type, or formal and actual are both primitive types and actual can be subject to widening conversion to formal.