public class GrailsMetaClassUtils
extends java.lang.Object
| Constructor and Description |
|---|
GrailsMetaClassUtils() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
static groovy.lang.ExpandoMetaClass |
getExpandoMetaClass(java.lang.Class<?> aClass) |
static groovy.lang.MetaClass |
getMetaClass(java.lang.Object instance) |
static java.lang.Object |
getPropertyIfExists(java.lang.Object instance,
java.lang.String property)
Obtains a property of an instance if it exists
|
static <T> T |
getPropertyIfExists(java.lang.Object instance,
java.lang.String property,
java.lang.Class<T> requiredType)
Obtains a property of an instance if it exists
|
static groovy.lang.MetaClassRegistry |
getRegistry()
Retrieves the MetaClassRegistry instance.
|
static java.lang.Object |
invokeMethodIfExists(java.lang.Object instance,
java.lang.String methodName)
Invokes a method if it exists otherwise returns null
|
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
|
public static groovy.lang.MetaClassRegistry getRegistry()
public static void copyExpandoMetaClass(java.lang.Class<?> fromClass,
java.lang.Class<?> toClass,
boolean removeSource)
fromClass - The source classtoClass - The destination classremoveSource - Whether to remove the source class after completion. True if yespublic 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)
instance - The instanceproperty - The propertypublic static <T> T getPropertyIfExists(java.lang.Object instance,
java.lang.String property,
java.lang.Class<T> requiredType)
instance - The instanceproperty - The propertyrequiredType - The required type of the propertypublic static java.lang.Object invokeMethodIfExists(java.lang.Object instance,
java.lang.String methodName)
instance - The instancemethodName - The method namepublic static java.lang.Object invokeMethodIfExists(java.lang.Object instance,
java.lang.String methodName,
java.lang.Object[] args)
instance - The instancemethodName - The method nameargs - The arguments