Generic extensions See more about extension methods http://docs.codehaus.org/display/GROOVY/Creating+an+extension+module
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
DATETIME_FORMAT |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static java.lang.Object |
asType(java.lang.String self, java.lang.Class<java.lang.Object> type)Converts a String to a Duration object |
|
static java.lang.Object |
asType(groovy.lang.GString self, java.lang.Class<java.lang.Object> type)Converts a GString to a Duration object |
|
static java.lang.Object |
asType(java.lang.Number self, java.lang.Class type)Converts a Number to a Duration object |
|
static java.lang.Object |
asType(java.io.File self, java.lang.Class<java.lang.Object> type)Converts a File to a Path object |
|
static java.util.List<java.lang.String> |
bestMatches(java.util.Collection<java.lang.String> options, java.lang.String sample)Find all the best matches for the given example string in a list of values |
|
static java.lang.String |
capitalize(java.lang.String self) |
|
static groovy.lang.GString |
cloneAsLazy(groovy.lang.GString self, java.lang.Object binding)Create a copy of a groovy.lang.GString object cloning all values that are instance of groovy.lang.Closure |
<T extends Closure> |
static T |
cloneWith(T self, java.lang.Object binding)Clone a groovy.lang.Closure object and set the specified map as delegate object in the resulting closure |
|
static java.util.List<java.lang.String> |
closest(java.util.Collection<java.lang.String> options, java.lang.String sample)Find all the best matches for the given example string in a list of values |
|
static void |
debug1(org.slf4j.Logger log, java.util.Map params = null, java.lang.Object msg)Append a `debug` level entry in the application log. |
|
static void |
error1(org.slf4j.Logger log, java.util.Map params = null, java.lang.Object msg)Append a `error` level entry in the application log. |
|
static java.lang.String |
format(java.util.Date self, java.lang.String format = null, java.lang.String tz = null)Format a java.util.Date object |
|
static java.lang.String |
format(java.time.OffsetDateTime self, java.lang.String format) |
|
static java.lang.String |
format(java.util.Date self, java.lang.String format, java.util.TimeZone tz)Format a java.util.Date object |
|
static java.lang.String |
getErrMessage(java.lang.Throwable e) |
<K, V> |
static V |
getOrCreate(java.util.Map<K, V> self, K key, groovy.lang.Closure<V> value) |
<K, V> |
static V |
getOrCreate(java.util.Map<K, V> self, K key, V value) |
|
static java.lang.String |
indent(java.lang.String text, java.lang.String prefix = ' ' )Indent each line in the given test by a specified prefix |
|
static void |
info1(org.slf4j.Logger log, java.util.Map params = null, java.lang.Object msg)Append a `info` level entry in the application log. |
|
static boolean |
isAllLowerCase(java.lang.String self)Check if ALL characters in a string are lowercase. |
|
static boolean |
isAllUpperCase(java.lang.String self)Check if ALL characters in a string are uppercase. |
|
static boolean |
isCamelCase(java.lang.String str) |
|
static boolean |
isLowerCase(java.lang.String self)Check if a alphabetic characters in a string are lowercase. |
|
static boolean |
isUpperCase(java.lang.String self)Check if a alphabetic characters in a string are uppercase. |
|
static java.lang.String |
leftTrim(java.lang.String self)Remove blank chars at string beginning |
|
static java.lang.Object |
navigate(java.util.Map self, java.lang.String key, groovy.lang.Closure closure = null )Navigate a map of maps traversing multiple attribute using dot notation. |
|
static java.lang.Object |
navigate(java.util.Map self, java.lang.String key, java.lang.Object defValue) |
|
static java.util.List |
pairs(java.util.Map self, java.util.Map opts = null) |
|
static java.lang.String |
rightTrim(java.lang.String self)Remove blank chars at the end of the string |
|
static java.lang.String |
strip(java.lang.String self, java.lang.String stripChars = null ) |
|
static java.lang.String |
stripEnd(java.lang.String self, java.lang.String stripChars = null ) |
|
static java.lang.String |
stripStart(java.lang.String self, java.lang.String stripChars = null ) |
|
static groovy.util.ConfigObject |
toConfigObject(java.util.Map self) |
|
static Duration |
toDuration(java.lang.Number number) |
|
static java.util.Map |
toMap(groovy.util.ConfigObject config)Converts ConfigObjects to a plain Map |
|
static MemoryUnit |
toMemory(java.lang.Number number) |
|
static void |
trace(org.slf4j.Logger log, java.lang.Object msg) |
|
static void |
trace(org.slf4j.Logger log, java.lang.Object msg, java.lang.Throwable e) |
|
static void |
trace1(org.slf4j.Logger log, java.util.Map params = null, java.lang.Object msg)Append a `trace` level entry in the application log. |
|
static java.lang.String |
trimDotZero(java.lang.String self)Remove the left side after a dot (including it) e.g. |
|
static boolean |
tryLock(java.util.concurrent.locks.Lock self, groovy.lang.Closure closure)Invokes the specify closure only if it is able to acquire a lock |
|
static java.lang.String |
uncapitalize(java.lang.String self) |
|
static void |
warn1(org.slf4j.Logger log, java.util.Map params = null, java.lang.Object msg)Append a `warn` level entry in the application log. |
<T> |
static T |
withLock(java.util.concurrent.locks.Lock self, boolean interruptible = false, groovy.lang.Closure<T> closure)Invokes the specify closure including it with a lock/unlock calls pair |
|
static java.lang.Object |
withLock(java.io.File self, Duration timeout = null, groovy.lang.Closure closure)Creates a file system wide lock that prevent two or more JVM instances/process to work on the same file |
|
static java.lang.Object |
withLock(java.nio.file.Path self, Duration timeout, groovy.lang.Closure closure)Creates a file system wide lock that prevent two or more JVM instances/process to work on the same file |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Converts a String to a Duration object
Converts a GString to a Duration object
Converts a Number to a Duration object
Converts a File to a Path object
Find all the best matches for the given example string in a list of values
options - A list of stringsample - The example string -- cannot be empty
Capitalizes a String changing the first letter to title case as per java.lang.Character#toTitleCase(char). No other letters are changed.
For a word based algorithm, see org.apache.commons.lang.WordUtils#capitalize(String).
A null input String returns null.
StringUtils.capitalize(null) = null
StringUtils.capitalize("") = ""
StringUtils.capitalize("cat") = "Cat"
StringUtils.capitalize("cAt") = "CAt"
Create a copy of a groovy.lang.GString object cloning all values that are instance of groovy.lang.Closure
self - The groovy.lang.GString itselfbinding - A java.util.Map object that is set as delegate object in the cloned closure.Clone a groovy.lang.Closure object and set the specified map as delegate object in the resulting closure
self - The groovy.lang.Closure object to be clonedbinding - The delegate object to set in the new closureFind all the best matches for the given example string in a list of values
sample - The example string -- cannot be emptyoptions - A list of stringAppend a `debug` level entry in the application log.
log
- The org.slf4j.Logger objectparams
- Optional named parameters
- `causedBy`: A java.lang.Throwable object that raised the error
- `throttle`: When specified suppress identical logs within the specified time Durationmsg
- The message to printAppend a `error` level entry in the application log.
log
- The org.slf4j.Logger objectparams
- Optional named parameters
- `causedBy`: A java.lang.Throwable object that raised the error
- `throttle`: When specified suppress identical logs within the specified time Durationmsg
- The message to printFormat a java.util.Date object
self - The java.util.Date object to formatformat - The date format to use eg. dd-MM-yyyy HH:mm.tz - The timezone to be used eg. UTC. If null the current timezone is used.Format a java.util.Date object
self - The java.util.Date object to formatformat - The date format to use eg. dd-MM-yyyy HH:mmtz - The timezone to be used. If null the current timezone is used.Indent each line in the given test by a specified prefix
Append a `info` level entry in the application log.
log
- The org.slf4j.Logger objectparams
- Optional named parameters
- `causedBy`: A java.lang.Throwable object that raised the error
- `throttle`: When specified suppress identical logs within the specified time Durationmsg
- The message to printCheck if ALL characters in a string are lowercase.
self - The string to checkfalse otherwiseCheck if ALL characters in a string are uppercase.
self - The string to checkfalse otherwiseCheck if a alphabetic characters in a string are lowercase. Non alphabetic characters are ingored
self - The string to checkfalse otherwiseCheck if a alphabetic characters in a string are uppercase. Non alphabetic characters are ignored
self - The string to checkfalse otherwiseRemove blank chars at string beginning
self - The string itself Navigate a map of maps traversing multiple attribute using dot notation. For example:
x.y.z
self - The root map objectkey - A dot separated list of keysclosure - An optional closure to be applied. Only if all keys existsRemove blank chars at the end of the string
self - The string itself
Strips any of a set of characters from the start and end of a String. This is similar to java.lang.String#trim() but allows the characters to be stripped to be controlled.
A null input String returns null.
An empty string ("") input returns the empty string.
If the stripChars String is null, whitespace is
stripped as defined by java.lang.Character#isWhitespace(char).
Alternatively use strip(String).
StringUtils.strip(null, *) = null
StringUtils.strip("", *) = ""
StringUtils.strip("abc", null) = "abc"
StringUtils.strip(" abc", null) = "abc"
StringUtils.strip("abc ", null) = "abc"
StringUtils.strip(" abc ", null) = "abc"
StringUtils.strip(" abcyx", "xyz") = " abc"
str - the String to remove characters from, may be nullstripChars - the characters to remove, null treated as whitespacenull if null String input
Strips any of a set of characters from the end of a String.
A null input String returns null.
An empty string ("") input returns the empty string.
If the stripChars String is null, whitespace is
stripped as defined by java.lang.Character#isWhitespace(char).
StringUtils.stripEnd(null, *) = null
StringUtils.stripEnd("", *) = ""
StringUtils.stripEnd("abc", "") = "abc"
StringUtils.stripEnd("abc", null) = "abc"
StringUtils.stripEnd(" abc", null) = " abc"
StringUtils.stripEnd("abc ", null) = "abc"
StringUtils.stripEnd(" abc ", null) = " abc"
StringUtils.stripEnd(" abcyx", "xyz") = " abc"
StringUtils.stripEnd("120.00", ".0") = "12"
str - the String to remove characters from, may be nullstripChars - the set of characters to remove, null treated as whitespacenull if null String input
Strips any of a set of characters from the start of a String.
A null input String returns null.
An empty string ("") input returns the empty string.
If the stripChars String is null, whitespace is
stripped as defined by java.lang.Character#isWhitespace(char).
StringUtils.stripStart(null, *) = null
StringUtils.stripStart("", *) = ""
StringUtils.stripStart("abc", "") = "abc"
StringUtils.stripStart("abc", null) = "abc"
StringUtils.stripStart(" abc", null) = "abc"
StringUtils.stripStart("abc ", null) = "abc "
StringUtils.stripStart(" abc ", null) = "abc "
StringUtils.stripStart("yxabc ", "xyz") = "abc "
str - the String to remove characters from, may be nullstripChars - the characters to remove, null treated as whitespacenull if null String input Converts ConfigObjects to a plain Map
Append a `trace` level entry in the application log.
log
- The org.slf4j.Logger objectparams
- Optional named parameters
- `causedBy`: A java.lang.Throwable object that raised the error
- `throttle`: When specified suppress identical logs within the specified time Durationmsg
- The message to printRemove the left side after a dot (including it) e.g.
0.10 => 0
10000.00 => 10000
Invokes the specify closure only if it is able to acquire a lock
Uncapitalizes a String changing the first letter to title case as per java.lang.Character#toLowerCase(char). No other letters are changed.
For a word based algorithm, see org.apache.commons.lang.WordUtils#uncapitalize(String).
A null input String returns null.
StringUtils.uncapitalize(null) = null
StringUtils.uncapitalize("") = ""
StringUtils.uncapitalize("Cat") = "cat"
StringUtils.uncapitalize("CAT") = "cAT"
Append a `warn` level entry in the application log.
log
- The org.slf4j.Logger objectparams
- Optional named parameters
- `causedBy`: A java.lang.Throwable object that raised the error
- `throttle`: When specified suppress identical logs within the specified time Durationmsg
- The message to printInvokes the specify closure including it with a lock/unlock calls pair
Creates a file system wide lock that prevent two or more JVM instances/process to work on the same file Note: this does not protected against multiple-thread accessing the file in a concurrent manner.
timeoutself - The file over which define the locktimeout - An option timeout elapsed which the a java.lang.InterruptedException is thrownclosure - The action to apply during the lock file spawnclosure resultCreates a file system wide lock that prevent two or more JVM instances/process to work on the same file Note: this does not protected against multiple-thread accessing the file in a concurrent manner.
timeoutself - The file over which define the locktimeout - An option timeout elapsed which the a java.lang.InterruptedException is thrownclosure - The action to apply during the lock file spawnclosure result