Closure createClosure ( String rootMethodName , final Object closureObj ) throws Exception { if ( ! isClosureCommand ( closureObj ) ) { throw new RuntimeException ( format ( ERROR_TYPE_MESSAGE , rootMethodName , getClosureCommandType ( ) . getName ( ) ) . getMessage ( ) ) ; } Method closureMethod = closureObj . getClass ( ) . getMethod ( INVOKE_METHOD ) ; return new Closure ( closureMethod , closureObj ) ; }
Creates closure .