Package: org.codehaus.groovy.runtime

## [Java] Class InvokerHelper

- org.codehaus.groovy.runtime.InvokerHelper

-     public class InvokerHelper
      extends Object

  A static helper class to make bytecode generation easier and act as a facade over the Invoker

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static Object[]` | `EMPTY_ARGS` |
    `protected static Object[]` | `EMPTY_ARGUMENTS` |
    `protected static Class[]` | `EMPTY_TYPES` |
    `static String` | `MAIN_METHOD_NAME` |
    `static MetaClassRegistry` | `metaRegistry` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static void` | `append(Appendable out, Object object)`
    `` | `public static Object[]` | `asArray(Object arguments)` Converts the given object into an array; if it's an array then just cast otherwise wrap it in an array
    `` | `public static Iterator<Object>` | `asIterator(Object o)`
    `` | `public static List` | `asList(Object value)`
    `` | `public static Object[]` | `asUnwrappedArray(Object arguments)`
    `` | `public static void` | `assertFailed(Object expression, Object message)`
    `` | `public static Object` | `bitwiseNegate(Object value)`
    `` | `public static AssertionError` | `createAssertError(Object expression, Object message)` Since: 4.0.7
    `` | `public static List` | `createList(Object[] values)`
    `` | `public static Map` | `createMap(Object[] values)`
    `` | `public static List` | `createRange(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight)`
    `` | `public static List` | `createRange(Object from, Object to, boolean inclusive)`
    `` | `public static Script` | `createScript(Class scriptClass, Binding context)`
    `` | `public static Tuple` | `createTuple(Object[] array)`
    `` | `public static String` | `escapeBackslashes(String orig)`
    `` | `public static Matcher` | `findRegex(Object left, Object right)` Find the right hand regex within the left hand string and return a matcher.
    `` | `protected static String` | `format(Object arguments, boolean verbose)`
    `` | `public static String` | `format(Object arguments, boolean verbose, int maxSize)`
    `` | `public static String` | `format(Object arguments, boolean verbose, int maxSize, boolean safe)`
    `` | `public static Object` | `getAttribute(Object object, String attribute)`
    `` | `public static Object` | `getGroovyObjectProperty(GroovyObject object, String property)`
    `` | `public static MetaClass` | `getMetaClass(Object object)`
    `` | `public static MetaClass` | `getMetaClass(Class cls)`
    `` | `public static MetaClassRegistry` | `getMetaRegistry()`
    `` | `public static Closure` | `getMethodPointer(Object object, String methodName)` Returns a method closure for the given object and name.
    `` | `public static Object` | `getProperty(Object object, String property)`
    `` | `public static Object` | `getPropertySafe(Object object, String property)`
    `` | `public static int` | `initialCapacity(int initialEntryCnt)` According to the initial entry count, calculate the initial capacity of hash map, which is power of 2 (SEE https://stackoverflow.com/questions/8352378/why-does-hashmap-require-that-the-initial-capacity-be-a-power-of-two)
    `` | `public static String` | `inspect(Object self)`
    `` | `public static Object` | `invokeClosure(Object closure, Object arguments)`
    `` | `public static Object` | `invokeConstructorOf(String klass, Object arguments)`
    `` | `public static Object` | `invokeConstructorOf(Class type, Object arguments)`
    `` | `public static Object` | `invokeMethod(Object object, String methodName, Object arguments)` Invokes the given method on the object.
    `` | `public static Object` | `invokeMethodSafe(Object object, String methodName, Object arguments)`
    `` | `public static Object` | `invokeNoArgumentsConstructorOf(Class type)`
    `` | `public static Object` | `invokeStaticMethod(String klass, String methodName, Object arguments)`
    `` | `public static Object` | `invokeStaticMethod(Class type, String method, Object arguments)`
    `` | `public static Object` | `invokeStaticNoArgumentsMethod(Class type, String methodName)`
    `` | `public static Object` | `invokeSuperMethod(Object object, String methodName, Object arguments)`
    `` | `public static boolean` | `matchRegex(Object left, Object right)` Find the right hand regex within the left hand string and return a matcher.
    `` | `public static Script` | `newScript(Class<? extends Script> scriptClass, Binding context)`
    `` | `public static void` | `removeClass(Class clazz)`
    `` | `public Object` | `run()`
    `` | `public Object` | `run()`
    `` | `public static Object` | `runScript(Class scriptClass, String[] args)`
    `` | `public static void` | `setAttribute(Object object, String attribute, Object newValue)`
    `` | `public static void` | `setGroovyObjectProperty(Object newValue, GroovyObject object, String property)` This is so we don't have to reorder the stack when we call this method.
    `` | `public static void` | `setProperties(Object object, Map map)` Sets the properties on the given object
    `` | `public static void` | `setProperty(Object object, String property, Object newValue)`
    `` | `public static void` | `setProperty2(Object newValue, Object object, String property)` This is so we don't have to reorder the stack when we call this method.
    `` | `public static void` | `setPropertySafe2(Object newValue, Object object, String property)` This is so we don't have to reorder the stack when we call this method.
    `` | `public static SpreadMap` | `spreadMap(Object value)`
    `` | `public static String` | `toArrayString(Object[] arguments)`
    `` | `public static String` | `toArrayString(Object[] arguments, int maxSize, boolean safe)`
    `` | `public static String` | `toListString(Collection arg)`
    `` | `public static String` | `toListString(Collection arg, int maxSize)`
    `` | `public static String` | `toListString(Collection arg, int maxSize, boolean safe)`
    `` | `public static String` | `toMapString(Map arg)`
    `` | `public static String` | `toMapString(Map arg, int maxSize)`
    `` | `public static String` | `toString(Object arguments)`
    `` | `public static String` | `toTypeString(Object[] arguments)`
    `` | `public static String` | `toTypeString(Object[] arguments, int maxSize)`
    `` | `public static Object` | `unaryMinus(Object value)`
    `` | `public static Object` | `unaryPlus(Object value)`
    `` | `public static void` | `write(Writer out, Object object)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final Object[] EMPTY_ARGS

    - #### protected static final Object[] EMPTY_ARGUMENTS

    - #### protected static final Class[] EMPTY_TYPES

    - #### public static final String MAIN_METHOD_NAME

    - #### public static final MetaClassRegistry metaRegistry

  - ### Method Detail

    - #### @Deprecated
      public static void append(Appendable out, Object object)

    - #### public static Object[] asArray(Object arguments)

      Converts the given object into an array; if it's an array then just cast otherwise wrap it in an array

    - #### @SuppressWarnings("unchecked")
      public static Iterator<Object> asIterator(Object o)

    - #### public static List asList(Object value)

    - #### public static Object[] asUnwrappedArray(Object arguments)

    - #### public static void assertFailed(Object expression, Object message)

    - #### public static Object bitwiseNegate(Object value)

    - #### public static AssertionError createAssertError(Object expression, Object message)

      Since:
        4.0.7

    - #### public static List createList(Object[] values)

    - #### public static Map createMap(Object[] values)

    - #### public static List createRange(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight)

    - #### public static List createRange(Object from, Object to, boolean inclusive)

    - #### @SuppressWarnings("unchecked")
      public static Script createScript(Class scriptClass, Binding context)

    - #### public static Tuple createTuple(Object[] array)

    - #### @Deprecated
      public static String escapeBackslashes(String orig)

    - #### public static Matcher findRegex(Object left, Object right)

      Find the right hand regex within the left hand string and return a matcher.

      Parameters:
        `left` - string to compare
        `right` - regular expression to compare the string to

    - #### @Deprecated
      protected static String format(Object arguments, boolean verbose)

    - #### @Deprecated
      public static String format(Object arguments, boolean verbose, int maxSize)

    - #### @Deprecated
      public static String format(Object arguments, boolean verbose, int maxSize, boolean safe)

    - #### public static Object getAttribute(Object object, String attribute)

    - #### public static Object getGroovyObjectProperty(GroovyObject object, String property)

    - #### public static MetaClass getMetaClass(Object object)

    - #### public static MetaClass getMetaClass(Class cls)

    - #### public static MetaClassRegistry getMetaRegistry()

    - #### @SuppressWarnings("rawtypes")
      public static Closure getMethodPointer(Object object, String methodName)

      Returns a method closure for the given object and name.

    - #### public static Object getProperty(Object object, String property)

    - #### public static Object getPropertySafe(Object object, String property)

    - #### public static int initialCapacity(int initialEntryCnt)

      According to the initial entry count, calculate the initial capacity of hash map, which is power of 2 (SEE https://stackoverflow.com/questions/8352378/why-does-hashmap-require-that-the-initial-capacity-be-a-power-of-two)

      Parameters:
        `initialEntryCnt` - the initial entry count
      Returns:
        the initial capacity

    - #### @Deprecated
      public static String inspect(Object self)

    - #### public static Object invokeClosure(Object closure, Object arguments)

    - #### public static Object invokeConstructorOf(String klass, Object arguments)

    - #### public static Object invokeConstructorOf(Class type, Object arguments)

    - #### public static Object invokeMethod(Object object, String methodName, Object arguments)

      Invokes the given method on the object.

    - #### public static Object invokeMethodSafe(Object object, String methodName, Object arguments)

    - #### public static Object invokeNoArgumentsConstructorOf(Class type)

    - #### public static Object invokeStaticMethod(String klass, String methodName, Object arguments)

    - #### public static Object invokeStaticMethod(Class type, String method, Object arguments)

    - #### public static Object invokeStaticNoArgumentsMethod(Class type, String methodName)

    - #### public static Object invokeSuperMethod(Object object, String methodName, Object arguments)

    - #### public static boolean matchRegex(Object left, Object right)

      Find the right hand regex within the left hand string and return a matcher.

      Parameters:
        `left` - string to compare
        `right` - regular expression to compare the string to

    - #### public static Script newScript(Class<? extends Script> scriptClass, Binding context)

    - #### public static void removeClass(Class clazz)

    - #### @Override
      public Object run()

    - #### @Override
      public Object run()

    - #### public static Object runScript(Class scriptClass, String[] args)

    - #### public static void setAttribute(Object object, String attribute, Object newValue)

    - #### public static void setGroovyObjectProperty(Object newValue, GroovyObject object, String property)

      This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order.

    - #### public static void setProperties(Object object, Map map)

      Sets the properties on the given object

    - #### public static void setProperty(Object object, String property, Object newValue)

    - #### public static void setProperty2(Object newValue, Object object, String property)

      This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order.

    - #### public static void setPropertySafe2(Object newValue, Object object, String property)

      This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order.

    - #### public static SpreadMap spreadMap(Object value)

    - #### @Deprecated
      public static String toArrayString(Object[] arguments)

    - #### @Deprecated
      public static String toArrayString(Object[] arguments, int maxSize, boolean safe)

    - #### @Deprecated
      public static String toListString(Collection arg)

    - #### @Deprecated
      public static String toListString(Collection arg, int maxSize)

    - #### @Deprecated
      public static String toListString(Collection arg, int maxSize, boolean safe)

    - #### @Deprecated
      public static String toMapString(Map arg)

    - #### @Deprecated
      public static String toMapString(Map arg, int maxSize)

    - #### @Deprecated
      public static String toString(Object arguments)

    - #### @Deprecated
      public static String toTypeString(Object[] arguments)

    - #### @Deprecated
      public static String toTypeString(Object[] arguments, int maxSize)

    - #### public static Object unaryMinus(Object value)

    - #### public static Object unaryPlus(Object value)

    - #### @Deprecated
      public static void write(Writer out, Object object)