Class MethodArgumentsUberspector

  • All Implemented Interfaces:
    org.apache.velocity.util.introspection.ChainableUberspector, org.apache.velocity.util.introspection.Uberspect, org.apache.velocity.util.RuntimeServicesAware

    public class MethodArgumentsUberspector
    extends org.apache.velocity.util.introspection.AbstractChainableUberspector
    implements org.apache.velocity.util.RuntimeServicesAware
    Chainable Velocity Uberspector that tries to convert method arguments to formal parameter types when the passed arguments don't match the method signature. In other words, it looks for a method matching the passed arguments and if none is found then it tries the convert the arguments to match the available method signatures (the available methods with the same name and the same number of parameters but with different parameter types). E.g.:
     $obj.someMethod('VALUE')
     // will forward to
     obj.someMethod(SomeEnum.VALUE)
     // if obj has someMethod(SomeEnum) and not someMethod(String)
     

    Also handle Optional return values and unwraps them.

    Since:
    4.1M2
    Version:
    $Id: 5225e2b9ed46dfe0fcad7eac955bf849ddbae084 $
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.velocity.util.introspection.UberspectImpl

        org.apache.velocity.util.introspection.UberspectImpl.VelGetterImpl, org.apache.velocity.util.introspection.UberspectImpl.VelMethodImpl, org.apache.velocity.util.introspection.UberspectImpl.VelSetterImpl
    • Field Summary

      • Fields inherited from class org.apache.velocity.util.introspection.AbstractChainableUberspector

        inner
      • Fields inherited from class org.apache.velocity.util.introspection.UberspectImpl

        conversionHandler, introspector, log, rsvc
    • Constructor Detail

      • MethodArgumentsUberspector

        public MethodArgumentsUberspector()
    • Method Detail

      • setRuntimeServices

        public void setRuntimeServices​(org.apache.velocity.runtime.RuntimeServices runtimeServices)
        Specified by:
        setRuntimeServices in interface org.apache.velocity.util.RuntimeServicesAware
        Overrides:
        setRuntimeServices in class org.apache.velocity.util.introspection.UberspectImpl
      • getMethod

        public org.apache.velocity.util.introspection.VelMethod getMethod​(Object obj,
                                                                          String methodName,
                                                                          Object[] args,
                                                                          org.apache.velocity.util.introspection.Info i)
        Specified by:
        getMethod in interface org.apache.velocity.util.introspection.Uberspect
        Overrides:
        getMethod in class org.apache.velocity.util.introspection.AbstractChainableUberspector