Package: grails.util

## [Java] Class GrailsMetaClassUtils

- grails.util.GrailsMetaClassUtils

-     public class GrailsMetaClassUtils
      extends java.lang.Object

  Provides utility methods for working with the Groovy MetaClass API.

  Authors:
    Graeme Rocher
  Since:
    0.5

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static org.apache.commons.logging.Log` | `LOG` |
    `private static int` | `MAX_DELEGATE_LEVELS` |
    `private static java.lang.Object[]` | `NO_ARGS` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static void` | `copyExpandoMetaClass(java.lang.Class<?> fromClass, java.lang.Class<?> toClass, boolean removeSource)` Copies the ExpandoMetaClass dynamic methods and properties from one Class to another.
    `` | `public static groovy.lang.ExpandoMetaClass` | `getExpandoMetaClass(java.lang.Class<?> aClass)`
    `` | `public static groovy.lang.MetaClass` | `getMetaClass(java.lang.Object instance)`
    `` | `public static java.lang.Object` | `getPropertyIfExists(java.lang.Object instance, java.lang.String property)` Obtains a property of an instance if it exists
    `<T>` | `public static T` | `getPropertyIfExists(java.lang.Object instance, java.lang.String property, java.lang.Class<T> requiredType)` Obtains a property of an instance if it exists
    `` | `public static groovy.lang.MetaClassRegistry` | `getRegistry()` Retrieves the MetaClassRegistry instance.
    `` | `public static java.lang.Object` | `invokeMethodIfExists(java.lang.Object instance, java.lang.String methodName)` Invokes a method if it exists otherwise returns null
    `` | `public static java.lang.Object` | `invokeMethodIfExists(java.lang.Object instance, java.lang.String methodName, java.lang.Object[] args)` Invokes a method if it exists otherwise returns null
    `` | `private static groovy.lang.MetaClass` | `unwrapDelegatingMetaClass(groovy.lang.MetaClass metaClass)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### private static final org.apache.commons.logging.Log LOG

    - #### private static final int MAX_DELEGATE_LEVELS

    - #### private static final java.lang.Object[] NO_ARGS

  - ### Method Detail

    - #### @java.lang.SuppressWarnings({ "unchecked", "rawtypes" }) public static void copyExpandoMetaClass(java.lang.Class<?> fromClass, java.lang.Class<?> toClass, boolean removeSource)

      Copies the ExpandoMetaClass dynamic methods and properties from one Class to another.

      Parameters:
        `fromClass` - The source class
        `toClass` - The destination class
        `removeSource` - Whether to remove the source class after completion. True if yes

    - #### public static groovy.lang.ExpandoMetaClass getExpandoMetaClass(java.lang.Class<?> aClass)

    - #### public static groovy.lang.MetaClass getMetaClass(java.lang.Object instance)

    - #### public static java.lang.Object getPropertyIfExists(java.lang.Object instance, java.lang.String property)

      Obtains a property of an instance if it exists

      Parameters:
        `instance` - The instance
        `property` - The property
      Returns:
        The value of null if non-exists

    - #### <T> @java.lang.SuppressWarnings("unchecked") public static T getPropertyIfExists(java.lang.Object instance, java.lang.String property, java.lang.Class<T> requiredType)

      Obtains a property of an instance if it exists

      Parameters:
        `instance` - The instance
        `property` - The property
        `requiredType` - The required type of the property
      Returns:
        The property value

    - #### public static groovy.lang.MetaClassRegistry getRegistry()

      Retrieves the MetaClassRegistry instance.

      Returns:
        The registry

    - #### public static java.lang.Object invokeMethodIfExists(java.lang.Object instance, java.lang.String methodName)

      Invokes a method if it exists otherwise returns null

      Parameters:
        `instance` - The instance
        `methodName` - The method name
      Returns:
        The result of the method call or null

    - #### public static java.lang.Object invokeMethodIfExists(java.lang.Object instance, java.lang.String methodName, java.lang.Object[] args)

      Invokes a method if it exists otherwise returns null

      Parameters:
        `instance` - The instance
        `methodName` - The method name
        `args` - The arguments
      Returns:
        The result of the method call or null

    - #### private static groovy.lang.MetaClass unwrapDelegatingMetaClass(groovy.lang.MetaClass metaClass)