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 <T> Tstatic <T> Tstatic Object[]despreadList(Object[] args, Object[] spreads, int[] positions) static booleanstatic ObjectgetAttribute(Object target, String name) Note: This method may throw checked exceptions although it doesn't say so.static groovy.lang.MetaClassgetMetaClass(Class<?> clazz) static groovy.lang.MetaClassgetMetaClass(Object object) static ObjectgetProperty(Object target, String property) Note: This method may throw checked exceptions although it doesn't say so.static StringgetterMethodToPropertyName(String methodName, List<Class<?>> parameterTypes, Class<?> returnType) Checks if the given method is a getter method according to Groovy rules.static <T extends groovy.lang.Closure<?>>
TinstantiateClosure(Class<T> closureType, Object owner, Object thisObject) Note: This method may throw checked exceptions although it doesn't say so.static <T> TinvokeClosure(groovy.lang.Closure<T> closure, Object... args) Note: This method may throw checked exceptions although it doesn't say so.static ObjectinvokeConstructor(Class<?> clazz, Object... args) Note: This method may throw checked exceptions although it doesn't say so.static ObjectinvokeMethod(Object target, String method, Object... args) Note: This method may throw checked exceptions although it doesn't say so.static ObjectinvokeMethodNullSafe(Object target, String method, Object... args) static ObjectinvokeMethodQuietly(Object target, String method, Object... args) static booleanstatic booleanisVoidMethod(Object target, String method, Object... args) static StringpropertyToMethodName(String prefix, String propertyName) static voidsetMetaClass(Class<?> clazz, groovy.lang.MetaClass metaClass) static voidsetMetaClass(Object object, groovy.lang.MetaClass metaClass) static voidsetProperty(Object target, String property, Object value) Note: This method may throw checked exceptions although it doesn't say so.static MethodtoMethod(groovy.lang.MetaMethod metaMethod) static String
-
Field Details
-
EMPTY_ARGUMENTS
-
-
Constructor Details
-
GroovyRuntimeUtil
public GroovyRuntimeUtil()
-
-
Method Details
-
isTruthy
-
coerce
-
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. -
instantiateClosure
public static <T extends groovy.lang.Closure<?>> T instantiateClosure(Class<T> closureType, Object owner, Object thisObject) 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. -
toMethod
-