write workaround about jdk8
[from now] 2013/11/25 06:27:42

diff --git a/README.md b/README.md
index 0fc5cdb..94ff69c 100644
--- a/README.md
+++ b/README.md
@@ -81,9 +81,7 @@ Possible solutions: sleep(long), sleep(long, groovy.lang.Closure), split(), next
 	at groovyx.comprehension.a.run(a.groovy:10)
 ```

-Java 8 JVM or API has some issue with Groovy module method extension. This issue is has reported.(http://jira.codehaus.org/browse/GROOVY-6447)
-
-As workaround, donwload  ``groovy-optional-x.x.jar`` from https://github.com/uehaj/maven-repo/tree/gh-pages/snapshot/org/jggug/kobo/groovy-optional/x.x onto to your ~/.groovy/lib folder.
+Java se 8 JVM or API has some issue with Groovy module method extension. This issue has reported.(http://jira.codehaus.org/browse/GROOVY-6447). Of cource JDK8 is requred, it means you can't @Grab for this groovy-module. As workaround, donwload  ``groovy-optional-x.x.jar`` from https://github.com/uehaj/maven-repo/tree/gh-pages/snapshot/org/jggug/kobo/groovy-optional/x.x onto to your ~/.groovy/lib folder.

 Requirements
diff --git a/build.gradle b/build.gradle
index ad293bf..fa61eb9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ repositories {
 }

 dependencies {
-    compile 'org.codehaus.groovy:groovy-all:2.2.0'
+    compile 'org.codehaus.groovy:groovy-all:2.2.0-rc-3'
 	testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
 }

diff --git a/src/main/groovy/groovyx/java8/optional/extension/OptionalGroovyMethods.groovy b/src/main/groovy/groovyx/java8/optional/extension/OptionalGroovyMethods.groovy
index cf2b213..9dec418 100644
--- a/src/main/groovy/groovyx/java8/optional/extension/OptionalGroovyMethods.groovy
+++ b/src/main/groovy/groovyx/java8/optional/extension/OptionalGroovyMethods.groovy
@@ -20,8 +20,10 @@ import org.codehaus.groovy.runtime.InvokerHelper;
 /**
  * @author Uehara Junji(@uehaj)
  */
-@CompileStatic
 class OptionalGroovyMethods {
+    public static void hello(String s) {
+        println "hello"
+    }

     public static Object methodMissing(Optional self, String name, Object args0) {
         Object[] args = (Object[])args0;
diff --git a/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
index 0d55f7e..d5be39f 100644
--- a/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
+++ b/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
@@ -1,4 +1,4 @@
 # see http://groovy.codehaus.org/Creating+an+extension+module
 moduleName=groovy-optional
-moduleVersion=0.1
+moduleVersion=0.2
 extensionClasses=groovyx.java8.optional.extension.OptionalGroovyMethods
diff --git a/src/test/groovy/groovyx/java8/optional/extension/OptionalTest.groovy b/src/test/groovy/groovyx/java8/optional/extension/OptionalTest.groovy
index 5b8c1e6..cf0eff2 100644
--- a/src/test/groovy/groovyx/java8/optional/extension/OptionalTest.groovy
+++ b/src/test/groovy/groovyx/java8/optional/extension/OptionalTest.groovy
@@ -26,14 +26,26 @@ class OptionalTest extends GroovyTestCase {
         assert toUpperAndToLower(arg1, NULL) == NULL
     }

-    def mult(a, b) {
+    def mult1(a, b) {
         a * 3 + b * 2
     }

-    void testMult() {
-        assert mult(arg1, arg2) == Optional.of("AbcAbcAbcDefDef")
-        assert mult(NULL, arg2) == NULL
-        assert mult(arg1, NULL) == NULL
+    void testMult1() {
+        assert mult1(arg1, arg2) == Optional.of("AbcAbcAbcDefDef")
+        assert mult1(NULL, arg2) == NULL
+        assert mult1(arg1, NULL) == NULL
+
+        assert mult1(Optional.of("Abc"), Optional.of(3)) == Optional.of("AbcAbcAbc6")
+    }
+
+    Optional<Integer> mult2(Optional<Integer>a, Optional<Integer>b) {
+        a * 3 + b * 2
+    }
+
+    void testMult2() {
+        assert mult2(arg1, arg2) == Optional.of("AbcAbcAbcDefDef")
+        assert mult2(NULL, arg2) == NULL
+        assert mult2(arg1, NULL) == NULL
     }

     void testJoin() {
@@ -42,4 +54,11 @@ class OptionalTest extends GroovyTestCase {
         assert (Optional.of{a,b -> String.join(' ', a, b) }(arg1, NULL)) == NULL
         assert (Optional.of{a,b -> String.join(' ', a, b) }(NULL, NULL)) == NULL
     }
+
+    void testToString() {
+        def a = Optional.of(3.3)
+        assert a.toString() == "Optional[3.3]" // != "3.3"
+        assert a.get().toString() == "3.3"
+        assert a.map{"<"+it.toString()+">"}.get() == "<3.3>"
+    }
 }