Package org.spockframework.runtime
Class GroovyRuntimeUtil
java.lang.Object
org.spockframework.runtime.GroovyRuntimeUtil
Provides convenient access to Groovy language and runtime features.
By convention, all usages of Groovy's InvokerHelper and
ScriptBytecodeAdapter go through this class.
- Author:
- Peter Niederwieser
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object[]
asArgumentArray
(Object args) Need to be careful because this converts null to an empty array.asArgumentList
(Object args) asIterator
(Object object) Note: This method may throw checked exceptions although it doesn't say so.static Object[]
static Object
static Object[]
despreadList
(Object[] args, Object[] spreads, int[] positions) static boolean
static Object
getAttribute
(Object target, String name) Note: This method may throw checked exceptions although it doesn't say so.static groovy.lang.MetaClass
getMetaClass
(Class<?> clazz) static groovy.lang.MetaClass
getMetaClass
(Object object) static Object
getProperty
(Object target, String property) Note: This method may throw checked exceptions although it doesn't say so.static String
getterMethodToPropertyName
(String methodName, List<Class<?>> parameterTypes, Class<?> returnType) Checks if the given method is a getter method according to Groovy rules.static Object
invokeClosure
(groovy.lang.Closure closure, Object... args) Note: This method may throw checked exceptions although it doesn't say so.static Object
invokeConstructor
(Class<?> clazz, Object... args) Note: This method may throw checked exceptions although it doesn't say so.static Object
invokeMethod
(Object target, String method, Object... args) Note: This method may throw checked exceptions although it doesn't say so.static Object
invokeMethodNullSafe
(Object target, String method, Object... args) static Object
invokeMethodQuietly
(Object target, String method, Object... args) static boolean
isPhysicalMethod
(groovy.lang.MetaMethod method, Class<?> targetClass) Tells whether the specified method is declared (in byte code) in the specified target class or one of its superclasses.static boolean
static boolean
isVoidMethod
(Object target, String method, Object... args) static String
propertyToMethodName
(String prefix, String propertyName) static void
setMetaClass
(Class<?> clazz, groovy.lang.MetaClass metaClass) static void
setMetaClass
(Object object, groovy.lang.MetaClass metaClass) static void
setProperty
(Object target, String property, Object value) Note: This method may throw checked exceptions although it doesn't say so.static String
-
Field Details
-
EMPTY_ARGUMENTS
-
-
Constructor Details
-
GroovyRuntimeUtil
public GroovyRuntimeUtil()
-
-
Method Details
-
isTruthy
-
coerce
-
equals
-
toString
-
getMetaClass
-
getMetaClass
-
setMetaClass
-
setMetaClass
-
propertyToMethodName
-
getterMethodToPropertyName
public static String getterMethodToPropertyName(String methodName, List<Class<?>> parameterTypes, Class<?> returnType) Checks if the given method is a getter method according to Groovy rules. If yes, the corresponding property name is returned. Otherwise, null is returned. This method differs from Groovy 1.6.8 in that the latter doesn't support the "is" prefix for static boolean properties; however, that seems more like a bug. See http://jira.codehaus.org/browse/GROOVY-4206 -
getProperty
Note: This method may throw checked exceptions although it doesn't say so. -
setProperty
Note: This method may throw checked exceptions although it doesn't say so. -
invokeConstructor
Note: This method may throw checked exceptions although it doesn't say so. -
invokeMethod
Note: This method may throw checked exceptions although it doesn't say so. -
invokeMethodNullSafe
-
invokeMethodQuietly
-
invokeClosure
Note: This method may throw checked exceptions although it doesn't say so. -
asIterator
Note: This method may throw checked exceptions although it doesn't say so. -
asUnwrappedArgumentArray
-
asArgumentArray
Need to be careful because this converts null to an empty array. For single arguments, new Object[] {arg} should therefore be used. -
asArgumentList
-
despreadList
-
isVoidMethod
-
getAttribute
Note: This method may throw checked exceptions although it doesn't say so. -
isPhysicalMethod
Tells whether the specified method is declared (in byte code) in the specified target class or one of its superclasses.
-