You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2016/03/04 20:58:49 UTC

groovy git commit: test more javadoc code examples

Repository: groovy
Updated Branches:
  refs/heads/master c04484a66 -> 870a1bca4


test more javadoc code examples


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/870a1bca
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/870a1bca
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/870a1bca

Branch: refs/heads/master
Commit: 870a1bca40e1c831101c64053edee603c43b3d0e
Parents: c04484a
Author: pascalschumacher <pa...@gmx.net>
Authored: Fri Mar 4 20:57:43 2016 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Mar 4 20:57:43 2016 +0100

----------------------------------------------------------------------
 src/main/groovy/lang/TracingInterceptor.java    |  2 +-
 src/main/groovy/transform/Canonical.groovy      |  3 ++-
 .../groovy/transform/EqualsAndHashCode.java     | 12 +++++----
 src/main/groovy/transform/Field.java            |  3 ++-
 src/main/groovy/transform/Immutable.java        |  6 ++---
 src/main/groovy/transform/MapConstructor.java   |  2 +-
 src/main/groovy/transform/TailRecursive.groovy  |  3 ++-
 .../transform/builder/DefaultStrategy.java      |  6 ++---
 .../transform/builder/ExternalStrategy.java     |  2 +-
 .../transform/builder/SimpleStrategy.java       |  2 +-
 src/main/groovy/util/ConfigObject.java          |  2 +-
 src/main/groovy/util/Eval.java                  | 26 ++++++++++----------
 .../ast/expr/ElvisOperatorExpression.java       |  2 +-
 .../groovy/runtime/ComposedClosure.java         |  2 +-
 .../codehaus/groovy/runtime/CurriedClosure.java |  2 +-
 .../groovy/runtime/DefaultGroovyMethods.java    |  2 +-
 .../groovy/runtime/StringGroovyMethods.java     | 10 ++++----
 17 files changed, 46 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/lang/TracingInterceptor.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/TracingInterceptor.java b/src/main/groovy/lang/TracingInterceptor.java
index 5a5a1ab..f67de11 100644
--- a/src/main/groovy/lang/TracingInterceptor.java
+++ b/src/main/groovy/lang/TracingInterceptor.java
@@ -32,7 +32,7 @@ import java.io.Writer;
  * of two spaces is written.
  * <p>
  * Here is an example usage on the ArrayList object: <br>
