From commits-return-8389-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Sat Apr 27 07:16:12 2019
Return-Path:
- * { final String n0, final String n1 -> "$n0$separator$n1" }
+ * { final String n0, final String n1 {@code ->} "$n0$separator$n1" }
*
*
* @since 2.5.0
diff --git a/src/main/groovy/groovy/transform/EqualsAndHashCode.java b/src/main/groovy/groovy/transform/EqualsAndHashCode.java
index 51e480d..20e0783 100644
--- a/src/main/groovy/groovy/transform/EqualsAndHashCode.java
+++ b/src/main/groovy/groovy/transform/EqualsAndHashCode.java
@@ -99,9 +99,9 @@ import java.lang.annotation.Target;
*
* def p3 = new IntPairWithSum(1, 2)
*
- * assert p1 == p2 && p2 == p1
- * assert p1 == p3 && p3 == p1
- * assert p3 == p2 && p2 == p3
+ * assert p1 == p2 {@code &&} p2 == p1
+ * assert p1 == p3 {@code &&} p3 == p1
+ * assert p3 == p2 {@code &&} p2 == p3
*
* Note that if you create any domain classes which don't have exactly the
* same contract as IntPair
then you should provide an appropriate
@@ -113,7 +113,7 @@ import java.lang.annotation.Target;
* {@code @TupleConstructor(includeSuperProperties=true)}
* class IntTriple extends IntPair { int z }
* def t1 = new IntTriple(1, 2, 3)
- * assert p1 != t1 && p2 != t1 && t1 != p3
+ * assert p1 != t1 {@code &&} p2 != t1 {@code &&} t1 != p3
*
*
* The alternative supported style regards any kind of inheritance as creation of
@@ -150,13 +150,13 @@ import java.lang.annotation.Target;
* e.g. for comparing instances of the IntPair
and IntTriple
classes
* discussed earlier, you could provide the following method in IntPair
:
*
- * boolean hasEqualXY(other) { other.x == getX() && other.y == getY() }
+ * boolean hasEqualXY(other) { other.x == getX() {@code &&} other.y == getY() }
*
* Then for the objects defined earlier, the following would be true:
*
- * assert p1.hasEqualXY(t1) && t1.hasEqualXY(p1)
- * assert p2.hasEqualXY(t1) && t1.hasEqualXY(p2)
- * assert p3.hasEqualXY(t1) && t1.hasEqualXY(p3)
+ * assert p1.hasEqualXY(t1) {@code &&} t1.hasEqualXY(p1)
+ * assert p2.hasEqualXY(t1) {@code &&} t1.hasEqualXY(p2)
+ * assert p3.hasEqualXY(t1) {@code &&} t1.hasEqualXY(p3)
*
* There is also support for including or excluding fields/properties by name when constructing
* the equals and hashCode methods as shown here:
diff --git a/src/main/groovy/groovy/transform/Memoized.java b/src/main/groovy/groovy/transform/Memoized.java
index 5bd1dc1..051cd81 100644
--- a/src/main/groovy/groovy/transform/Memoized.java
+++ b/src/main/groovy/groovy/transform/Memoized.java
@@ -49,7 +49,7 @@ import java.lang.annotation.Target;
*
* class MemoizedExample {
*
- * private final Closure memoizedSum = { int n1, int n2 ->
+ * private final Closure memoizedSum = { int n1, int n2 {@code ->}
* private$method$memoizedSum(n1,n2)
* }.memoize()
*
diff --git a/src/main/groovy/groovy/transform/stc/MapEntryOrKeyValue.java b/src/main/groovy/groovy/transform/stc/MapEntryOrKeyValue.java
index 9316ef8..a53d14e 100644
--- a/src/main/groovy/groovy/transform/stc/MapEntryOrKeyValue.java
+++ b/src/main/groovy/groovy/transform/stc/MapEntryOrKeyValue.java
@@ -37,9 +37,9 @@ import java.util.Map;
* or on a key,value pair.
The result is a closure which can have the following forms:
*{ key, value -> ...}
where key is the key of a map entry, and value the corresponding value{ entry -> ... }
where entry is a {@link java.util.Map.Entry} map entry{ ...}
where it is an implicit {@link java.util.Map.Entry} map entry{ key, value {@code ->} ... }
where key is the key of a map entry, and value the corresponding value{ entry {@code ->} ... }
where entry is a {@link java.util.Map.Entry} map entry{ ... }
where it is an implicit {@link java.util.Map.Entry} map entryThis hint handles all those cases by picking the generics from the first argument of the method (by default).
*The options array is used to modify the behavior of this hint. Each string in the option array consists of diff --git a/src/main/groovy/groovy/transform/stc/PickAnyArgumentHint.java b/src/main/groovy/groovy/transform/stc/PickAnyArgumentHint.java index 0f4d92f..34b58f0 100644 --- a/src/main/groovy/groovy/transform/stc/PickAnyArgumentHint.java +++ b/src/main/groovy/groovy/transform/stc/PickAnyArgumentHint.java @@ -29,7 +29,7 @@ import org.codehaus.groovy.control.SourceUnit; * This can optionally use a generic type of the selected parameter as the hint. For example, imagine the following * method:
*void foo(A firstArg, B secondArg, Closure c) {...}
- * If the c closure should be { B it -> ...}
, then we can see that the parameter type
+ *
If the c closure should be { B it {@code ->} ...}
, then we can see that the parameter type
* should be picked from the second parameter of the foo method, which is what {@link groovy.transform.stc.PickAnyArgumentHint}
* lets you do.
Alternatively, the method may look like this:
diff --git a/src/main/groovy/groovy/util/IndentPrinter.java b/src/main/groovy/groovy/util/IndentPrinter.java index ccbec0f..e79d4bb 100644 --- a/src/main/groovy/groovy/util/IndentPrinter.java +++ b/src/main/groovy/groovy/util/IndentPrinter.java @@ -36,7 +36,7 @@ import java.io.Writer; * The following is an example usage. Note that within a "with" block you need to * specify a parameter name so that this.println is not called instead of IndentPrinter.println: *- * new IndentPrinter(new PrintWriter(out)).with { p -> + * new IndentPrinter(new PrintWriter(out)).with { p {@code ->} * p.printIndent() * p.println('parent1') * p.incrementIndent() diff --git a/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java b/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java index 27bbd6c..374239c 100644 --- a/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java +++ b/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java @@ -583,7 +583,7 @@ public class WideningCategories { /** * This {@link ClassNode} specialization is used when the lowest upper bound of two types * cannot be represented by an existing type. For example, if B extends A, C extends A - * and both C & B implement a common interface not implemented by A, then we use this class + * and both C and B implement a common interface not implemented by A, then we use this class * to represent the bound. * * At compile time, some classes like {@link org.codehaus.groovy.classgen.AsmClassGenerator} need diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java index c969074..f4e00fc 100644 --- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java +++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java @@ -1040,7 +1040,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * * @param self any Object * @return a String that matches what would be typed into a terminal to - * create this object. e.g. [1, 'hello'].inspect() -> [1, "hello"] + * create this object. e.g. [1, 'hello'].inspect() {@code ->} [1, "hello"] * @since 1.0 */ public static String inspect(Object self) { @@ -1354,7 +1354,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * will be passed as arguments, and the closure should return an * int value (with 0 indicating the items are not unique). **assert [1,4] == [1,3,4,5].unique { it % 2 }- *assert [2,3,4] == [2,3,3,4].unique { a, b -> a <=> b }+ *assert [2,3,4] == [2,3,3,4].unique { a, b {@code ->} a {@code <=>} b }* * @param self a Collection * @param closure a 1 or 2 arg Closure used to determine unique items @@ -1378,7 +1378,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * will be passed as arguments, and the closure should return an * int value (with 0 indicating the items are not unique). *assert [1,4] == [1,3,4,5].unique { it % 2 }- *assert [2,3,4] == [2,3,3,4].unique { a, b -> a <=> b }+ *assert [2,3,4] == [2,3,3,4].unique { a, b {@code ->} a {@code <=>} b }* * @param self a List * @param closure a 1 or 2 arg Closure used to determine unique items @@ -1406,7 +1406,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { *
* def orig = [2, 3, 3, 4] - * def uniq = orig.unique(false) { a, b -> a <=> b } + * def uniq = orig.unique(false) { a, b {@code ->} a {@code <=>} b } * assert orig == [2, 3, 3, 4] * assert uniq == [2, 3, 4] *@@ -1444,7 +1444,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * *
* def orig = [2, 3, 3, 4] - * def uniq = orig.unique(false) { a, b -> a <=> b } + * def uniq = orig.unique(false) { a, b {@code ->} a {@code <=>} b } * assert orig == [2, 3, 3, 4] * assert uniq == [2, 3, 4] *@@ -1524,7 +1524,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * * def list = [a, b, c, d] * List list2 = list.unique(new PersonComparator()) - * assert( list2 == list && list == [a, b, c] ) + * assert( list2 == list {@code &&} list == [a, b, c] ) * * * @param self a Collection @@ -1575,7 +1575,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * * def list = [a, b, c, d] * List list2 = list.unique(new PersonComparator()) - * assert( list2 == list && list == [a, b, c] ) + * assert( list2 == list {@code &&} list == [a, b, c] ) * * * @param self a List @@ -1626,7 +1626,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * * def list = [a, b, c, d] * List list2 = list.unique(false, new PersonComparator()) - * assert( list2 != list && list2 == [a, b, c] ) + * assert( list2 != list {@code &&} list2 == [a, b, c] ) * * * @param self a Collection @@ -1698,7 +1698,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * * def list = [a, b, c, d] * List list2 = list.unique(false, new PersonComparator()) - * assert( list2 != list && list2 == [a, b, c] ) + * assert( list2 != list {@code &&} list2 == [a, b, c] ) * * * @param self a List @@ -1728,7 +1728,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * assert noDups == ['H', 'e', 'l', 'o', null, 't', 'r'] * *
assert [1,4] == [1,3,4,5].toUnique { it % 2 }- *
assert [2,3,4] == [2,3,3,4].toUnique { a, b -> a <=> b }+ *
assert [2,3,4] == [2,3,3,4].toUnique { a, b {@code ->} a {@code <=>} b }* * @param self an Iterator * @param condition a Closure used to determine unique items @@ -1843,7 +1843,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * * def list = [a, b, c, d] * List list2 = list.toUnique(new PersonComparator()) - * assert list2 == [a, b, c] && list == [a, b, c, d] + * assert list2 == [a, b, c] {@code &&} list == [a, b, c, d] * * * @param self an Iterable @@ -1894,7 +1894,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * * def list = [a, b, c, d] * List list2 = list.toUnique(new PersonComparator()) - * assert list2 == [a, b, c] && list == [a, b, c, d] + * assert list2 == [a, b, c] {@code &&} list == [a, b, c, d] * * * @param self a List @@ -1968,10 +1968,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Person d = new Person(fname:"Clark", lname:"Taylor") * * def list = [a, b, c, d] - * def list2 = list.toUnique{ p1, p2 -> p1.lname != p2.lname ? p1.lname <=> p2.lname : p1.fname <=> p2.fname } - * assert( list2 == [a, b, c] && list == [a, b, c, d] ) + * def list2 = list.toUnique{ p1, p2 {@code ->} p1.lname != p2.lname ? p1.lname <=> p2.lname : p1.fname <=> p2.fname } + * assert( list2 == [a, b, c] {@code &&} list == [a, b, c, d] ) * def list3 = list.toUnique{ it.toString() } - * assert( list3 == [a, b, c] && list == [a, b, c, d] ) + * assert( list3 == [a, b, c] {@code &&} list == [a, b, c, d] ) * * * @param self an Iterable @@ -2012,10 +2012,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Person d = new Person(fname:"Clark", lname:"Taylor") * * def list = [a, b, c, d] - * def list2 = list.toUnique{ p1, p2 -> p1.lname != p2.lname ? p1.lname <=> p2.lname : p1.fname <=> p2.fname } - * assert( list2 == [a, b, c] && list == [a, b, c, d] ) + * def list2 = list.toUnique{ p1, p2 {@code ->} p1.lname != p2.lname ? p1.lname <=> p2.lname : p1.fname <=> p2.fname } + * assert( list2 == [a, b, c] {@code &&} list == [a, b, c, d] ) * def list3 = list.toUnique{ it.toString() } - * assert( list3 == [a, b, c] && list == [a, b, c, d] ) + * assert( list3 == [a, b, c] {@code &&} list == [a, b, c, d] ) * * * @param self a List @@ -2036,7 +2036,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * String[] letters = ['c', 'a', 't', 's', 'A', 't', 'h', 'a', 'T'] * String[] lower = ['c', 'a', 't', 's', 'h'] * class LowerComparator implements Comparator { - * int compare(let1, let2) { let1.toLowerCase() <=> let2.toLowerCase() } + * int compare(let1, let2) { let1.toLowerCase() {@code <=>} let2.toLowerCase() } * } * assert letters.toUnique(new LowerComparator()) == lower * @@ -2080,7 +2080,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { *
* String[] letters = ['c', 'a', 't', 's', 'A', 't', 'h', 'a', 'T'] * String[] expected = ['c', 'a', 't', 's', 'h'] - * assert letters.toUnique{ p1, p2 -> p1.toLowerCase() <=> p2.toLowerCase() } == expected + * assert letters.toUnique{ p1, p2 {@code ->} p1.toLowerCase() {@code <=>} p2.toLowerCase() } == expected * assert letters.toUnique{ it.toLowerCase() } == expected ** @@ -2145,7 +2145,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { *
* String[] letters = ['a', 'b', 'c'] * String result = '' - * letters.eachWithIndex{ letter, index -> result += "$index:$letter" } + * letters.eachWithIndex{ letter, index {@code ->} result += "$index:$letter" } * assert result == '0:a1:b2:c' ** @@ -2171,7 +2171,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * zero) to the given closure. *
* String result = '' - * ['a', 'b', 'c'].eachWithIndex{ letter, index -> result += "$index:$letter" } + * ['a', 'b', 'c'].eachWithIndex{ letter, index {@code ->} result += "$index:$letter" } * assert result == '0:a1:b2:c' ** @@ -2365,10 +2365,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * otherwise if the closure takes two parameters then it will be * passed the key and the value. *
def result = "" - * [a:1, b:3].each { key, value -> result += "$key$value" } + * [a:1, b:3].each { key, value {@code ->} result += "$key$value" } * assert result == "a1b3"*
def result = "" - * [a:1, b:3].each { entry -> result += entry } + * [a:1, b:3].each { entry {@code ->} result += entry } * assert result == "a=1b=3"* * In general, the order in which the map contents are processed @@ -2417,10 +2417,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * takes three parameters then it will be passed the key, the value, and * the index. *
def result = "" - * [a:1, b:3].eachWithIndex { key, value, index -> result += "$index($key$value)" } + * [a:1, b:3].eachWithIndex { key, value, index {@code ->} result += "$index($key$value)" } * assert result == "0(a1)1(b3)"*
def result = "" - * [a:1, b:3].eachWithIndex { entry, index -> result += "$index($entry)" } + * [a:1, b:3].eachWithIndex { entry, index {@code ->} result += "$index($entry)" } * assert result == "0(a=1)1(b=3)"* * @param self the map over which we iterate @@ -2470,7 +2470,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { *
true
for all items in this data structure).
* A simple example for a list:
* def list = [3,4,5] - * def greaterThanTwo = list.every { it > 2 } + * def greaterThanTwo = list.every { it {@code >} 2 } ** * @param self the object over which we iterate @@ -2487,7 +2487,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { *
true
for all items in this iterator).
* A simple example for a list:
* def list = [3,4,5] - * def greaterThanTwo = list.iterator().every { it > 2 } + * def greaterThanTwo = list.iterator().every { it {@code >} 2 } ** * @param self the iterator over which we iterate @@ -2523,7 +2523,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { *
true
for all items in this iterable).
* A simple example for a list:
* def list = [3,4,5] - * def greaterThanTwo = list.every { it > 2 } + * def greaterThanTwo = list.every { it {@code >} 2 } ** * @param self the iterable over which we iterate @@ -2542,8 +2542,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * otherwise if the closure takes two parameters then it will be * passed the key and the value. *
def map = [a:1, b:2.0, c:2L] - * assert !map.every { key, value -> value instanceof Integer } - * assert map.every { entry -> entry.value instanceof Number }+ * assert !map.every { key, value {@code ->} value instanceof Integer } + * assert map.every { entry {@code ->} entry.value instanceof Number } * * @param self the map over which we iterate * @param predicate the 1 or 2 arg Closure predicate used for matching @@ -2563,7 +2563,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Iterates over every element of a collection, and checks whether all * elements are
true
according to the Groovy Truth.
- * Equivalent to self.every({element -> element})
+ * Equivalent to self.every({element {@code ->} element})
* * assert [true, true].every() * assert [1, 1].every() @@ -2589,7 +2589,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * predicate is valid for at least one element. ** assert [1, 2, 3].any { it == 2 } - * assert ![1, 2, 3].any { it > 3 } + * assert ![1, 2, 3].any { it {@code >} 3 } ** * @param self the object over which we iterate @@ -2606,7 +2606,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * predicate is valid for at least one element. ** assert [1, 2, 3].iterator().any { it == 2 } - * assert ![1, 2, 3].iterator().any { it > 3 } + * assert ![1, 2, 3].iterator().any { it {@code >} 3 } ** * @param self the iterator over which we iterate @@ -2627,7 +2627,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * predicate is valid for at least one element. ** assert [1, 2, 3].any { it == 2 } - * assert ![1, 2, 3].any { it > 3 } + * assert ![1, 2, 3].any { it {@code >} 3 } ** * @param self the iterable over which we iterate @@ -2659,8 +2659,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * otherwise if the closure takes two parameters then it will be * passed the key and the value. *- * assert [2:3, 4:5, 5:10].any { key, value -> key * 2 == value } - * assert ![2:3, 4:5, 5:10].any { entry -> entry.key == entry.value * 2 } + * assert [2:3, 4:5, 5:10].any { key, value {@code ->} key * 2 == value } + * assert ![2:3, 4:5, 5:10].any { entry {@code ->} entry.key == entry.value * 2 } ** * @param self the map over which we iterate @@ -2681,7 +2681,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Iterates over the elements of a collection, and checks whether at least * one element is true according to the Groovy Truth. - * Equivalent to self.any({element -> element}) + * Equivalent to self.any({element {@code ->} element}) ** assert [false, true].any() * assert [0, 1].any() @@ -3041,7 +3041,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Otherwise, the closure should take two parameters and will be passed the key and value. ** Note: When using the list-style of result, the behavior is '* Example usage: - *
assert [a:1, b:1, c:2, d:2].count{ k,v -> k == 'a' || v == 2 } == 3+ *assert [a:1, b:1, c:2, d:2].count{ k,v {@code ->} k == 'a' {@code ||} v == 2 } == 3* * @param self the map within which we count the number of occurrences * @param closure a 1 or 2 arg Closure condition applying on the entries @@ -3785,7 +3785,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * assert squaresAndCubesOfEvens == [4, 8, 16, 64, 36, 216, 64, 512, 100, 1000] * * def animals = ['CAT', 'DOG', 'ELEPHANT'] as Set - * def smallAnimals = animals.collectMany{ it.size() > 3 ? [] : [it.toLowerCase()] } + * def smallAnimals = animals.collectMany{ it.size() {@code >} 3 ? [] : [it.toLowerCase()] } * assert smallAnimals == ['cat', 'dog'] * * def orig = nums as Set @@ -3810,7 +3810,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { **
* def animals = ['CAT', 'DOG', 'ELEPHANT'] as Set - * def smallAnimals = animals.collectMany(['ant', 'bee']){ it.size() > 3 ? [] : [it.toLowerCase()] } + * def smallAnimals = animals.collectMany(['ant', 'bee']){ it.size() {@code >} 3 ? [] : [it.toLowerCase()] } * assert smallAnimals == ['ant', 'bee', 'cat', 'dog'] * * def nums = 1..5 @@ -3837,7 +3837,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { ** Note: When using the list-style of result, the behavior is '*
* def map = [bread:3, milk:5, butter:2] - * def result = map.collectMany(['x']){ k, v -> k.startsWith('b') ? k.toList() : [] } + * def result = map.collectMany(['x']){ k, v {@code ->} k.startsWith('b') ? k.toList() : [] } * assert result == ['x', 'b', 'r', 'e', 'a', 'd', 'b', 'u', 't', 't', 'e', 'r'] ** @@ -3860,7 +3860,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { **
* def map = [bread:3, milk:5, butter:2] - * def result = map.collectMany{ k, v -> k.startsWith('b') ? k.toList() : [] } + * def result = map.collectMany{ k, v {@code ->} k.startsWith('b') ? k.toList() : [] } * assert result == ['b', 'r', 'e', 'a', 'd', 'b', 'u', 't', 't', 'e', 'r'] ** @@ -3916,8 +3916,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Iterates through this Map transforming each map entry into a new value using thetransform
closure * returning thecollector
with all transformed values added to it. - *assert [a:1, b:2].collect( [] as HashSet ) { key, value -> key*value } == ["a", "bb"] as Set - * assert [3:20, 2:30].collect( [] as HashSet ) { entry -> entry.key * entry.value } == [60] as Set+ *assert [a:1, b:2].collect( [] as HashSet ) { key, value {@code ->} key*value } == ["a", "bb"] as Set + * assert [3:20, 2:30].collect( [] as HashSet ) { entry {@code ->} entry.key * entry.value } == [60] as Set* * @param self a Map * @param collector the Collection to which transformed values are added @@ -3935,8 +3935,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Iterates through this Map transforming each map entry into a new value using thetransform
closure * returning a list of transformed values. - *assert [a:1, b:2].collect { key, value -> key*value } == ["a", "bb"] - * assert [3:20, 2:30].collect { entry -> entry.key * entry.value } == [60, 60]+ *assert [a:1, b:2].collect { key, value {@code ->} key*value } == ["a", "bb"] + * assert [3:20, 2:30].collect { entry {@code ->} entry.key * entry.value } == [60, 60]* * @param self a Map * @param transform the transformation closure which can take one (Map.Entry) or two (key, value) parameters @@ -3951,8 +3951,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Iterates through this Map transforming each map entry using thetransform
closure * returning a map of the transformed entries. *- * assert [a:1, b:2].collectEntries( [:] ) { k, v -> [v, k] } == [1:'a', 2:'b'] - * assert [a:1, b:2].collectEntries( [30:'C'] ) { key, value -> + * assert [a:1, b:2].collectEntries( [:] ) { k, v {@code ->} [v, k] } == [1:'a', 2:'b'] + * assert [a:1, b:2].collectEntries( [30:'C'] ) { key, value {@code ->} * [(value*10): key.toUpperCase()] } == [10:'A', 20:'B', 30:'C'] ** Note: When using the list-style of result, the behavior is 'def (key, value) = listResultFromClosure
'. @@ -3979,8 +3979,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Iterates through this Map transforming each entry using thetransform
closure * and returning a map of the transformed entries. *- * assert [a:1, b:2].collectEntries { key, value -> [value, key] } == [1:'a', 2:'b'] - * assert [a:1, b:2].collectEntries { key, value -> + * assert [a:1, b:2].collectEntries { key, value {@code ->} [value, key] } == [1:'a', 2:'b'] + * assert [a:1, b:2].collectEntries { key, value {@code ->} * [(value*10): key.toUpperCase()] } == [10:'A', 20:'B'] ** Note: When using the list-style of result, the behavior is 'def (key, value) = listResultFromClosure
'. @@ -4029,9 +4029,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { ** def letters = "abc" * // collect letters with index using list style - * assert (0..2).collectEntries { index -> [index, letters[index]] } == [0:'a', 1:'b', 2:'c'] + * assert (0..2).collectEntries { index {@code ->} [index, letters[index]] } == [0:'a', 1:'b', 2:'c'] * // collect letters with index using map style - * assert (0..2).collectEntries { index -> [(index): letters[index]] } == [0:'a', 1:'b', 2:'c'] + * assert (0..2).collectEntries { index {@code ->} [(index): letters[index]] } == [0:'a', 1:'b', 2:'c'] ** Note: When using the list-style of result, the behavior is 'def (key, value) = listResultFromClosure
'. * While we strongly discourage using a list of size other than 2, Groovy's normal semantics apply in this case; @@ -4124,8 +4124,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { ** def letters = "abc" * // collect letters with index - * assert (0..2).collectEntries( [:] ) { index -> [index, letters[index]] } == [0:'a', 1:'b', 2:'c'] - * assert (0..2).collectEntries( [4:'d'] ) { index -> + * assert (0..2).collectEntries( [:] ) { index {@code ->} [index, letters[index]] } == [0:'a', 1:'b', 2:'c'] + * assert (0..2).collectEntries( [4:'d'] ) { index {@code ->} * [(index+1): letters[index]] } == [1:'a', 2:'b', 3:'c', 4:'d'] ** Note: When using the list-style of result, the behavior is 'def (key, value) = listResultFromClosure
'. @@ -4190,8 +4190,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * def letters = "abc" * def nums = [0, 1, 2] as Integer[] * // collect letters with index - * assert nums.collectEntries( [:] ) { index -> [index, letters[index]] } == [0:'a', 1:'b', 2:'c'] - * assert nums.collectEntries( [4:'d'] ) { index -> + * assert nums.collectEntries( [:] ) { index {@code ->} [index, letters[index]] } == [0:'a', 1:'b', 2:'c'] + * assert nums.collectEntries( [4:'d'] ) { index {@code ->} * [(index+1): letters[index]] } == [1:'a', 2:'b', 3:'c', 4:'d'] *def (key, value) = listResultFromClosure
'. @@ -4232,9 +4232,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * def letters = "abc" * def nums = [0, 1, 2] as Integer[] * // collect letters with index using list style - * assert nums.collectEntries { index -> [index, letters[index]] } == [0:'a', 1:'b', 2:'c'] + * assert nums.collectEntries { index {@code ->} [index, letters[index]] } == [0:'a', 1:'b', 2:'c'] * // collect letters with index using map style - * assert nums.collectEntries { index -> [(index): letters[index]] } == [0:'a', 1:'b', 2:'c'] + * assert nums.collectEntries { index {@code ->} [(index): letters[index]] } == [0:'a', 1:'b', 2:'c'] *def (key, value) = listResultFromClosure
'. * While we strongly discourage using a list of size other than 2, Groovy's normal semantics apply in this case; @@ -4291,7 +4291,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * ** def numbers = [1, 2, 3] - * def result = numbers.find { it > 1} + * def result = numbers.find { it {@code >} 1} * assert result == 2 ** @@ -4332,7 +4332,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Finds the first value matching the closure condition. Example: *def list = [1,2,3] - * assert 2 == list.find { it > 1 } + * assert 2 == list.find { it {@code >} 1 } ** * @param self a Collection @@ -4355,8 +4355,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example: ** def list = [1,2,3] as Integer[] - * assert 2 == list.find { it > 1 } - * assert null == list.find { it > 5 } + * assert 2 == list.find { it {@code >} 1 } + * assert null == list.find { it {@code >} 5 } ** * @param self an Array @@ -4397,8 +4397,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { **
* int[] numbers = [1, 2, 3] - * assert numbers.findResult { if(it > 1) return it } == 2 - * assert numbers.findResult { if(it > 4) return it } == null + * assert numbers.findResult { if(it {@code >} 1) return it } == 2 + * assert numbers.findResult { if(it {@code >} 4) return it } == null ** * @param self an Object with an iterator returning its values @@ -4422,8 +4422,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { **
* int[] numbers = [1, 2, 3] - * assert numbers.findResult(5) { if(it > 1) return it } == 2 - * assert numbers.findResult(5) { if(it > 4) return it } == 5 + * assert numbers.findResult(5) { if(it {@code >} 1) return it } == 2 + * assert numbers.findResult(5) { if(it {@code >} 4) return it } == 5 ** * @param self an Object with an iterator returning its values @@ -4476,8 +4476,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Examples: ** def iter = [1,2,3].iterator() - * assert "Found 2" == iter.findResult("default") { it > 1 ? "Found $it" : null } - * assert "default" == iter.findResult("default") { it > 3 ? "Found $it" : null } + * assert "Found 2" == iter.findResult("default") { it {@code >} 1 ? "Found $it" : null } + * assert "default" == iter.findResult("default") { it {@code >} 3 ? "Found $it" : null } ** * @param self an Iterator @@ -4519,8 +4519,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Examples: ** def list = [1,2,3] - * assert "Found 2" == list.findResult("default") { it > 1 ? "Found $it" : null } - * assert "default" == list.findResult("default") { it > 3 ? "Found $it" : null } + * assert "Found 2" == list.findResult("default") { it {@code >} 1 ? "Found $it" : null } + * assert "default" == list.findResult("default") { it {@code >} 3 ? "Found $it" : null } ** * @param self an Iterable @@ -4582,7 +4582,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { ** assert "Found b:3" == [a:1, b:3].findResult { if (it.value == 3) return "Found ${it.key}:${it.value}" } * assert null == [a:1, b:3].findResult { if (it.value == 9) return "Found ${it.key}:${it.value}" } - * assert "Found a:1" == [a:1, b:3].findResult { k, v -> if (k.size() + v == 2) return "Found $k:$v" } + * assert "Found a:1" == [a:1, b:3].findResult { k, v {@code ->} if (k.size() + v == 2) return "Found $k:$v" } ** * @param self a Map @@ -4607,7 +4607,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { ** assert "Found b:3" == [a:1, b:3].findResult("default") { if (it.value == 3) return "Found ${it.key}:${it.value}" } * assert "default" == [a:1, b:3].findResult("default") { if (it.value == 9) return "Found ${it.key}:${it.value}" } - * assert "Found a:1" == [a:1, b:3].findResult("default") { k, v -> if (k.size() + v == 2) return "Found $k:$v" } + * assert "Found a:1" == [a:1, b:3].findResult("default") { k, v {@code ->} if (k.size() + v == 2) return "Found $k:$v" } ** * @param self a Map @@ -4639,7 +4639,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example: ** def list = [1,2,3] - * def result = list.findResults { it > 1 ? "Found $it" : null } + * def result = list.findResults { it {@code >} 1 ? "Found $it" : null } * assert result == ["Found 2", "Found 3"] ** @@ -4695,7 +4695,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example: ** def map = [a:1, b:2, hi:2, cat:3, dog:2] - * def result = map.findResults { k, v -> k.size() == v ? "Found $k:$v" : null } + * def result = map.findResults { k, v {@code ->} k.size() == v ? "Found $k:$v" : null } * assert result == ["Found a:1", "Found hi:2", "Found cat:3"] ** @@ -5031,7 +5031,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * take two parameters, which will be the key and the value. * *def map = [a:1, b:2] - * map.retainAll { k,v -> k == 'b' } + * map.retainAll { k,v {@code ->} k == 'b' } * assert map == [b:2]* * See alsofindAll
when wanting to produce a new map containing items @@ -5094,7 +5094,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * will be the key and the value. * *def map = [a:1, b:2] - * map.removeAll { k,v -> k == 'b' } + * map.removeAll { k,v {@code ->} k == 'b' } * assert map == [a:1]* * See alsofindAll
when wanting to produce a new map containing items @@ -5298,7 +5298,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Adds GroovyCollections#combinations(Iterable, Closure) as a method on collections. ** Example usage: - *
assert [[2, 3],[4, 5, 6]].combinations {x,y -> x*y } == [8, 12, 10, 15, 12, 18]+ *assert [[2, 3],[4, 5, 6]].combinations {x,y {@code ->} x*y } == [8, 12, 10, 15, 12, 18]* * @param self a Collection of lists * @param function a closure to be called on each combination @@ -5375,7 +5375,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * into a list. ** Example usage: - *
Set result = [1, 2, 3].permutations { it.collect { v -> 2*v }} + ** Edge case for multiple max values: *Set result = [1, 2, 3].permutations { it.collect { v {@code ->} 2*v }} * assert result == [[6, 4, 2], [6, 2, 4], [2, 6, 4], [4, 6, 2], [4, 2, 6], [2, 4, 6]] as Set* * @param self the Iterable of items @@ -5558,7 +5558,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * of items for that 'group path'. * * Example usage: - *def result = [1,2,3,4,5,6].groupBy({ it % 2 }, { it < 4 }) + **def result = [1,2,3,4,5,6].groupBy({ it % 2 }, { it {@code <} 4 }) * assert result == [1:[(true):[1, 3], (false):[5]], 0:[(true):[2], (false):[4, 6]]]* * Another example: @@ -5591,7 +5591,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { final Object[] tail = new Object[closures.length - 1]; System.arraycopy(closures, 1, tail, 0, closures.length - 1); // Arrays.copyOfRange only since JDK 1.6 - // inject([:]) { a,e -> a << [(e.key): e.value.groupBy(tail)] } + // inject([:]) { a,e {@code ->} a {@code <<} [(e.key): e.value.groupBy(tail)] } Map- * def lastDigit = { a, b -> a % 10 <=> b % 10 } + * def lastDigit = { a, b {@code ->} a % 10 {@code <=>} b % 10 } * assert [19, 55, 91].min(lastDigit) == 91 **@@ -7123,13 +7123,13 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * def zoo = [monkeys:6, lions:5, tigers:7] * def leastCommonEntry = zoo.min{ it.value } * assert leastCommonEntry.value == 5 - * def mostCommonEntry = zoo.min{ a, b -> b.value <=> a.value } // double negative! + * def mostCommonEntry = zoo.min{ a, b {@code ->} b.value {@code <=>} a.value } // double negative! * assert mostCommonEntry.value == 7 ** Edge case for multiple min values: ** def zoo = [monkeys:6, lions:5, tigers:7] - * def lastCharOfName = { e -> e.key[-1] } + * def lastCharOfName = { e {@code ->} e.key[-1] } * def ans = zoo.min(lastCharOfName) // some random entry * assert lastCharOfName(ans) == 's' *@@ -7161,13 +7161,13 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * def zoo = [monkeys:6, lions:5, tigers:7] * def mostCommonEntry = zoo.max{ it.value } * assert mostCommonEntry.value == 7 - * def leastCommonEntry = zoo.max{ a, b -> b.value <=> a.value } // double negative! + * def leastCommonEntry = zoo.max{ a, b {@code ->} b.value {@code <=>} a.value } // double negative! * assert leastCommonEntry.value == 5 ** def zoo = [monkeys:6, lions:5, tigers:7] - * def lengthOfNamePlusNumber = { e -> e.key.size() + e.value } + * def lengthOfNamePlusNumber = { e {@code ->} e.key.size() + e.value } * def ans = zoo.max(lengthOfNamePlusNumber) // one of [monkeys:6, tigers:7] * assert lengthOfNamePlusNumber(ans) == 13 *@@ -7304,7 +7304,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Comparable (typically an Integer) which is then used for * further comparison. *assert "hello" == ["hello","hi","hey"].max { it.length() }- *assert "hello" == ["hello","hi","hey"].max { a, b -> a.length() <=> b.length() }+ *assert "hello" == ["hello","hi","hey"].max { a, b {@code ->} a.length() {@code <=>} b.length() }** def pets = ['dog', 'elephant', 'anaconda'] * def longestName = pets.max{ it.size() } // one of 'elephant' or 'anaconda' @@ -7398,7 +7398,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Selects the maximum value found in the Iterable using the given comparator. *- * assert "hello" == ["hello","hi","hey"].max( { a, b -> a.length() <=> b.length() } as Comparator ) + * assert "hello" == ["hello","hi","hey"].max( { a, b {@code ->} a.length() {@code <=>} b.length() } as Comparator ) ** * @param self an Iterable @@ -7466,7 +7466,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example: ** String[] letters = ['a', 'b', 'c', 'd'] - * assert 0..<4 == letters.indices + * {@code assert 0..<4 == letters.indices} ** * @param self an array @@ -7623,8 +7623,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Support the range subscript operator for an eager or lazy List. - *def list = [true, 1, 3.4].withDefault{ 42 } - * assert list[0..<0] == []+ *+ * def list = [true, 1, 3.4].withDefault{ 42 } + * {@code assert list[0..<0] == []} + ** * @param self a ListWithDefault * @param range a Range indicating the items to get @@ -7638,8 +7640,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Support the range subscript operator for a List. - *def list = [true, 1, 3.4] - * assert list[0..<0] == []+ *+ * def list = [true, 1, 3.4] + * {@code assert list[0..<0] == []} + ** * @param self a List * @param range a Range indicating the items to get @@ -7967,9 +7971,11 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * A helper method to allow lists to work with subscript operators. - *def list = ["a", true] - * list[1..<1] = 5 - * assert list == ["a", 5, true]+ *+ * def list = ["a", true] + * {@code list[1..<1] = 5} + * assert list == ["a", 5, true] + ** * @param self a List * @param range the (in this case empty) subset of the list to set @@ -7991,9 +7997,11 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * A helper method to allow lists to work with subscript operators. - *def list = ["a", true] - * list[1..<1] = [4, 3, 2] - * assert list == ["a", 4, 3, 2, true]+ *+ * def list = ["a", true] + * {@code list[1..<1] = [4, 3, 2]} + * assert list == ["a", 4, 3, 2, true] + ** * @param self a List * @param range the (in this case empty) subset of the list to set @@ -8580,9 +8588,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * result of calling the supplied Closure with the key as the parameter to the Closure. * Example usage: *- * def map = [a:1, b:2].withDefault{ k -> k.toCharacter().isLowerCase() ? 10 : -10 } + * def map = [a:1, b:2].withDefault{ k {@code ->} k.toCharacter().isLowerCase() ? 10 : -10 } * def expected = [a:1, b:2, c:10, D:-10] - * assert expected.every{ e -> e.value == map[e.key] } + * assert expected.every{ e {@code ->} e.value == map[e.key] } * * def constMap = [:].withDefault{ 42 } * assert constMap.foo == 42 @@ -8644,7 +8652,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * assert list == [0, 1, null, 42] // gap filled with null * * // illustrate using the index when generating default values - * def list2 = [5].withLazyDefault{ index -> index * index } + * def list2 = [5].withLazyDefault{ index {@code ->} index * index } * assert list2[3] == 9 * assert list2 == [5, null, null, 9] * assert list2[2] == 4 @@ -8690,7 +8698,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * assert list == [0, 1, 42, 42] // gap filled with default value * * // illustrate using the index when generating default values - * def list2 = [5].withEagerDefault{ index -> index * index } + * def list2 = [5].withEagerDefault{ index {@code ->} index * index } * assert list2[3] == 9 * assert list2 == [5, 1, 4, 9] * @@ -8720,7 +8728,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example usage: ** assert [["a", 0], ["b", 1]] == ["a", "b"].withIndex() - * assert ["0: a", "1: b"] == ["a", "b"].withIndex().collect { str, idx -> "$idx: $str" } + * assert ["0: a", "1: b"] == ["a", "b"].withIndex().collect { str, idx {@code ->} "$idx: $str" } ** * @param self an Iterable @@ -8738,7 +8746,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example usage: ** assert [0: "a", 1: "b"] == ["a", "b"].indexed() - * assert ["0: a", "1: b"] == ["a", "b"].indexed().collect { idx, str -> "$idx: $str" } + * assert ["0: a", "1: b"] == ["a", "b"].indexed().collect { idx, str {@code ->} "$idx: $str" } ** * @param self an Iterable @@ -8756,7 +8764,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example usage: ** assert [["a", 5], ["b", 6]] == ["a", "b"].withIndex(5) - * assert ["1: a", "2: b"] == ["a", "b"].withIndex(1).collect { str, idx -> "$idx: $str" } + * assert ["1: a", "2: b"] == ["a", "b"].withIndex(1).collect { str, idx {@code ->} "$idx: $str" } ** * @param self an Iterable @@ -8775,7 +8783,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example usage: ** assert [5: "a", 6: "b"] == ["a", "b"].indexed(5) - * assert ["1: a", "2: b"] == ["a", "b"].indexed(1).collect { idx, str -> "$idx: $str" } + * assert ["1: a", "2: b"] == ["a", "b"].indexed(1).collect { idx, str {@code ->} "$idx: $str" } ** * @param self an Iterable @@ -8800,7 +8808,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example usage: ** assert [["a", 0], ["b", 1]] == ["a", "b"].iterator().withIndex().toList() - * assert ["0: a", "1: b"] == ["a", "b"].iterator().withIndex().collect { str, idx -> "$idx: $str" }.toList() + * assert ["0: a", "1: b"] == ["a", "b"].iterator().withIndex().collect { str, idx {@code ->} "$idx: $str" }.toList() ** * @param self an iterator @@ -8817,8 +8825,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * * Example usage: *- * assert [[0, "a"], [1, "b"]] == ["a", "b"].iterator().indexed().collect{ tuple -> [tuple.first, tuple.second] } - * assert ["0: a", "1: b"] == ["a", "b"].iterator().indexed().collect { idx, str -> "$idx: $str" }.toList() + * assert [[0, "a"], [1, "b"]] == ["a", "b"].iterator().indexed().collect{ tuple {@code ->} [tuple.first, tuple.second] } + * assert ["0: a", "1: b"] == ["a", "b"].iterator().indexed().collect { idx, str {@code ->} "$idx: $str" }.toList() ** * @param self an iterator @@ -8836,7 +8844,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example usage: ** assert [["a", 5], ["b", 6]] == ["a", "b"].iterator().withIndex(5).toList() - * assert ["1: a", "2: b"] == ["a", "b"].iterator().withIndex(1).collect { str, idx -> "$idx: $str" }.toList() + * assert ["1: a", "2: b"] == ["a", "b"].iterator().withIndex(1).collect { str, idx {@code ->} "$idx: $str" }.toList() ** * @param self an iterator @@ -8855,7 +8863,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Example usage: ** assert [[5, "a"], [6, "b"]] == ["a", "b"].iterator().indexed(5).toList() - * assert ["a: 1", "b: 2"] == ["a", "b"].iterator().indexed(1).collect { idx, str -> "$str: $idx" }.toList() + * assert ["a: 1", "b: 2"] == ["a", "b"].iterator().indexed(1).collect { idx, str {@code ->} "$str: $idx" }.toList() ** * @param self an iterator @@ -8980,7 +8988,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Sorts the elements from the given map into a new ordered map using * the closure as a comparator to determine the ordering. * The original map is unchanged. - *def map = [a:5, b:3, c:6, d:4].sort { a, b -> a.value <=> b.value } + *def map = [a:5, b:3, c:6, d:4].sort { a, b {@code ->} a.value {@code <=>} b.value } * assert map == [b:3, d:4, a:5, c:6]* * @param self the original unsorted map @@ -9002,7 +9010,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Sorts the elements from the given map into a new ordered Map using * the specified key comparator to determine the ordering. * The original map is unchanged. - *def map = [ba:3, cz:6, ab:5].sort({ a, b -> a[-1] <=> b[-1] } as Comparator) + *def map = [ba:3, cz:6, ab:5].sort({ a, b {@code ->} a[-1] {@code <=>} b[-1] } as Comparator) * assert map*.value == [3, 5, 6]* * @param self the original unsorted map @@ -9123,7 +9131,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * is true, it is sorted in place and returned. Otherwise, the elements are first placed * into a new list which is then sorted and returned - leaving the original Iterable unchanged. *- * assert ["hi","hey","hello"] == ["hello","hi","hey"].sort(false, { a, b -> a.length() <=> b.length() } as Comparator ) + * assert ["hi","hey","hello"] == ["hello","hi","hey"].sort(false, { a, b {@code ->} a.length() {@code <=>} b.length() } as Comparator ) *** def orig = ["hello","hi","Hey"] @@ -9289,7 +9297,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Comparable (typically an Integer) which is then used for * further comparison. *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { it.length() }- *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b -> a.length() <=> b.length() }+ *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b {@code ->} a.length() {@code <=>} b.length() }* * @param self the Iterable to be sorted * @param closure a 1 or 2 arg Closure used to determine the correct ordering @@ -9315,7 +9323,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Comparable (typically an Integer) which is then used for * further comparison. *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { it.length() }- *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b -> a.length() <=> b.length() }+ *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b {@code ->} a.length() {@code <=>} b.length() }** def orig = ["hello","hi","Hey"] * def sorted = orig.sort(false) { it.toUpperCase() } @@ -9419,7 +9427,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Comparable (typically an Integer) which is then used for * further comparison. ** * @param self an Iterable @@ -11148,9 +11156,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * true when passed each of the dropped entries (or key/value pairs). *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { it.length() }- *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b -> a.length() <=> b.length() }+ *assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b {@code ->} a.length() {@code <=>} b.length() }* * @param self the Iterable to be sorted * @param closure a 1 or 2 arg Closure used to determine the correct ordering @@ -9499,7 +9507,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Returns a sorted version of the given array using the supplied comparator to determine the resulting order. *- * def sumDigitsComparator = [compare: { num1, num2 -> num1.toString().toList()*.toInteger().sum() <=> num2.toString().toList()*.toInteger().sum() }] as Comparator + * def sumDigitsComparator = [compare: { num1, num2 {@code ->} num1.toString().toList()*.toInteger().sum() {@code <=>} num2.toString().toList()*.toInteger().sum() }] as Comparator * Integer[] nums = [9, 44, 222, 7000] * def result = nums.toSorted(sumDigitsComparator) * assert result instanceof Integer[] @@ -9569,8 +9577,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Sorts the elements from the given map into a new ordered map using * the supplied comparator to determine the ordering. The original map is unchanged. ** * @param self the Iterator @@ -11069,8 +11077,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * except that it attempts to preserve the type of the original SortedSet. *- * def keyComparator = [compare: { e1, e2 -> e1.key <=> e2.key }] as Comparator - * def valueComparator = [compare: { e1, e2 -> e1.value <=> e2.value }] as Comparator + * def keyComparator = [compare: { e1, e2 {@code ->} e1.key {@code <=>} e2.key }] as Comparator + * def valueComparator = [compare: { e1, e2 {@code ->} e1.value {@code <=>} e2.value }] as Comparator * def map1 = [a:5, b:3, d:4, c:6].toSorted(keyComparator) * assert map1.toString() == '[a:5, b:3, c:6, d:4]' * def map2 = [a:5, b:3, d:4, c:6].toSorted(valueComparator) @@ -9601,7 +9609,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * the Closure is assumed to take a single entry parameter and return a Comparable (typically an Integer) * which is then used for further comparison. ** * @param self an Iterable @@ -10919,9 +10927,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * except that it attempts to preserve the type of the original SortedSet. *- * def map = [a:5, b:3, c:6, d:4].toSorted { a, b -> a.value <=> b.value } + * def map = [a:5, b:3, c:6, d:4].toSorted { a, b {@code ->} a.value {@code <=>} b.value } * assert map.toString() == '[b:3, d:4, a:5, c:6]' ** @@ -10862,9 +10870,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * except that it attempts to preserve the type of the original list. ** def nums = [ 1, 3, 2 ] - * assert nums.takeWhile{ it < 1 } == [] - * assert nums.takeWhile{ it < 3 } == [ 1 ] - * assert nums.takeWhile{ it < 4 } == [ 1, 3, 2 ] + * assert nums.takeWhile{ it {@code <} 1 } == [] + * assert nums.takeWhile{ it {@code <} 3 } == [ 1 ] + * assert nums.takeWhile{ it {@code <} 4 } == [ 1, 3, 2 ] ** * @param self the original list @@ -10895,8 +10903,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Iteratoriterator() { "abc".iterator() } * } * def abc = new AbcIterable() - * assert abc.takeWhile{ it < 'b' } == ['a'] - * assert abc.takeWhile{ it <= 'b' } == ['a', 'b'] + * assert abc.takeWhile{ it {@code <} 'b' } == ['a'] + * assert abc.takeWhile{ it {@code <=} 'b' } == ['a', 'b'] * * def nums = [ 1, 2, 3 ] as SortedSet - * assert nums.takeWhile{ it < 1 } == [] as SortedSet - * assert nums.takeWhile{ it < 2 } == [ 1 ] as SortedSet - * assert nums.takeWhile{ it < 4 } == [ 1, 2, 3 ] as SortedSet + * assert nums.takeWhile{ it {@code <} 1 } == [] as SortedSet + * assert nums.takeWhile{ it {@code <} 2 } == [ 1 ] as SortedSet + * assert nums.takeWhile{ it {@code <} 4 } == [ 1, 2, 3 ] as SortedSet ** * @param self the original SortedSet @@ -10940,9 +10948,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * passed to the given closure evaluates to true. ** def shopping = [milk:1, bread:2, chocolate:3] - * assert shopping.takeWhile{ it.key.size() < 6 } == [milk:1, bread:2] + * assert shopping.takeWhile{ it.key.size() {@code <} 6 } == [milk:1, bread:2] * assert shopping.takeWhile{ it.value % 2 } == [milk:1] - * assert shopping.takeWhile{ k, v -> k.size() + v <= 7 } == [milk:1, bread:2] + * assert shopping.takeWhile{ k, v {@code ->} k.size() + v {@code <=} 7 } == [milk:1, bread:2] ** If the map instance does not have ordered keys, then this function could appear to take random * entries. Groovy by default uses LinkedHashMap, so this shouldn't be an issue in the main. @@ -10972,9 +10980,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * passed to the given closure evaluates to true. ** def nums = [ 1, 3, 2 ] as Integer[] - * assert nums.takeWhile{ it < 1 } == [] as Integer[] - * assert nums.takeWhile{ it < 3 } == [ 1 ] as Integer[] - * assert nums.takeWhile{ it < 4 } == [ 1, 3, 2 ] as Integer[] + * assert nums.takeWhile{ it {@code <} 1 } == [] as Integer[] + * assert nums.takeWhile{ it {@code <} 3 } == [ 1 ] as Integer[] + * assert nums.takeWhile{ it {@code <} 4 } == [ 1, 3, 2 ] as Integer[] ** * @param self the original array @@ -11006,9 +11014,9 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * def a = 0 * def iter = [ hasNext:{ true }, next:{ a++ } ] as Iterator * - * assert [].iterator().takeWhile{ it < 3 }.toList() == [] - * assert [1, 2, 3, 4, 5].iterator().takeWhile{ it < 3 }.toList() == [ 1, 2 ] - * assert iter.takeWhile{ it < 5 }.toList() == [ 0, 1, 2, 3, 4 ] + * assert [].iterator().takeWhile{ it {@code <} 3 }.toList() == [] + * assert [1, 2, 3, 4, 5].iterator().takeWhile{ it {@code <} 3 }.toList() == [ 1, 2 ] + * assert iter.takeWhile{ it {@code <} 5 }.toList() == [ 0, 1, 2, 3, 4 ] ** def nums = [ 1, 2, 3 ] as SortedSet - * assert nums.dropWhile{ it < 4 } == [] as SortedSet - * assert nums.dropWhile{ it < 2 } == [ 2, 3 ] as SortedSet + * assert nums.dropWhile{ it {@code <} 4 } == [] as SortedSet + * assert nums.dropWhile{ it {@code <} 2 } == [ 2, 3 ] as SortedSet * assert nums.dropWhile{ it != 3 } == [ 3 ] as SortedSet * assert nums.dropWhile{ it == 0 } == [ 1, 2, 3 ] as SortedSet *@@ -11092,8 +11100,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * except that it attempts to preserve the type of the original list. ** def nums = [ 1, 3, 2 ] - * assert nums.dropWhile{ it < 4 } == [] - * assert nums.dropWhile{ it < 3 } == [ 3, 2 ] + * assert nums.dropWhile{ it {@code <} 4 } == [] + * assert nums.dropWhile{ it {@code <} 3 } == [ 3, 2 ] * assert nums.dropWhile{ it != 2 } == [ 2 ] * assert nums.dropWhile{ it == 0 } == [ 1, 3, 2 ] *@@ -11125,8 +11133,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Iteratoriterator() { "horse".iterator() } * } * def horse = new HorseIterable() - * assert horse.dropWhile{ it < 'r' } == ['r', 's', 'e'] - * assert horse.dropWhile{ it <= 'r' } == ['s', 'e'] + * assert horse.dropWhile{ it {@code <} 'r' } == ['r', 's', 'e'] + * assert horse.dropWhile{ it {@code <=} 'r' } == ['s', 'e'] * * def shopping = [milk:1, bread:2, chocolate:3] - * assert shopping.dropWhile{ it.key.size() < 6 } == [chocolate:3] + * assert shopping.dropWhile{ it.key.size() {@code <} 6 } == [chocolate:3] * assert shopping.dropWhile{ it.value % 2 } == [bread:2, chocolate:3] - * assert shopping.dropWhile{ k, v -> k.size() + v <= 7 } == [chocolate:3] + * assert shopping.dropWhile{ k, v {@code ->} k.size() + v {@code <=} 7 } == [chocolate:3] ** If the map instance does not have ordered keys, then this function could appear to drop random * entries. Groovy by default uses LinkedHashMap, so this shouldn't be an issue in the main. @@ -11182,8 +11190,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * true when passed each of the dropped elements. ** def nums = [ 1, 3, 2 ] as Integer[] - * assert nums.dropWhile{ it <= 3 } == [ ] as Integer[] - * assert nums.dropWhile{ it < 3 } == [ 3, 2 ] as Integer[] + * assert nums.dropWhile{ it {@code <=} 3 } == [ ] as Integer[] + * assert nums.dropWhile{ it {@code <} 3 } == [ 3, 2 ] as Integer[] * assert nums.dropWhile{ it != 2 } == [ 2 ] as Integer[] * assert nums.dropWhile{ it == 0 } == [ 1, 3, 2 ] as Integer[] *@@ -11214,10 +11222,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * condition evaluates to true when passed each of the dropped elements. ** def a = 0 - * def iter = [ hasNext:{ a < 10 }, next:{ a++ } ] as Iterator - * assert [].iterator().dropWhile{ it < 3 }.toList() == [] - * assert [1, 2, 3, 4, 5].iterator().dropWhile{ it < 3 }.toList() == [ 3, 4, 5 ] - * assert iter.dropWhile{ it < 5 }.toList() == [ 5, 6, 7, 8, 9 ] + * def iter = [ hasNext:{ a {@code <} 10 }, next:{ a++ } ] as Iterator + * assert [].iterator().dropWhile{ it {@code <} 3 }.toList() == [] + * assert [1, 2, 3, 4, 5].iterator().dropWhile{ it {@code <} 3 }.toList() == [ 3, 4, 5 ] + * assert iter.dropWhile{ it {@code <} 5 }.toList() == [ 5, 6, 7, 8, 9 ] ** * @param self the Iterator @@ -12365,7 +12373,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { ** def one = ['a', 'B', 'c', 'd'] * def two = ['b', 'C', 'd', 'e'] - * def compareIgnoreCase = { a, b -> a.toLowerCase() <=> b.toLowerCase() } + * def compareIgnoreCase = { a, b {@code ->} a.toLowerCase() {@code <=>} b.toLowerCase() } * assert one.intersect(two) == ['d'] * assert two.intersect(one) == ['d'] * assert one.intersect(two, compareIgnoreCase) == ['b', 'C', 'd'] @@ -13246,7 +13254,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * collections have their contents (recursively) added to the new SortedSet. ** @@ -700,9 +700,9 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { ** Set nested = [[0,1],[2],3,[4],5] - * SortedSet sorted = new TreeSet({ a, b -> (a instanceof List ? a[0] : a) <=> (b instanceof List ? b[0] : b) } as Comparator) + * SortedSet sorted = new TreeSet({ a, b {@code ->} (a instanceof List ? a[0] : a) {@code <=>} (b instanceof List ? b[0] : b) } as Comparator) * sorted.addAll(nested) * assert [0,1,2,3,4,5] as SortedSet == sorted.flatten() *@@ -16018,9 +16026,11 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { * Iterates from this number down to the given number, inclusive, * decrementing by one each time. Each number is passed to the closure. * Example: - *10.5.downto(0) { + ** Prints numbers 10.5, 9.5 ... to 0.5. * * @param self a BigDecimal @@ -16060,9 +16070,11 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { /** * Iterates from this number up to the given number using a step increment. * Each intermediate number is passed to the given closure. Example: - *+ * 10.5.downto(0) { * println it - * }+ * } + *0.step( 10, 2 ) { + ** Prints even numbers 0 through 8. * * @param self a Number to start with diff --git a/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java index 2ac7385..5a9754e 100644 --- a/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java +++ b/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java @@ -478,7 +478,7 @@ public class IOGroovyMethods extends DefaultGroovyMethodsSupport { *+ * 0.step( 10, 2 ) { * println it - * }+ * } + ** def s = 'The 3 quick\nbrown 4 fox' * def result = '' - * new StringReader(s).splitEachLine(/\d/){ parts -> + * new StringReader(s).splitEachLine(/\d/){ parts {@code ->} * result += "${parts[0]}_${parts[1]}|" * } * assert result == 'The _ quick|brown _ fox|' @@ -508,7 +508,7 @@ public class IOGroovyMethods extends DefaultGroovyMethodsSupport { ** * @param self a File (that happens to be a folder/directory) diff --git a/src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java index 21ca04c..9e500d6 100644 --- a/src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java +++ b/src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java @@ -537,7 +537,7 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { * def text = "Groovy" * assert text.dropWhile{ false } == 'Groovy' * assert text.dropWhile{ true } == '' - * assert text.dropWhile{ it < 'Z' } == 'roovy' + * assert text.dropWhile{ it {@code <} 'Z' } == 'roovy' * assert text.dropWhile{ it != 'v' } == 'vy' ** def s = 'The 3 quick\nbrown 4 fox' * def result = '' - * new StringReader(s).splitEachLine(~/\d/){ parts -> + * new StringReader(s).splitEachLine(~/\d/){ parts {@code ->} * result += "${parts[0]}_${parts[1]}|" * } * assert result == 'The _ quick|brown _ fox|' diff --git a/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java index 3bdcb19..647f47d 100644 --- a/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java +++ b/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java @@ -766,7 +766,7 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { ** or with some help fromExpandoMetaClass
, you could do something like: *- * myFile.metaClass.setText = { String s -> delegate.setText(s, 'UTF-8') } + * myFile.metaClass.setText = { String s {@code ->} delegate.setText(s, 'UTF-8') } * myfile.text = 'some text' ** @@ -1285,8 +1285,8 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { ** def totalSize = 0 * def count = 0 - * def sortByTypeThenName = { a, b -> - * a.isFile() != b.isFile() ? a.isFile() <=> b.isFile() : a.name <=> b.name + * def sortByTypeThenName = { a, b {@code ->} + * a.isFile() != b.isFile() ? a.isFile() {@code <=>} b.isFile() : a.name {@code <=>} b.name * } * rootDir.traverse( * type : FILES, @@ -1296,7 +1296,7 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { * totalSize = 0; count = 0 }, * postRoot : true * sort : sortByTypeThenName - * ) {it -> totalSize += it.size(); count++ } + * ) {it {@code ->} totalSize += it.size(); count++ } ** * @param self a File (that happens to be a folder/directory) @@ -1511,14 +1511,14 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { * // collect names of files in baseDir matching supplied regex pattern * import static groovy.io.FileType.* * def names = [] - * baseDir.eachFileMatch FILES, ~/foo\d\.txt/, { names << it.name } + * baseDir.eachFileMatch FILES, ~/foo\d\.txt/, { names {@code <<} it.name } * assert names == ['foo1.txt', 'foo2.txt'] * * // remove all *.bak files in baseDir - * baseDir.eachFileMatch FILES, ~/.*\.bak/, { File bak -> bak.delete() } + * baseDir.eachFileMatch FILES, ~/.*\.bak/, { File bak {@code ->} bak.delete() } * - * // print out files > 4K in size from baseDir - * baseDir.eachFileMatch FILES, { new File(baseDir, it).size() > 4096 }, { println "$it.name ${it.size()}" } + * // print out files > 4K in size from baseDir + * baseDir.eachFileMatch FILES, { new File(baseDir, it).size() {@code >} 4096 }, { println "$it.name ${it.size()}" } ** assert "Groovy".collectReplacements{ it == 'o' ? '_O_' : null } == 'Gr_O__O_vy' * assert "Groovy".collectReplacements{ it.equalsIgnoreCase('O') ? '_O_' : null } == 'Gr_O__O_vy' - * assert "Groovy".collectReplacements{ char c -> c == 'o' ? '_O_' : null } == 'Gr_O__O_vy' - * assert "Groovy".collectReplacements{ Character c -> c == 'o' ? '_O_' : null } == 'Gr_O__O_vy' - * assert "B&W".collectReplacements{ it == '&' ? '&' : null } == 'B&W' + * assert "Groovy".collectReplacements{ char c {@code ->} c == 'o' ? '_O_' : null } == 'Gr_O__O_vy' + * assert "Groovy".collectReplacements{ Character c {@code ->} c == 'o' ? '_O_' : null } == 'Gr_O__O_vy' + * assert "B&W".collectReplacements{ {@code it == '&' ? '&' : null} } == 'B&W' ** * @param orig the original String @@ -972,19 +972,19 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { ** For example, if the pattern doesn't match, the result is null: *
- * assert "New York, NY".find(~/\d{5}/) { match -> return "-$match-"} == null + * assert "New York, NY".find(~/\d{5}/) { match {@code ->} return "-$match-"} == null ** * If it does match and we don't have any capture groups in our regex, there is a single parameter * on the closure that the match gets passed to: *- * assert "New York, NY 10292-0098".find(~/\d{5}/) { match -> return "-$match-"} == "-10292-" + * assert "New York, NY 10292-0098".find(~/\d{5}/) { match {@code ->} return "-$match-"} == "-10292-" ** * If we have capture groups in our expression, our closure has one parameter for the match, followed by * one for each of the capture groups: *- * assert "New York, NY 10292-0098".find(~/(\d{5})-?(\d{4})/) { match, zip, plusFour -> + * assert "New York, NY 10292-0098".find(~/(\d{5})-?(\d{4})/) { match, zip, plusFour {@code ->} * assert match == "10292-0098" * assert zip == "10292" * assert plusFour == "0098" @@ -995,7 +995,7 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { * the closure will be passed an array with the first element corresponding to the whole match, * followed by an element for each of the capture groups: *- * assert "New York, NY 10292-0098".find(~/(\d{5})-?(\d{4})/) { array -> + * assert "New York, NY 10292-0098".find(~/(\d{5})-?(\d{4})/) { array {@code ->} * assert array[0] == "10292-0098" * assert array[1] == "10292" * assert array[2] == "0098" @@ -1005,7 +1005,7 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { * If a capture group is optional, and doesn't match, then the corresponding value * for that capture group passed to the closure will be null as illustrated here: *- * assert "adsf 233-9999 adsf".find(~/(\d{3})?-?(\d{3})-(\d{4})/) { match, areaCode, exchange, stationNumber -> + * assert "adsf 233-9999 adsf".find(~/(\d{3})?-?(\d{3})-(\d{4})/) { match, areaCode, exchange, stationNumber {@code ->} * assert "233-9999" == match * assert null == areaCode * assert "233" == exchange @@ -1106,16 +1106,16 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { ** * class C (from c.jar) extends B (from b.jar) * * childLoader.find("C") - * --> parentLoader does know C.class, try to load it - * --> to load C.class it has to load B.class - * --> parentLoader is unable to find B.class in a.jar or c.jar - * --> NoClassDefFoundException! + ** For example, if the regex doesn't match, it returns an empty list: *
- * assert "foo".findAll(/(\w*) Fish/) { match, firstWord -> return firstWord } == [] + * assert "foo".findAll(/(\w*) Fish/) { match, firstWord {@code ->} return firstWord } == [] ** Any regular expression matches are passed to the closure, if there are no capture groups, there will be one parameter for the match: *- * assert "I could not, would not, with a fox.".findAll(/.ould/) { match -> "${match}n't"} == ["couldn't", "wouldn't"] + * assert "I could not, would not, with a fox.".findAll(/.ould/) { match {@code ->} "${match}n't"} == ["couldn't", "wouldn't"] ** If there are capture groups, the first parameter will be the match followed by one parameter for each capture group: ** def orig = "There's a Wocket in my Pocket" - * assert orig.findAll(/(.)ocket/) { match, firstLetter -> "$firstLetter > $match" } == ["W > Wocket", "P > Pocket"] + * assert orig.findAll(/(.)ocket/) { match, firstLetter {@code ->} "$firstLetter {@code >} $match" } == ["W {@code >} Wocket", "P {@code >} Pocket"] ** * @param self a CharSequence @@ -1170,17 +1170,17 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { ** For example, if the pattern doesn't match, it returns an empty list: *
- * assert "foo".findAll(~/(\w*) Fish/) { match, firstWord -> return firstWord } == [] + * assert "foo".findAll(~/(\w*) Fish/) { match, firstWord {@code ->} return firstWord } == [] ** Any regular expression matches are passed to the closure, if there are no capture groups, there will be one * parameter for the match: *- * assert "I could not, would not, with a fox.".findAll(~/.ould/) { match -> "${match}n't"} == ["couldn't", "wouldn't"] + * assert "I could not, would not, with a fox.".findAll(~/.ould/) { match {@code ->} "${match}n't"} == ["couldn't", "wouldn't"] ** If there are capture groups, the first parameter will be the match followed by one parameter for each capture group: ** def orig = "There's a Wocket in my Pocket" - * assert orig.findAll(~/(.)ocket/) { match, firstLetter -> "$firstLetter > $match" } == ["W > Wocket", "P > Pocket"] + * assert orig.findAll(~/(.)ocket/) { match, firstLetter {@code ->} "$firstLetter {@code >} $match" } == ["W {@code >} Wocket", "P {@code >} Pocket"] ** * @param self a CharSequence @@ -2507,14 +2507,14 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { ** assert "hello world".replaceAll("(o)") { it[0].toUpperCase() } == "hellO wOrld" * - * assert "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { Object[] it -> it[0].toUpperCase() }) == "FOOBAR-FOOBAR-" + * assert "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { Object[] it {@code ->} it[0].toUpperCase() }) == "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 "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { x, y, z -> z.toUpperCase() }) == "FOO-FOO-" + * assert "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { x, y, z {@code ->} z.toUpperCase() }) == "FOO-FOO-" * * // Here, * // x is the global string of the matched group @@ -2576,14 +2576,14 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { * // it[1] is the first string in the matched group * // it[2] is the second string in the matched group * - * assert "foobar-FooBar-".replaceAll(~"(([fF][oO]{2})[bB]ar)", { Object[] it -> it[0].toUpperCase() }) == "FOOBAR-FOOBAR-" + * assert "foobar-FooBar-".replaceAll(~"(([fF][oO]{2})[bB]ar)", { Object[] it {@code ->} it[0].toUpperCase() }) == "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 "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { x, y, z -> z.toUpperCase() }) == "FOO-FOO-" + * assert "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { x, y, z {@code ->} z.toUpperCase() }) == "FOO-FOO-" * * // Here, * // x is the global string of the matched group @@ -3322,10 +3322,10 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport { *+ **
* def text = "Groovy" - * assert text.takeWhile{ it < 'A' } == '' - * assert text.takeWhile{ it < 'Z' } == 'G' + * assert text.takeWhile{ it {@code <} 'A' } == '' + * assert text.takeWhile{ it {@code <} 'Z' } == 'G' * assert text.takeWhile{ it != 'v' } == 'Groo' - * assert text.takeWhile{ it < 'z' } == 'Groovy' + * assert text.takeWhile{ it {@code <} 'z' } == 'Groovy' ** * @param self the original CharSequence diff --git a/src/main/java/org/codehaus/groovy/tools/RootLoader.java b/src/main/java/org/codehaus/groovy/tools/RootLoader.java index 84588da..46e0d5f 100644 --- a/src/main/java/org/codehaus/groovy/tools/RootLoader.java +++ b/src/main/java/org/codehaus/groovy/tools/RootLoader.java @@ -38,8 +38,7 @@ import java.util.Map; * classloaders. Normal is to first check parent and then look in * the resources you gave this classloader. *- * It's possible to add urls to the classpath at runtime through - * {@link addURL(URL)} + * It's possible to add urls to the classpath at runtime through {@link #addURL(URL)}. *
* Why using RootLoader? * If you have to load classes with multiple classloaders and a @@ -57,15 +56,17 @@ import java.util.Map; * | * | * childLoader (has classpath: a.jar;b.jar;c.jar) - *
+ * --> parentLoader does know C.class, try to load it + * --> to load C.class it has to load B.class + * --> parentLoader is unable to find B.class in a.jar or c.jar + * --> NoClassDefFoundException! + ** * if childLoader had tried to load the class by itself, there * would be no problem. Changing childLoader to be a RootLoader diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java index d4df7be..2224f5d 100644 --- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java +++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java @@ -351,7 +351,7 @@ public abstract class StaticTypeCheckingSupport { * * @param params method parameters * @param args type arguments - * @return -1 if arguments do not match, 0 if arguments are of the exact type and >0 when one or more argument is + * @return -1 if arguments do not match, 0 if arguments are of the exact type and > 0 when one or more argument is * not of the exact type but still match */ public static int allParametersAndArgumentsMatch(Parameter[] params, ClassNode[] args) {