|
Groovy JDK |
def list = [1, 'a', 1 def types = list
compareTo(value) == 0
or equals(value)
)
true
if the intersection of two collections is empty
RFC 4648
RFC 4648
false
if either collection is null
false
if either collection is null
true
according to the Groovy Truth
Equivalent to self
-
every(groovy.lang.Closure closure) -
Method in class java.lang.Object
-
Used to determine if the given predicate closure is valid (i
true
for all items in this data structure)
A simple example for a list:
def list = [3,4,5]
def greaterThanTwo = list
-
execute() -
Method in class java.lang.String
-
Executes the given string as a command line process
over the process mechanism in JDK 1
-
execute(java.lang.String[] envp, java.io.File dir) -
Method in class java.lang.String
-
Executes the command specified by the
self
with environments envp
under the working directory dir
For more control over the process mechanism in JDK 1
-
execute(java.util.List envp, java.io.File dir) -
Method in class java.lang.String
-
Executes the command specified by the
self
with environments envp
under the working directory dir
For more control over the process mechanism in JDK 1
true
if the line should be passed to the writer
true
if the line should be passed to the
writer
bean[somePropertyNameExpression]
of groovy is neater and more concise but only works with compile-time known
property names
String
-
getMetaPropertyValues() -
Method in class java.lang.Object
-
Retrieves the list of {@link MetaProperty} objects for 'self' and wraps it
in a list of {@link PropertyValue} objects that additionally provide
the value for each property of 'self'
-
getOut() -
Method in class java.lang.Process
-
An alias method so that a process appears similar to System
you can use process
-
getProperties() -
Method in class java.lang.Object
-
Convenience method that calls {@link #getMetaPropertyValues(Object)}(self)
and provides the data in form of simple key/value pairs, i
type() information
-
getRootLoader() -
Method in class java.lang.ClassLoader
-
Iterates through the classloader parents until it finds a loader with a class
named "org
null
will be returned
a direct comparison using == may fail as the class may be loaded through
different classloaders
-
getText() -
Method in class java.lang.Process
-
Read the text of the output stream of the Process
-
getText(java.lang.String charset) -
Method in class java.io.File
-
Read the content of the File using the specified encoding and return it
as a String
-
getTimeString() -
Method in class java.util.Date
-
Return a string representation of the time portion of this date
according to the locale-specific format used by {@link DateFormat}
-
grep(java.lang.Object filter) -
Method in class java.lang.Object
-
Iterates over every element of the collection and returns each item that matches
the given filter - calling the
{@link #isCase(Object,Object)}
method used by switch statements
kinds of filters like regular expressions, classes, ranges etc
Example:
def list = ['a', 'b', 'aa', 'bc' ]
def filtered = list
-
groupBy(groovy.lang.Closure closure) -
Method in class java.util.Collection
-
Sorts all collection members into groups determined by the
supplied mapping closure
item should be grouped by
distinct key returned from the closure, with each value being a list of
items for that group
-
groupEntriesBy(groovy.lang.Closure closure) -
Method in class java.util.Map
-
Groups all map entries into groups determined by the
supplied mapping closure
key and value (depending on the number of parameters the closure accepts)
and should return the key that each item should be grouped under
resulting map will have an entry for each 'group' key returned by the
closure, with values being the list of map entries that belong to each
group
def same = (this is that)
compareTo()
method for comparing numbers of different
types
switch( obj ) { case List : // obj is a list break; case Set : // etc }
toString()
representation of each
items in this array, with the given String as a separator between each
item
newInstance()
for the default (no-arg) constructor
left
and right
,
giving precedence to right
will appear in the resultant map with values from the right
operand
or Properties, the returned Map will preserve that type, otherwise a HashMap will
be returned
Roughly equivalent to Map m = new HashMap(); m
but with some additional logic to preserve the left
Map type for common cases as
described above
-
pop() -
Method in class java.util.List
-
Removes the last item from the List
is similar to push and pop on a Stack
-
power(java.lang.Number exponent) -
Method in class java.lang.Number
-
Power of a Number to a certain exponent
-
previous() -
Method in class java.lang.Character
-
Decrement a Character by one
-
print(java.io.PrintWriter out) -
Method in class java.lang.Object
-
Print to a console in interactive format
-
print(java.lang.Object value) -
Method in class java.lang.Object
-
Print a value to the standard output stream
-
printf(java.lang.String format, java.lang.Object arg) -
Method in class java.lang.Object
-
Prints a formatted string using the specified format string and
arguments (Only works with JDK1
For examples,
printf ( "Hello, %s!\n" , [ "world" ] as String[] )
printf ( "Hello, %s!\n" , [ "Groovy" ])
printf ( "%d + %d = %d\n" , [ 1 , 2 , 1+2 ] as Integer[] )
printf ( "%d + %d = %d\n" , [ 3 , 3 , 3+3 ])
( 1
( 1
( 0x41
( 07
( 7
( 7
( 7
( 7
-
printf(java.lang.String format, java.lang.Object[] values) -
Method in class java.lang.Object
-
Printf to a console (Only works with JDK1
-
println() -
Method in class java.lang.Object
-
Print a linebreak to the standard output stream
-
println(java.io.PrintWriter out) -
Method in class java.lang.Object
-
Print to a console in interactive format
-
println(java.lang.Object value) -
Method in class java.lang.Object
-
Print a value (followed by a newline) to the standard output stream
-
push(java.lang.Object value) -
Method in class java.util.List
-
Appends an item to the List
-
putAt(groovy.lang.EmptyRange range, java.lang.Object value) -
Method in class java.lang.StringBuffer
-
Support the range subscript operator for StringBuffer
-
putAt(groovy.lang.IntRange range, boolean value) -
Method in class java.util.BitSet
-
Support assigning a range of values with a single assignment statement
-
putAt(groovy.lang.IntRange range, java.lang.Object value) -
Method in class java.lang.StringBuffer
-
Support the range subscript operator for StringBuffer
treated as characters within the buffer
-
putAt(groovy.lang.IntRange range, java.util.Collection col) -
Method in class java.util.List
-
List subscript assignment operator when given a range as the index and
the assignment operand is a collection
Example:
myList[3
range are relaced with items from the collection
-
putAt(int idx, java.lang.Boolean newValue) -
Method in class primitive-types.boolean[]
-
-
putAt(int idx, java.lang.Object newValue) -
Method in class primitive-types.byte[]
-
-
putAt(int idx, java.lang.Object value) -
Method in class java.lang.Object[]
-
Support the subscript operator for an Array
-
putAt(int index, boolean value) -
Method in class java.util.BitSet
-
Support subscript-style assignment for a BitSet
-
putAt(java.lang.Object key, java.lang.Object value) -
Method in class java.util.Map
-
A helper method to allow lists to work with subscript operators
-
putAt(java.lang.String property, java.lang.Object newValue) -
Method in class java.lang.Object
-
Allows the subscript operator to be used to set dynamically named property values
bean[somePropertyNameExpression] = foo
of groovy is neater and more concise but only works with property names which
are known at compile time
-
putAt(java.util.List splice, java.lang.Object value) -
Method in class java.util.List
-
A helper method to allow lists to work with subscript operators
-
putAt(java.util.List splice, java.util.List values) -
Method in class java.util.List
-
A helper method to allow lists to work with subscript operators
For examples,
assert "FOOBAR-FOOBAR-" == "foobar-FooBar-" Here, it[0] is the global string of the matched group it[1] is the first string in the matched group it[2] is the second string in the matched group assert "FOO-FOO-" == "foobar-FooBar-" Here, x is the global string of the matched group y is the first string in the matched group z is the second string in the matched group
size()
method for an array
0 println it }Prints even numbers 0 through 8
coll
coll
-
sum(java.lang.Object initialValue) -
Method in class java.util.Collection
-
Sums the items in a collection, adding the result to some initial value
-
sum(java.lang.Object initialValue, groovy.lang.Closure closure) -
Method in class java.util.Collection
-
Sums the result of apply a closure to each item of a collection to sum intial value
coll
coll
10 println it }Prints the numbers 0 through 9
{1, 2, "a"}
[1, 2, a]
class Person {
def fname, lname
public String toString() {
return fname + " " + lname
}
}
class PersonComparator implements Comparator {
public int compare(Object o1, Object o2) {
Person p1 = (Person) o1
Person p2 = (Person) o2
if (p1
return p1
else
return p1
}
public boolean equals(Object obj) {
return this
}
}
Person a = new Person(fname:"John", lname:"Taylor")
Person b = new Person(fname:"Clark", lname:"Taylor")
Person c = new Person(fname:"Tom", lname:"Cruz")
Person d = new Person(fname:"Clark", lname:"Taylor")
def list = [a, b, c, d]
List list2 = list
assert( list2 == list && list == [a, b, c] )
use(CategoryClass1, CategoryClass2) {
This method saves having to wrap the the category
classes in a list
-
use(java.util.List categoryClassList, groovy.lang.Closure closure) -
Method in class java.lang.Object
-
Scoped use method with list of categories
|
Groovy JDK |