Class GroovyMethods
- All Implemented Interfaces:
GroovyObject
Provides commonly used Martini Runtime functions, as well as useful utilities to the Groovy engine. This is included in the Groovy engine through its extension module functionality.
Before using this in your scripts, you should read up on Closures (also consider reading more about them here.
Aside from this utility class, you can also use built-in utility classes included by the Groovy Engine and Martini Runtime. See the list of classes below to learn more about the functionalities available to you when writing Groovy scripts in Martini.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionGroovyMethods(MartiniPackageProvider martiniPackageProvider, io.toro.martini.ipackage.MartiniPackageToPackageConverter martiniMartiniPackageToPackageConverterPayload, List<Object> groovyMethodsClassInstance, io.toro.properties.ToroProperties applicationProperties) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGet the value of an application property.static StringgetApplicationProperty(String key, String defaultValue) Get the value of an application property.static MartiniPackageDeprecated.Moved toPackageMethods.getPackage()static StringgetPackageProperty(String key) Deprecated.static StringgetPackageProperty(String key, String defaultValue) Deprecated.static String[]Deprecated.static String[]getPackagePropertyArray(String key, String[] defaultValue) Deprecated.static StringDeprecated.static StringgetTOROProperty(String key) Deprecated.This method has been renamed.static StringgetTOROProperty(String key, String defaultValue) Deprecated.This method has been renamed.static String[]Deprecated.This method has been renamed.static String[]getTOROPropertyArray(String key, String[] defaultValue) Deprecated.This method has been renamed.static StringDeprecated.This method has been renamed.invokeMethod(String name, Object args) iterator()static StringDeprecated.static StringremoveTOROProperty(String key) Deprecated.This method has been renamed.static StringsavePackageProperty(String key, String value) Deprecated.static voidsavePackagePropertyComment(String key, String comment) Deprecated.static StringsaveTOROProperty(String key, String value) Deprecated.This method has been renamed.static voidsaveTOROPropertyComment(String key, String comment) Deprecated.This method has been renamed.voidsetAdaptee(Object adaptee) static <V> VwithPackageEndpoints(GroovyObject obj, Closure<V> closure) Allow aGroovyObjectto execute a closure against the availableEndpoints installed on the package associated with the current thread.Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClassMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface groovy.lang.GroovyObject
getProperty, setProperty
-
Constructor Details
-
GroovyMethods
GroovyMethods() -
GroovyMethods
GroovyMethods(MartiniPackageProvider martiniPackageProvider, io.toro.martini.ipackage.MartiniPackageToPackageConverter martiniMartiniPackageToPackageConverterPayload, List<Object> groovyMethodsClassInstance, io.toro.properties.ToroProperties applicationProperties)
-
-
Method Details
-
getPackage
Deprecated.Moved toPackageMethods.getPackage()Get the package assigned to the current context.- Returns:
- the current context's package
-
withPackageEndpoints
Allow aGroovyObjectto execute a closure against the availableEndpoints installed on the package associated with the current thread.- Type Parameters:
V- the expected type- Parameters:
obj- the object that requires the endpointsclosure- the closure to invoke- Returns:
- the actual result after invoking the closure against the collection of endpoints
- Throws:
ToroRuntimeException- if there's no package associated with the current thread
-
saveTOROProperty
Deprecated.This method has been renamed. Please prefersavePackageProperty(String, String).Save an application property.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.saveTOROProperty('value')- Parameters:
key- the property keyvalue- the property value- Returns:
- the saved property value
- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
saveTOROPropertyComment
Deprecated.This method has been renamed. Please prefersavePackagePropertyComment(String, String).Add a comment to an application property, useful for providing a description of the property.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.saveTOROPropertyComment('This is a comment describing a property.')- Parameters:
key- the property keycomment- the comment to the key- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getTOROPropertyComment
Deprecated.This method has been renamed. Please prefergetPackagePropertyComment(String).Get the comment of an application property, useful for understanding the property's purpose.
invalid input: '<'Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.getTOROPropertyComment()
- Parameters:
key- the property key- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getTOROPropertyArray
Deprecated.This method has been renamed. Please prefergetPackagePropertyArray(String, String[]).Get the value of an application property as an array. Every comma-separated value in the property is assigned to one array element.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.getTOROPropertyArray(['default', 'values'])
- Parameters:
key- the property keydefaultValue- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValueif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getTOROPropertyArray
Deprecated.This method has been renamed. Please prefergetPackagePropertyArray(String).Get the value of an application property as an array. Every comma-separated value in the property is assigned to one array element.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.getTOROPropertyArray()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getTOROProperty
Deprecated.This method has been renamed. Please prefergetPackageProperty(String).Get the value of an application property.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.getTOROProperty()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getTOROProperty
Deprecated.This method has been renamed. Please prefergetPackageProperty(String, String).Get the value of an application property.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.getTOROProperty('defaultValue')- Parameters:
key- the property keydefaultValue- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValueif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
removeTOROProperty
Deprecated.This method has been renamed. Please preferremovePackageProperty(String).Delete an application property.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.removeTOROProperty()
- Parameters:
key- the property key- Returns:
- the property's assigned value
- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
savePackageProperty
Deprecated.Save a package property.
Package properties are local only to a package. This one-liner saves the property to the package in the current context; specifically in the package's
package.propertiesfile.Example usage:
'key'.saveTOROProperty('value')- Parameters:
key- the property keyvalue- the property value- Returns:
- the property's assigned value
- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
savePackagePropertyComment
Deprecated.Add a comment to a package property, useful for providing a description of the property.
Package properties are local only to a package. This one-liner saves the property comment to the package in the current context; specifically in the package's
Example usage:package.propertiesfile.'key'.savePackagePropertyComment('This is a comment describing a property.')- Parameters:
key- the property keycomment- the comment to the key- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackagePropertyComment
Deprecated.Get the comment of a package property, useful for understanding the property's purpose.
Package properties are local only to a package. This one-liner fetches the property comment from the package in the current context; specifically in the package's
package.propertiesfile.Example usage:
'key'.getPackagePropertyComment()
- Parameters:
key- the property key- Returns:
- package property comment
- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackagePropertyArray
Deprecated.Get the value of a package property as an array. Every comma-separated value in the property is assigned to one array element.
Package properties are local only to a package. This one-liner fetches the property from the package in the current context; specifically in the package's
package.propertiesfile.Example usage:
'key'.getPackagePropertyArray(['default', 'values'])
- Parameters:
key- the property keydefaultValue- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValueif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackagePropertyArray
Deprecated.Get the value of a package property as an array. Every comma-separated value in the property is assigned to one array element.
Package properties are local only to a package. This one-liner fetches the property from the package in the current context; specifically in the package's
package.propertiesfile.Example usage:
'key'.getPackagePropertyArray()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackageProperty
Deprecated.Get the value of a package property.
Package properties are local only to a package. This one-liner fetches the property from the package in the current context; specifically in the package's
package.propertiesfile.Example usage:
'key'.getPackageProperty()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackageProperty
Deprecated.Get the value of a package property.
Package properties are local only to a package. This one-liner fetches the property from the package in the current context; specifically in the package's
package.propertiesfile.Example usage:
'key'.getPackageProperty('defaultValue')- Parameters:
key- the property keydefaultValue- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValueif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
removePackageProperty
Deprecated.Delete a package property.
Package properties are local only to a package. This one-liner removes the property from the package in the current context; specifically in the package's
Example usage:package.propertiesfile.'key'.removePackageProperty()
- Parameters:
key- the property key- Returns:
- the property's assigned value
- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getApplicationProperty
Get the value of an application property.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.getApplicationProperty()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif the property doesn't exist - Since:
- 1.0
-
getApplicationProperty
Get the value of an application property.
Application properties are global, and stored in the
corepackage'sapplication.propertiesfile.Example usage:
'key'.getApplicationProperty('defaultValue')- Parameters:
key- the property keydefaultValue- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValueif the property doesn't exist - Since:
- 1.0
-
wrap
-
getAdaptee
- Overrides:
getAdapteein classProxy
-
setAdaptee
- Overrides:
setAdapteein classProxy
-
invokeMethod
- Specified by:
invokeMethodin interfaceGroovyObject- Overrides:
invokeMethodin classProxy
-
iterator
-
PackageMethods.MartiniPackageSetterinstead