Questions tagged [groovy-2]

Groovy is an object-oriented programming language for the Java platform.

It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform.

Groovy uses a Java-like bracket syntax. It is dynamically compiled to Java Virtual Machine (JVM) bytecode and interoperates with other Java code and libraries. Most Java code is also syntactically valid Groovy.

Groovy 2 was released on June 28, 2012.

8 questions
13
votes
2 answers

Should I use Groovy's @CompileStatic if I'm also using Java 7

I've read through the "What's new in Groovy 2.0" and I'm a bit confused about when to use @CompileStatic. The article mentions that the @CompileStatic annotation was added for developers who weren't able to take advantage of the invoke dynamic part…
Scott
  • 16,711
  • 14
  • 75
  • 120
8
votes
1 answer

Mixing private and public/protected methods of the same name causes multimethods to be disabled and is forbidden to avoid surprising behaviour

I just upgraded one of my Grails apps to 2.2.0 which is using Groovy 2.0 and I am now getting this compile error: Mixing private and public/protected methods of the same name causes multimethods to be disabled and is forbidden to avoid…
Gregg
  • 34,973
  • 19
  • 109
  • 214
5
votes
2 answers

How to display HTTPBuilder logs in groovyConsole

The Problem I'm getting groovyx.net.http.HttpResponseException: Not Found and want to see the logs from HTTPBuilder. I'm using Groovy 2.1.9 with groovyConsole. What I tried So I checked this blog post that says about adding log4j.xml to…
user800014
1
vote
1 answer

Groovy mixed typing

I see that as of Groovy 2.0 there is the possibility to add a TypeChecked annotation to classes or methods to trigger the optional static checking. I must admit that I am confused by how such a thing could work. The article gives simple examples…
Andrea
  • 20,253
  • 23
  • 114
  • 183
0
votes
2 answers

How to iterate over list and remove the matched items to create a new list

I am new to groovy Lists, and I have list as shown below: Class File{ String name int type int revision } def fileList = [File1, File2, File3,....] I want the fileList to have the latest files It should not have the items of same type It…
n92
  • 7,424
  • 27
  • 93
  • 129
0
votes
2 answers

Groovy @CompileStatic and Grails

Looking at article on DZone about improved performance with Groovy2 when compiling with @CompileStatic annotation, I wonder to what extent can I take advantage of it? I'm guessing annotate controllers, domain objects and services? Does Grails take…
vector
  • 7,334
  • 8
  • 52
  • 80
0
votes
1 answer

Instantiated a class, but it appears referenced to null

I'm trying to instantiate an object and set a single attribute on it, which comes from a request parameter, like so : println "Question text from the request :" + params.question def question = new SurveyQuestion() question.question =…
Jimmy
  • 16,123
  • 39
  • 133
  • 213
0
votes
1 answer

Is there a way to add constructors using Groovy 2.0 Extensions

In the older (1.x.x) versions of Groovy you can add constructors using metaClass.constructor Example.metaClass.constructor << { String arg0 -> new Example(arg0, "") } Is there a way to register constructors using the new Groovy 2.0 extension…
Michael Rutherfurd
  • 13,815
  • 5
  • 29
  • 40