protected static MethodHandle addTransformer ( MethodHandle handle , int pos , Object arg , Class parameter ) { MethodHandle transformer = null ; if ( arg instanceof GString ) { transformer = TO_STRING ; } else if ( arg instanceof Closure ) { transformer = createSAMTransform ( arg , parameter ) ; } else if ( Number . class . isAssignableFrom ( parameter ) ) { transformer = selectNumberTransformer ( parameter , arg ) ; } else if ( parameter . isArray ( ) ) { transformer = MethodHandles . insertArguments ( AS_ARRAY , 1 , parameter ) ; } if ( transformer == null ) throw new GroovyBugError ( "Unknown transformation for argument " + arg + " at position " + pos + " with " + arg . getClass ( ) + " for parameter of type " + parameter ) ; return applyUnsharpFilter ( handle , pos , transformer ) ; }
Adds a type transformer applied at runtime . This method handles transformations to String from GString array transformations and number based transformations