|
Griffon 0.9.5-rc2 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgriffon.util.GriffonClassUtils
public final class GriffonClassUtils extends Object
Class containing utility methods for dealing with Griffon class artifacts.
Contains utility methods copied from commons-lang and commons-beanutils in order to reduce dependencies on external libraries.
Contains code copied from commons-beanutils and commons-langs
Nested Class Summary | |
---|---|
static class |
GriffonClassUtils.MethodDescriptor
|
Constructor Summary | |
GriffonClassUtils()
|
Method Summary | |
---|---|
private static void
|
addAbbreviation(String primitive, String abbreviation)
Add primitive type abbreviation to maps of abbreviations. |
static Object[]
|
collectionToObjectArray(Collection c)
Convenience method for converting a collection to an Object[] |
private static String
|
convertPropertyName(String prop)
|
static Collection
|
createConcreteCollection(Class interfaceType)
Creates a concrete collection for the suppied interface |
private static Method
|
findDeclaredMethod(Class clazz, String methodName, Class[] parameterTypes)
|
static String
|
findPropertyNameForValue(Object target, Object obj)
Locates the name of a property for the given value on the target object using Groovy's meta APIs. |
static boolean
|
getBooleanFromMap(String key, Map map)
Retrieves a boolean value from a Map for the given key |
static MetaClass
|
getExpandoMetaClass(Class clazz)
|
static Object
|
getFieldValue(Object obj, String name)
Get the value of a declared field on an object |
static String
|
getGetterName(String propertyName)
Calculate the name for a getter method to retrieve the specified property |
static String
|
getPackageName(Object object, String valueIfNull)
|
static String
|
getPackageName(Class cls)
|
static String
|
getPackageName(String className)
|
static PropertyDescriptor[]
|
getPropertiesAssignableToType(Class clazz, Class propertySuperType)
Retrieves all the properties of the given class which are assignable to the given type |
static PropertyDescriptor[]
|
getPropertiesOfType(Class clazz, Class propertyType)
Retrieves all the properties of the given class for the given type |
static PropertyDescriptor
|
getProperty(Class clazz, String propertyName, Class propertyType)
Retrieves a property of the given class of the specified name and type |
static Object
|
getProperty(Object bean, String name)
Return the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions. |
static PropertyDescriptor
|
getPropertyDescriptor(Object bean, String name)
|
static PropertyDescriptor
|
getPropertyDescriptor(Class clazz, String name)
|
static PropertyDescriptor
|
getPropertyDescriptorForValue(Object instance, Object propertyValue)
Retrieves a PropertyDescriptor for the specified instance and property value |
static PropertyDescriptor[]
|
getPropertyDescriptors(Class beanClass)
|
static String
|
getPropertyForGetter(String getterName)
Returns a property name equivalent for the given getter name or null if it is not a getter |
static String
|
getPropertyForSetter(String setterName)
Returns a property name equivalent for the given setter name or null if it is not a getter |
static Object
|
getPropertyOrStaticPropertyOrFieldValue(Object obj, String name)
|
static Class
|
getPropertyType(Class clazz, String propertyName)
Returns the type of the given property contained within the specified class |
static Object
|
getPropertyValueOfNewInstance(Class clazz, String propertyName, Class propertyType)
Returns the value of the specified property and type from an instance of the specified Griffon class |
static Object
|
getPropertyValueOfNewInstance(Class clazz, String propertyName)
Returns the value of the specified property and type from an instance of the specified Griffon class |
static Method
|
getReadMethod(PropertyDescriptor descriptor)
|
static Method
|
getReadMethod(Class clazz, PropertyDescriptor descriptor)
|
static String
|
getSetterName(String propertyName)
Retrieves the name of a setter for the specified property name |
static String
|
getShortClassName(Object object, String valueIfNull)
Feed abbreviation maps |
static String
|
getShortClassName(Class cls)
|
static String
|
getShortClassName(String className)
|
static Object
|
getStaticPropertyValue(Class clazz, String name)
|
static Object
|
instantiate(Class clazz, Object[] args)
|
static Object
|
instantiateClass(Class clazz)
Instantiates a Class, wrapping any exceptions in a RuntimeException. |
static Object
|
invokeExactInstanceMethod(Object object, String methodName)
|
static Object
|
invokeExactInstanceMethod(Object object, String methodName, Object arg)
|
static Object
|
invokeExactInstanceMethod(Object object, String methodName, Object... args)
|
static Object
|
invokeExactStaticMethod(Class type, String methodName)
|
static Object
|
invokeExactStaticMethod(Class type, String methodName, Object arg)
|
static Object
|
invokeExactStaticMethod(Class type, String methodName, Object... args)
|
static Object
|
invokeInstanceMethod(Object object, String methodName)
|
static Object
|
invokeInstanceMethod(Object object, String methodName, Object arg)
|
static Object
|
invokeInstanceMethod(Object object, String methodName, Object... args)
|
static Object
|
invokeStaticMethod(Class type, String methodName)
|
static Object
|
invokeStaticMethod(Class type, String methodName, Object arg)
|
static Object
|
invokeStaticMethod(Class type, String methodName, Object... args)
|
static boolean
|
isAssignableOrConvertibleFrom(Class clazz, Class type)
Returns true if the specified clazz parameter is either the same as, or is a superclass or superinterface of, the specified type parameter. |
static boolean
|
isBasicMethod(Method method)
Finds out if the given Method belongs either to the Object class or the GroovyObject class. |
static boolean
|
isBasicMethod(MetaMethod method)
Finds out if the given MetaMethod belongs either to the Object class or the GroovyObject class. |
static boolean
|
isBasicMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor belongs either to the Object class or the GroovyObject class. |
static boolean
|
isClassBelowPackage(Class theClass, List packageList)
Returns whether the specified class is either within one of the specified packages or within a subpackage of one of the packages |
static boolean
|
isEventHandler(String name)
Finds out if the given string represents the name of an event handler by matching against the following pattern: "^on[A-Z][\\w]*$" |
static boolean
|
isEventHandler(Method method)
Finds out if the given Method represents an event handler by matching its name against the following pattern: "^on[A-Z][\\w]*$" |
static boolean
|
isEventHandler(MetaMethod method)
Finds out if the given Method represents an event handler by matching its name against the following pattern: "^on[A-Z][\\w]*$" |
static boolean
|
isEventHandler(GriffonClassUtils.MethodDescriptor method)
Finds out if the given Method represents an event handler by matching its name against the following pattern: "^on[A-Z][\\w]*$" |
static boolean
|
isEventPublisherMethod(Method method)
Finds out if the given Method belongs to the set of predefined EVENT_PUBLISHER methods by convention. |
static boolean
|
isEventPublisherMethod(MetaMethod method)
Finds out if the given MetaMethod belongs to the set of predefined EVENT_PUBLISHER methods by convention. |
static boolean
|
isEventPublisherMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor belongs to the set of predefined EVENT_PUBLISHER methods by convention. |
static boolean
|
isGetter(MetaProperty property)
|
static boolean
|
isGetter(MetaProperty property, boolean strict)
|
static boolean
|
isGetter(String name, Class[] args)
Returns true if the name of the method specified and the number of arguments make it a javabean property |
static boolean
|
isGetterMethod(Method method)
Finds out if the given Method is a getter method. |
static boolean
|
isGetterMethod(MetaMethod method)
Finds out if the given MetaMethod is a getter method. |
static boolean
|
isGetterMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MetaMethod is a getter method. |
static boolean
|
isGroovyAssignableFrom(Class leftType, Class rightType)
|
static boolean
|
isGroovyInjectedMethod(Method method)
Finds out if the given Method was injected by the Groovy compiler. |
static boolean
|
isGroovyInjectedMethod(MetaMethod method)
Finds out if the given MetaMethod was injected by the Groovy compiler. |
static boolean
|
isGroovyInjectedMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor was injected by the Groovy compiler. |
static boolean
|
isInstanceMethod(Method method)
Finds out if the given Method is an instance method, i.e, it is public and non-static. |
static boolean
|
isInstanceMethod(MetaMethod method)
Finds out if the given MetaMethod is an instance method, i.e, it is public and non-static. |
static boolean
|
isInstanceMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor is an instance method, i.e, it is public and non-static. |
static boolean
|
isMatchBetweenPrimitiveAndWrapperTypes(Class leftType, Class rightType)
Detect if left and right types are matching types. |
static boolean
|
isMvcMethod(Method method)
Finds out if the given Method belongs to the set of predefined MVC methods by convention. |
static boolean
|
isMvcMethod(MetaMethod method)
Finds out if the given MetaMethod belongs to the set of predefined MVC methods by convention. |
static boolean
|
isMvcMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor belongs to the set of predefined MVC methods by convention. |
static boolean
|
isObservableMethod(Method method)
Finds out if the given Method belongs to the set of predefined OBSERVABLE methods by convention. |
static boolean
|
isObservableMethod(MetaMethod method)
Finds out if the given MetaMethod belongs to the set of predefined OBSERVABLE methods by convention. |
static boolean
|
isObservableMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor belongs to the set of predefined OBSERVABLE methods by convention. |
static boolean
|
isPlainMethod(Method method)
Finds out if the given Method matches the following criteria:
|
static boolean
|
isPlainMethod(MetaMethod method)
Finds out if the given MetaMethod matches the following criteria:
|
static boolean
|
isPlainMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor matches the following criteria:
|
static boolean
|
isPropertyInherited(Class clz, String propertyName)
Checks whether the specified property is inherited from a super class |
static boolean
|
isPropertyOfType(Class clazz, String propertyName, Class type)
Returns true if the specified property in the specified class is of the specified type |
static boolean
|
isPublicField(Object obj, String name)
Work out if the specified object has a public field with the name supplied. |
static boolean
|
isPublicStatic(Method m)
Determine whether the method is declared public static |
static boolean
|
isPublicStatic(Field f)
Determine whether the field is declared public static |
static boolean
|
isReadable(Object bean, String name)
|
static boolean
|
isSetter(MetaProperty property)
|
static boolean
|
isSetter(String name, Class[] args)
|
static boolean
|
isSetterMethod(Method method)
Finds out if the given Method is a setter method. |
static boolean
|
isSetterMethod(MetaMethod method)
Finds out if the given MetaMethod is a setter method. |
static boolean
|
isSetterMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor is a setter method. |
static boolean
|
isStaticProperty(Class clazz, String propertyName)
|
static boolean
|
isThreadingMethod(Method method)
Finds out if the given Method belongs to the set of predefined threading methods by convention. |
static boolean
|
isThreadingMethod(MetaMethod method)
Finds out if the given MetaMethod belongs to the set of predefined threading methods by convention. |
static boolean
|
isThreadingMethod(GriffonClassUtils.MethodDescriptor method)
Finds out if the given MethodDescriptor belongs to the set of predefined threading methods by convention. |
static void
|
isTrue(boolean expression, String message)
|
private static boolean
|
isTypeInstanceOfPropertyType(Class type, Class propertyType)
|
private static void
|
registerPrimitiveClassPair(Class left, Class right)
Just add two entries to the class compatibility map |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
private static final Set BASIC_METHODS
public static final Object[] EMPTY_ARGS
public static final Class[] EMPTY_CLASS_ARRAY
public static final Object[] EMPTY_OBJECT_ARRAY
private static final String EMPTY_STRING
public static final Class[] EMPTY_TYPES
private static final Pattern EVENT_HANDLER_PATTERN
private static final Set EVENT_PUBLISHER_METHODS
private static final Pattern GETTER_PATTERN_1
private static final Pattern GETTER_PATTERN_2
public static final String INNER_CLASS_SEPARATOR
The inner class separator String: "$"
.
public static final char INNER_CLASS_SEPARATOR_CHAR
The inner class separator character: '$' == {@value}
.
private static final Set MVC_METHODS
private static final Set OBSERVABLE_METHODS
public static final String PACKAGE_SEPARATOR
The package separator String: "."
.
public static final char PACKAGE_SEPARATOR_CHAR
The package separator character: '.' == {@value}
.
public static final Map PRIMITIVE_TYPE_COMPATIBLE_CLASSES
private static final String PROPERTY_GET_PREFIX
private static final String PROPERTY_IS_PREFIX
private static final String PROPERTY_SET_PREFIX
private static final Pattern SETTER_PATTERN
private static final Set THREADING_METHODS
private static final Map abbreviationMap
private static final Map descriptorsCache
private static final Map reverseAbbreviationMap
Constructor Detail |
---|
GriffonClassUtils()
Method Detail |
---|
private static void addAbbreviation(String primitive, String abbreviation)
primitive
- Canonical name of primitive typeabbreviation
- Corresponding abbreviation of primitive type
public static Object[] collectionToObjectArray(Collection c)
c
- The collection
private static String convertPropertyName(String prop)
public static Collection createConcreteCollection(Class interfaceType)
interfaceType
- The interface
private static Method findDeclaredMethod(Class clazz, String methodName, Class[] parameterTypes)
public static String findPropertyNameForValue(Object target, Object obj)
target
- The targetobj
- The property value
public static boolean getBooleanFromMap(String key, Map map)
key
- The key that references the boolean valuemap
- The map to look in
public static MetaClass getExpandoMetaClass(Class clazz)
public static Object getFieldValue(Object obj, String name)
public static String getGetterName(String propertyName)
public static String getPackageName(Object object, String valueIfNull)
Gets the package name of an Object
.
object
- the class to get the package name for, may be nullvalueIfNull
- the value to return if null
public static String getPackageName(Class cls)
Gets the package name of a Class
.
cls
- the class to get the package name for, may be null
.
public static String getPackageName(String className)
Gets the package name from a String
.
The string passed in is assumed to be a class name - it is not checked.
If the class is unpackaged, return an empty string.
className
- the className to get the package name for, may be null
public static PropertyDescriptor[] getPropertiesAssignableToType(Class clazz, Class propertySuperType)
clazz
- The class to retrieve the properties frompropertySuperType
- The type of the properties you wish to retrieve
public static PropertyDescriptor[] getPropertiesOfType(Class clazz, Class propertyType)
clazz
- The class to retrieve the properties frompropertyType
- The type of the properties you wish to retrieve
public static PropertyDescriptor getProperty(Class clazz, String propertyName, Class propertyType)
clazz
- The class to retrieve the property frompropertyName
- The name of the propertypropertyType
- The type of the property
public static Object getProperty(Object bean, String name)
bean
or
name
is nullbean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property
to be extracted
public static PropertyDescriptor getPropertyDescriptor(Object bean, String name)
Retrieve the property descriptor for the specified property of the
specified bean, or return null
if there is no such
descriptor.
bean
or
name
is nullbean
- Bean for which a property descriptor is requestedname
- name of the property for which a property descriptor
is requested
public static PropertyDescriptor getPropertyDescriptor(Class clazz, String name)
Retrieve the property descriptor for the specified property of the
specified class, or return null
if there is no such
descriptor.
bean
or
name
is nullclazz
- class for which a property descriptor is requestedname
- name of the property for which a property descriptor
is requested
public static PropertyDescriptor getPropertyDescriptorForValue(Object instance, Object propertyValue)
instance
- The instancepropertyValue
- The value of the property
public static PropertyDescriptor[] getPropertyDescriptors(Class beanClass)
Retrieve the property descriptors for the specified class, introspecting and caching them the first time a particular bean class is encountered.
beanClass
is nullbeanClass
- Bean class for which property descriptors are requested
public static String getPropertyForGetter(String getterName)
getterName
- The getter name
public static String getPropertyForSetter(String setterName)
setterName
- The setter name
public static Object getPropertyOrStaticPropertyOrFieldValue(Object obj, String name)
Looks for a property of the reference instance with a given name.
If found its value is returned. We follow the Java bean conventions with augmentation for groovy support and static fields/properties. We will therefore match, in this order:
public static Class getPropertyType(Class clazz, String propertyName)
clazz
- The class which contains the propertypropertyName
- The name of the property
public static Object getPropertyValueOfNewInstance(Class clazz, String propertyName, Class propertyType)
clazz
- The name of the class which contains the propertypropertyName
- The property namepropertyType
- The property type
public static Object getPropertyValueOfNewInstance(Class clazz, String propertyName)
clazz
- The name of the class which contains the propertypropertyName
- The property name
public static Method getReadMethod(PropertyDescriptor descriptor)
Return an accessible property getter method for this property,
if there is one; otherwise return null
.
descriptor
- Property descriptor to return a getter for
public static Method getReadMethod(Class clazz, PropertyDescriptor descriptor)
Return an accessible property getter method for this property,
if there is one; otherwise return null
.
clazz
- The class of the read method will be invoked ondescriptor
- Property descriptor to return a getter for
public static String getSetterName(String propertyName)
propertyName
- The property name
public static String getShortClassName(Object object, String valueIfNull)
public static String getShortClassName(Class cls)
Gets the class name minus the package name from a Class
.
cls
- the class to get the short name for.
public static String getShortClassName(String className)
Gets the class name minus the package name from a String.
The string passed in is assumed to be a class name - it is not checked.
className
- the className to get the short name for
public static Object getStaticPropertyValue(Class clazz, String name)
Get a static property value, which has a public static getter or is just a public static field.
clazz
- The class to check for static propertyname
- The property name
public static Object instantiate(Class clazz, Object[] args)
public static Object instantiateClass(Class clazz)
clazz
- target Class for which an object will be instantiated
public static Object invokeExactInstanceMethod(Object object, String methodName)
public static Object invokeExactInstanceMethod(Object object, String methodName, Object arg)
public static Object invokeExactInstanceMethod(Object object, String methodName, Object... args)
public static Object invokeExactStaticMethod(Class type, String methodName)
public static Object invokeExactStaticMethod(Class type, String methodName, Object arg)
public static Object invokeExactStaticMethod(Class type, String methodName, Object... args)
public static Object invokeInstanceMethod(Object object, String methodName)
public static Object invokeInstanceMethod(Object object, String methodName, Object arg)
public static Object invokeInstanceMethod(Object object, String methodName, Object... args)
public static Object invokeStaticMethod(Class type, String methodName)
public static Object invokeStaticMethod(Class type, String methodName, Object arg)
public static Object invokeStaticMethod(Class type, String methodName, Object... args)
public static boolean isAssignableOrConvertibleFrom(Class clazz, Class type)
public static boolean isBasicMethod(Method method)
method
- a Method reference
public static boolean isBasicMethod(MetaMethod method)
method
- a MetaMethod reference
public static boolean isBasicMethod(GriffonClassUtils.MethodDescriptor method)
method
- a MethodDescriptor reference
public static boolean isClassBelowPackage(Class theClass, List packageList)
theClass
- The classpackageList
- The list of packages
public static boolean isEventHandler(String name)
GriffonClassUtils.isEventHandler("onBootstrapEnd") = true GriffonClassUtils.isEventHandler("mvcGroupInit") = false GriffonClassUtils.isEventHandler("online") = false
name
- the name of a possible event handler
public static boolean isEventHandler(Method method)
GriffonClassUtils.isEventHandler("onBootstrapEnd") = true GriffonClassUtils.isEventHandler("mvcGroupInit") = false GriffonClassUtils.isEventHandler("online") = false
method
- a Method reference
public static boolean isEventHandler(MetaMethod method)
GriffonClassUtils.isEventHandler("onBootstrapEnd") = true GriffonClassUtils.isEventHandler("mvcGroupInit") = false GriffonClassUtils.isEventHandler("online") = false
method
- a MetaMethod reference
public static boolean isEventHandler(GriffonClassUtils.MethodDescriptor method)
GriffonClassUtils.isEventHandler("onBootstrapEnd") = true GriffonClassUtils.isEventHandler("mvcGroupInit") = false GriffonClassUtils.isEventHandler("online") = false
method
- a MethodDescriptor reference
public static boolean isEventPublisherMethod(Method method)
// assuming getMethod() returns an appropriate Method reference isEventPublisherMethod(getMethod("addEventPublisher")) = true isEventPublisherMethod(getMethod("publishEvent")) = true isEventPublisherMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isEventPublisherMethod(MetaMethod method)
// assuming getMethod() returns an appropriate MetaMethod reference isEventPublisherMethod(getMethod("addEventPublisher")) = true isEventPublisherMethod(getMethod("publishEvent")) = true isEventPublisherMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isEventPublisherMethod(GriffonClassUtils.MethodDescriptor method)
// assuming getMethod() returns an appropriate MethodDescriptor reference isEventPublisherMethod(getMethod("addEventPublisher")) = true isEventPublisherMethod(getMethod("publishEvent")) = true isEventPublisherMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isGetter(MetaProperty property)
public static boolean isGetter(MetaProperty property, boolean strict)
public static boolean isGetter(String name, Class[] args)
name
- True if its a Javabean propertyargs
- The arguments
public static boolean isGetterMethod(Method method)
// assuming getMethod() returns an appropriate Method reference isGetterMethod(getMethod("getFoo")) = true isGetterMethod(getMethod("getfoo") ) = false isGetterMethod(getMethod("mvcGroupInit")) = false isGetterMethod(getMethod("isFoo")) = true isGetterMethod(getMethod("island")) = false
method
- a Method reference
public static boolean isGetterMethod(MetaMethod method)
// assuming getMethod() returns an appropriate MetaMethod reference isGetterMethod(getMethod("getFoo")) = true isGetterMethod(getMethod("getfoo") ) = false isGetterMethod(getMethod("mvcGroupInit")) = false isGetterMethod(getMethod("isFoo")) = true isGetterMethod(getMethod("island")) = false
method
- a Method reference
public static boolean isGetterMethod(GriffonClassUtils.MethodDescriptor method)
// assuming getMethod() returns an appropriate MethodDescriptor reference isGetterMethod(getMethod("getFoo")) = true isGetterMethod(getMethod("getfoo") ) = false isGetterMethod(getMethod("mvcGroupInit")) = false isGetterMethod(getMethod("isFoo")) = true isGetterMethod(getMethod("island")) = false
method
- a MethodDescriptor reference
public static boolean isGroovyAssignableFrom(Class leftType, Class rightType)
Tests whether or not the left hand type is compatible with the right hand type in Groovy terms, i.e. can the left type be assigned a value of the right hand type in Groovy.
This handles Java primitive type equivalence and uses isAssignableFrom for all other types, with a bit of magic for native types and polymorphism i.e. Number assigned an int. If either parameter is null an exception is thrown
leftType
- The type of the left hand part of a notional assignmentrightType
- The type of the right hand part of a notional assignment
public static boolean isGroovyInjectedMethod(Method method)
Performs a basic checks against the method's name, returning true if the name starts with either "super$" or "this$".
method
- a Method reference
public static boolean isGroovyInjectedMethod(MetaMethod method)
Performs a basic checks against the method's name, returning true if the name starts with either "super$" or "this$".
method
- a MetaMethod reference
public static boolean isGroovyInjectedMethod(GriffonClassUtils.MethodDescriptor method)
Performs a basic checks against the method's name, returning true if the name starts with either "super$" or "this$".
method
- a MethodDescriptor reference
public static boolean isInstanceMethod(Method method)
method
- a Method reference
public static boolean isInstanceMethod(MetaMethod method)
method
- a MetaMethod reference
public static boolean isInstanceMethod(GriffonClassUtils.MethodDescriptor method)
method
- a MethodDescriptor reference
public static boolean isMatchBetweenPrimitiveAndWrapperTypes(Class leftType, Class rightType)
public static boolean isMvcMethod(Method method)
// assuming getMethod() returns an appropriate Method reference isMvcMethod(getMethod("mvcGroupInit")) = true isMvcMethod(getMethod("mvcGroupDestroy")) = true isMvcMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isMvcMethod(MetaMethod method)
// assuming getMethod() returns an appropriate MetaMethod reference isMvcMethod(getMethod("mvcGroupInit")) = true isMvcMethod(getMethod("mvcGroupDestroy")) = true isMvcMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isMvcMethod(GriffonClassUtils.MethodDescriptor method)
// assuming getMethod() returns an appropriate MethodDescriptor reference isMvcMethod(getMethod("mvcGroupInit")) = true isMvcMethod(getMethod("mvcGroupDestroy")) = true isMvcMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isObservableMethod(Method method)
// assuming getMethod() returns an appropriate Method reference isObservableMethod(getMethod("addPropertyChangeListener")) = true isObservableMethod(getMethod("getPropertyChangeListeners")) = true isObservableMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isObservableMethod(MetaMethod method)
// assuming getMethod() returns an appropriate MetaMethod reference isObservableMethod(getMethod("addPropertyChangeListener")) = true isObservableMethod(getMethod("getPropertyChangeListeners")) = true isObservableMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isObservableMethod(GriffonClassUtils.MethodDescriptor method)
// assuming getMethod() returns an appropriate MethodDescriptor reference isObservableMethod(getMethod("addPropertyChangeListener")) = true isObservableMethod(getMethod("getPropertyChangeListeners")) = true isObservableMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isPlainMethod(Method method)
method
- a Method reference
public static boolean isPlainMethod(MetaMethod method)
method
- a Method reference
public static boolean isPlainMethod(GriffonClassUtils.MethodDescriptor method)
method
- a MethodDescriptor reference
public static boolean isPropertyInherited(Class clz, String propertyName)
clz
- The class to checkpropertyName
- The property name
public static boolean isPropertyOfType(Class clazz, String propertyName, Class type)
clazz
- The class which contains the propertypropertyName
- The property nametype
- The type to check
public static boolean isPublicField(Object obj, String name)
public static boolean isPublicStatic(Method m)
public static boolean isPublicStatic(Field f)
public static boolean isReadable(Object bean, String name)
Return true
if the specified property name identifies
a readable property on the specified bean; otherwise, return
false
.
bean
or name
is null
bean
- Bean to be examinedname
- Property name to be evaluatedtrue
if the property is readable,
otherwise false
public static boolean isSetter(MetaProperty property)
public static boolean isSetter(String name, Class[] args)
public static boolean isSetterMethod(Method method)
// assuming getMethod() returns an appropriate Method reference isGetterMethod(getMethod("setFoo")) = true isGetterMethod(getMethod("setfoo")) = false isGetterMethod(getMethod("mvcGroupInit")) = false
method
- a Method reference
public static boolean isSetterMethod(MetaMethod method)
// assuming getMethod() returns an appropriate MetaMethod reference isGetterMethod(getMethod("setFoo")) = true isGetterMethod(getMethod("setfoo")) = false isGetterMethod(getMethod("mvcGroupInit")) = false
method
- a MetaMethod reference
public static boolean isSetterMethod(GriffonClassUtils.MethodDescriptor method)
// assuming getMethod() returns an appropriate MethodDescriptor reference isGetterMethod(getMethod("setFoo")) = true isGetterMethod(getMethod("setfoo")) = false isGetterMethod(getMethod("mvcGroupInit")) = false
method
- a MethodDescriptor reference
public static boolean isStaticProperty(Class clazz, String propertyName)
Work out if the specified property is readable and static. Java introspection does not recognize this concept of static properties but Groovy does. We also consider public static fields as static properties with no getters/setters
clazz
- The class to check for static propertypropertyName
- The property name
public static boolean isThreadingMethod(Method method)
// assuming getMethod() returns an appropriate Method reference isThreadingMethod(getMethod("execOutside")) = true isThreadingMethod(getMethod("doLater")) = true isThreadingMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isThreadingMethod(MetaMethod method)
// assuming getMethod() returns an appropriate MetaMethod reference isThreadingMethod(getMethod("execOutside")) = true isThreadingMethod(getMethod("doLater")) = true isThreadingMethod(getMethod("foo")) = false
method
- a Method reference
public static boolean isThreadingMethod(GriffonClassUtils.MethodDescriptor method)
// assuming getMethod() returns an appropriate MethodDescriptor reference isThreadingMethod(getMethod("execOutside")) = true isThreadingMethod(getMethod("doLater")) = true isThreadingMethod(getMethod("foo")) = false
method
- a Method reference
public static void isTrue(boolean expression, String message)
Validate that the argument condition is true
; otherwise
throwing an exception with the specified message. This method is useful when
validating according to an arbitrary boolean expression, such as validating a
primitive number or using your own custom validation expression.
isTrue( (i > 0), "The value must be greater than zero"); isTrue( myObject.isOk(), "The object is not OK");
false
expression
- the boolean expression to checkmessage
- the exception message if invalid
private static boolean isTypeInstanceOfPropertyType(Class type, Class propertyType)
private static void registerPrimitiveClassPair(Class left, Class right)
Groovy Documentation