- * <pre>
+ * <pre class="groovyTestCase">
  * def proxy = ProxyMetaClass.getInstance(ArrayList.class)
  * proxy.interceptor = new TracingInterceptor()
  * proxy.use {

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/Canonical.groovy
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/Canonical.groovy b/src/main/groovy/transform/Canonical.groovy
index 82d2fc2..6f99c80 100644
--- a/src/main/groovy/transform/Canonical.groovy
+++ b/src/main/groovy/transform/Canonical.groovy
@@ -24,7 +24,8 @@ package groovy.transform
  * which add positional constructors, equals, hashCode and a pretty print toString to your class.
  * <p>
  * You can write classes in this shortened form:
- * <pre>
+ * <pre class="groovyTestCase">
+ * import groovy.transform.Canonical
  * {@code @Canonical} class Customer {
  *     String first, last
  *     int age

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/EqualsAndHashCode.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/EqualsAndHashCode.java b/src/main/groovy/transform/EqualsAndHashCode.java
index 634dbe9..daab142 100644
--- a/src/main/groovy/transform/EqualsAndHashCode.java
+++ b/src/main/groovy/transform/EqualsAndHashCode.java
@@ -29,7 +29,7 @@ import java.lang.annotation.Target;
  * Class annotation used to assist in creating appropriate {@code equals()} and {@code hashCode()} methods.
  * <p>
  * It allows you to write classes in this shortened form:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.EqualsAndHashCode
  * {@code @EqualsAndHashCode}
  * class Person {
@@ -83,7 +83,8 @@ import java.lang.annotation.Target;
  * to be used in limited cases where its purpose is for overriding implementation details rather than
  * creating a derived type with different behavior. This is useful when using JPA Proxies for example or
  * as shown in the following examples:
- * <pre>
+ * <pre class="groovyTestCase">
+ * import groovy.transform.*
  * {@code @Canonical} class IntPair { int x, y }
  * def p1 = new IntPair(1, 2)
  *
@@ -107,7 +108,8 @@ import java.lang.annotation.Target;
  * <code>equals</code> and <code>canEqual</code> method. The easiest way to
  * achieve this would be to use the {@code @Canonical} or
  * {@code @EqualsAndHashCode} annotations as shown below:
- * <pre>
+ * <pre class="groovyTestCase">
+ * import groovy.transform.*
  * {@code @EqualsAndHashCode}
  * {@code @TupleConstructor(includeSuperProperties=true)}
  * class IntTriple extends IntPair { int z }
@@ -159,7 +161,7 @@ import java.lang.annotation.Target;
  * </pre>
  * There is also support for including or excluding fields/properties by name when constructing
  * the equals and hashCode methods as shown here:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.*
  * {@code @EqualsAndHashCode}(excludes="z")
  * {@code @TupleConstructor}
@@ -172,7 +174,7 @@ import java.lang.annotation.Target;
  *
  * {@code @EqualsAndHashCode}(excludes=["y", "z"])
  * {@code @TupleConstructor}
- * public class Point2D {
+ * public class Point1D {
  *     int x, y, z
  * }
  *

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/Field.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/Field.java b/src/main/groovy/transform/Field.java
index 0a89817..546d045 100644
--- a/src/main/groovy/transform/Field.java
+++ b/src/main/groovy/transform/Field.java
@@ -31,7 +31,8 @@ import java.lang.annotation.Target;
  * <p>
  * The annotated variable will become a private field of the script class.
  * The type of the field will be the same as the type of the variable. Example usage:
- * <pre>
+ * <pre class="groovyTestCase">
+ * import groovy.transform.Field
  * {@code @Field} List awe = [1, 2, 3]
  * def awesum() { awe.sum() }
  * assert awesum() == 6

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/Immutable.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/Immutable.java b/src/main/groovy/transform/Immutable.java
index 20a1034..d0567e6 100644
--- a/src/main/groovy/transform/Immutable.java
+++ b/src/main/groovy/transform/Immutable.java
@@ -29,8 +29,8 @@ import java.lang.annotation.Target;
  * Class annotation used to assist in the creation of immutable classes.
  * <p>
  * It allows you to write classes in this shortened form:
- * <pre>
- * {@code @Immutable} class Customer {
+ * <pre class="groovyTestCase">
+ * {@code @groovy.transform.Immutable} class Customer {
  *     String first, last
  *     int age
  *     Date since
@@ -224,7 +224,7 @@ public @interface Immutable {
      * new property values and returns a new instance of the Immutable class with
      * these values set.
      * Example:
-     * <pre>
+     * <pre class="groovyTestCase">
      * {@code @groovy.transform.Immutable}(copyWith = true)
      * class Person {
      *     String first, last

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/MapConstructor.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/MapConstructor.java b/src/main/groovy/transform/MapConstructor.java
index 8388643..d5ad3d2 100644
--- a/src/main/groovy/transform/MapConstructor.java
+++ b/src/main/groovy/transform/MapConstructor.java
@@ -29,7 +29,7 @@ import java.lang.annotation.Target;
  * Class annotation used to assist in the creation of map constructors in classes.
  * <p>
  * It allows you to write classes in this shortened form:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.*
  *
  * {@code @TupleConstructor}

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/TailRecursive.groovy
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/TailRecursive.groovy b/src/main/groovy/transform/TailRecursive.groovy
index 0c9b6cf..e2bea42 100644
--- a/src/main/groovy/transform/TailRecursive.groovy
+++ b/src/main/groovy/transform/TailRecursive.groovy
@@ -30,7 +30,8 @@ import java.lang.annotation.Target
  * since the JVM cannot do this itself. This works for both static and non-static methods.
  * <p/>
  * It allows you to write a method like this:
- * <pre>
+ * <pre class="groovyTestCase">
+ * import groovy.transform.TailRecursive
  * class Target {
  *      {@code @TailRecursive}
  *      long sumUp(long number, long sum = 0) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/builder/DefaultStrategy.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/builder/DefaultStrategy.java b/src/main/groovy/transform/builder/DefaultStrategy.java
index 83aeb15..291f50e 100644
--- a/src/main/groovy/transform/builder/DefaultStrategy.java
+++ b/src/main/groovy/transform/builder/DefaultStrategy.java
@@ -69,7 +69,7 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC;
  * static method or constructor levels.
  *
  * You use it as follows:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.builder.*
  *
  * {@code @Builder}
@@ -101,7 +101,7 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC;
  *
  * You can also use the {@code @Builder} annotation in combination with this strategy on one or more constructor or
  * static method instead of or in addition to using it at the class level. An example with a constructor follows:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.ToString
  * import groovy.transform.builder.Builder
  *
@@ -129,7 +129,7 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC;
  * have unique names. E.g.&nbsp;we can modify the previous example to have three builders. At least two of the builders
  * in our case will need to set the 'builderClassName' and 'builderMethodName' annotation attributes to ensure
  * we have unique names. This is shown in the following example:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.builder.*
  * import groovy.transform.*
  *

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/builder/ExternalStrategy.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/builder/ExternalStrategy.java b/src/main/groovy/transform/builder/ExternalStrategy.java
index 2cef050..c6ca2ad 100644
--- a/src/main/groovy/transform/builder/ExternalStrategy.java
+++ b/src/main/groovy/transform/builder/ExternalStrategy.java
@@ -61,7 +61,7 @@ import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
  *
  * You use it by creating and annotating an explicit builder class which will be filled in by during
  * annotation processing with the appropriate build method and setters. An example is shown here:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.builder.*
  *
  * class Person {

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/transform/builder/SimpleStrategy.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/builder/SimpleStrategy.java b/src/main/groovy/transform/builder/SimpleStrategy.java
index 8d54bd9..98fc62b 100644
--- a/src/main/groovy/transform/builder/SimpleStrategy.java
+++ b/src/main/groovy/transform/builder/SimpleStrategy.java
@@ -50,7 +50,7 @@ import static org.codehaus.groovy.transform.BuilderASTTransformation.NO_EXCEPTIO
  * setter methods for properties return the original object, thus allowing chained usage of the setters.
  *
  * You use it as follows:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.builder.*
  *
  * {@code @Builder}(builderStrategy=SimpleStrategy)

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/util/ConfigObject.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/util/ConfigObject.java b/src/main/groovy/util/ConfigObject.java
index 24220cd..a9e2803 100644
--- a/src/main/groovy/util/ConfigObject.java
+++ b/src/main/groovy/util/ConfigObject.java
@@ -372,7 +372,7 @@ public class ConfigObject extends GroovyObjectSupport implements Writable, Map,
 
     /**
      * Checks if a config option is set. Example usage:
-     * <pre>
+     * <pre class="groovyTestCase">
      * def config = new ConfigSlurper().parse("foo { password='' }")
      * assert config.foo.isSet('password')
      * assert config.foo.isSet('username') == false

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/groovy/util/Eval.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/util/Eval.java b/src/main/groovy/util/Eval.java
index 930337d..0330108 100644
--- a/src/main/groovy/util/Eval.java
+++ b/src/main/groovy/util/Eval.java
@@ -29,9 +29,9 @@ import groovy.lang.GroovyShell;
  * This class is a simple helper on top of GroovyShell. You can use it to evaluate small
  * Groovy scripts that don't need large Binding objects. For example, this script 
  * executes with no errors: 
- * <pre>
- * assert 10 == Eval.me(' 2 * 4 + 2')
- * assert 10 == Eval.x(2, ' x * 4 + 2')
+ * <pre class="groovyTestCase">
+ * assert Eval.me(' 2 * 4 + 2') == 10
+ * assert Eval.x(2, ' x * 4 + 2') == 10
  * </pre>
  * 
  * @see GroovyShell
@@ -41,8 +41,8 @@ import groovy.lang.GroovyShell;
 public class Eval {
     /**
      * Evaluates the specified String expression and returns the result. For example: 
-     * <pre>
-     * assert 10 == Eval.me(' 2 * 4 + 2')
+     * <pre class="groovyTestCase">
+     * assert Eval.me(' 2 * 4 + 2') == 10
      * </pre>
      * @param expression the Groovy expression to evaluate
      * @return the result of the expression
@@ -55,8 +55,8 @@ public class Eval {
     /**
      * Evaluates the specified String expression and makes the parameter available inside
      * the script, returning the result. For example, this code binds the 'x' variable: 
-     * <pre>
-     * assert 10 == Eval.me('x', 2, ' x * 4 + 2')
+     * <pre class="groovyTestCase">
+     * assert Eval.me('x', 2, ' x * 4 + 2') == 10
      * </pre>
      * @param expression the Groovy expression to evaluate
      * @return the result of the expression
@@ -73,8 +73,8 @@ public class Eval {
      * Evaluates the specified String expression and makes the parameter available inside
      * the script bound to a variable named 'x', returning the result. For example, this 
      * code executes without failure: 
-     * <pre>
-     * assert 10 == Eval.x(2, ' x * 4 + 2')
+     * <pre class="groovyTestCase">
+     * assert Eval.x(2, ' x * 4 + 2') == 10
      * </pre>
      * @param expression the Groovy expression to evaluate
      * @return the result of the expression
@@ -88,8 +88,8 @@ public class Eval {
      * Evaluates the specified String expression and makes the first two parameters available inside
      * the script bound to variables named 'x' and 'y' respectively, returning the result. For example, 
      * this code executes without failure: 
-     * <pre>
-     * assert 10 == Eval.xy(2, 4, ' x * y + 2')
+     * <pre class="groovyTestCase">
+     * assert Eval.xy(2, 4, ' x * y + 2') == 10
      * </pre>
      * @param expression the Groovy expression to evaluate
      * @return the result of the expression
@@ -107,8 +107,8 @@ public class Eval {
      * Evaluates the specified String expression and makes the first three parameters available inside
      * the script bound to variables named 'x', 'y', and 'z' respectively, returning the result. For 
      * example, this code executes without failure: 
-     * <pre>
-     * assert 10 == Eval.xyz(2, 4, 2, ' x * y + z')
+     * <pre class="groovyTestCase">
+     * assert Eval.xyz(2, 4, 2, ' x * y + z') == 10
      * </pre>
      * @param expression the Groovy expression to evaluate
      * @return the result of the expression

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/org/codehaus/groovy/ast/expr/ElvisOperatorExpression.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/expr/ElvisOperatorExpression.java b/src/main/org/codehaus/groovy/ast/expr/ElvisOperatorExpression.java
index e794fb5..64df749 100644
--- a/src/main/org/codehaus/groovy/ast/expr/ElvisOperatorExpression.java
+++ b/src/main/org/codehaus/groovy/ast/expr/ElvisOperatorExpression.java
@@ -30,7 +30,7 @@ import org.codehaus.groovy.ast.GroovyCodeVisitor;
  * </pre>
  * Even if x is no atomic expression, x will be evaluated only 
  * once. Example:
- * <pre>
+ * <pre class="groovyTestCase">
  * class Foo { 
  *   def index=0 
  *   def getX(){ index++; return index }

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/org/codehaus/groovy/runtime/ComposedClosure.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/ComposedClosure.java b/src/main/org/codehaus/groovy/runtime/ComposedClosure.java
index dd56389..948ce09 100644
--- a/src/main/org/codehaus/groovy/runtime/ComposedClosure.java
+++ b/src/main/org/codehaus/groovy/runtime/ComposedClosure.java
@@ -28,7 +28,7 @@ import java.util.List;
  * <code>leftShift()</code> methods on <code>Closure</code>.
  * <p>
  * Typical usages:
- * <pre>
+ * <pre class="groovyTestCase">
  * def twice = { a -> a * 2 }
  * def inc = { b -> b + 1 }
  * def f = { x -> twice(inc(x)) } // longhand

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/org/codehaus/groovy/runtime/CurriedClosure.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/CurriedClosure.java b/src/main/org/codehaus/groovy/runtime/CurriedClosure.java
index 0deb990..964d4ba 100644
--- a/src/main/org/codehaus/groovy/runtime/CurriedClosure.java
+++ b/src/main/org/codehaus/groovy/runtime/CurriedClosure.java
@@ -25,7 +25,7 @@ import groovy.lang.Closure;
  * Normally used only internally through the <code>curry()</code>, <code>rcurry()</code> or
  * <code>ncurry()</code> methods on <code>Closure</code>.
  * Typical usages:
- * <pre>
+ * <pre class="groovyTestCase">
  * // normal usage
  * def unitAdder = { first, second, unit -> "${first + second} $unit" }
  * assert unitAdder(10, 15, "minutes") == "25 minutes"

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 3202844..ca9dba5 100644
--- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -210,7 +210,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
      * Any method invoked inside the closure will first be invoked on the
      * self reference. For instance, the following method calls to the append()
      * method are invoked on the StringBuilder instance:
-     * <pre>
+     * <pre class="groovyTestCase">
      * def b = new StringBuilder().with {
      *   append('foo')
      *   append('bar')

http://git-wip-us.apache.org/repos/asf/groovy/blob/870a1bca/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
index 265e36c..da072c3 100644
--- a/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
@@ -2727,12 +2727,12 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport {
      * Replaces the first occurrence of a captured group by the result of a closure call on that text.
      * <p>
      * For example (with some replaceAll variants thrown in for comparison purposes),
-     * <pre>
-     * assert "hellO world" == "hello world".replaceFirst("(o)") { it[0].toUpperCase() } // first match
-     * assert "hellO wOrld" == "hello world".replaceAll("(o)") { it[0].toUpperCase() }   // all matches
+     * <pre class="groovyTestCase">
+     * assert "hello world".replaceFirst("(o)") { it[0].toUpperCase() } == "hellO world" // first match
+     * assert "hello world".replaceAll("(o)") { it[0].toUpperCase() } == "hellO wOrld" // all matches
      *
-     * assert '1-FISH, two fish' == "one fish, two fish".replaceFirst(/([a-z]{3})\s([a-z]{4})/) { [one:1, two:2][it[1]] + '-' + it[2].toUpperCase() }
-     * assert '1-FISH, 2-FISH' == "one fish, two fish".replaceAll(/([a-z]{3})\s([a-z]{4})/) { [one:1, two:2][it[1]] + '-' + it[2].toUpperCase() }
+     * assert "one fish, two fish".replaceFirst(/([a-z]{3})\s([a-z]{4})/) { [one:1, two:2][it[1]] + '-' + it[2].toUpperCase() } == '1-FISH, two fish'
+     * assert "one fish, two fish".replaceAll(/([a-z]{3})\s([a-z]{4})/) { [one:1, two:2][it[1]] + '-' + it[2].toUpperCase() } == '1-FISH, 2-FISH'
      * </pre>
      *
      * @param self    a CharSequence