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.

learn more… | top users | synonyms

2
votes
0answers
12 views

Using my own Optional type with fold method in groovy

I have written an Optional type in groovy roughly based on java8s Optional. I implemented and use a fold method and would like to know if it can be improved. First, ...
0
votes
1answer
13 views

Object with highest count in a Groovy list

I have a list of Parcel objects and am trying to write a closure that picks the parcel object with highest count: ...
4
votes
1answer
33 views

Better way to assert correct return values in Groovy

I have written a function that returns me the duplicates of a list: ...
3
votes
1answer
108 views

Parsing version number from a Java source file

I'm extracting the version number from a file like this one. It works, but I find it clumsy and longer than probably needed. I'd also appreciate some sanity checks as long as they don't make the code ...
5
votes
1answer
55 views

Avoiding repetitive code for timestamping and updating status

This is some boilerplate I found myself writing on a new abstract class. It seems ripe for refactoring, but I'm not sure the best way to implement it more effectively. Is there a pattern for these ...
0
votes
1answer
52 views

Restructuring multiple variables into an array

I'm using Groovy to grab properties from a page and each of the properties are grouped into a specific type: Groovy: ...
1
vote
2answers
35 views

Domain object toString null check

Following advice to "Make good use of toString() for all Domain classes", I made what I thought was the most useful toString ...
2
votes
0answers
146 views

Android Gradle script in multi-module project

I have a multi-module Android project built by Gradle with the new Android-plugin 0.10+. All modules are mainly configured from the root project. I've enable the new code coverage feature. The major ...
4
votes
1answer
40 views

Code for adjusting linelength

I wrote the following groovy function for taking a string of multiple lines (or any other character for splitting the code into parts), and bringing each line/part to a specified number of characters, ...
2
votes
0answers
980 views

Code to write data to Excel

I have a need to read properties from soapUI using groovy and writing them to Excel. I initially had a problem with writing to Excel, but I was able to solve that. Now I want to know if my solution is ...
2
votes
2answers
144 views

Grails overloaded controller workaround

I had an overloaded method, but Grails doesn't allow overloaded methods in controller actions. The overloaded method looked like this: ...
4
votes
3answers
154 views

Is this code too Groovy to understand?

The variable result is an integer representing the exit code of a command line process that was run via Groovy code. An exit code of 0 means the process was ...
1
vote
0answers
370 views

Android Gradle Release prompt for signingConfigs params [closed]

Code allows to run Gradle build system in these ways: ...
3
votes
2answers
123 views

How to design DAOs that handle composite objects?

Suppose I have following elementary DTOs, each DTO corresponding to a database table: class Event { String name } class Player { String name } DAOs for ...
1
vote
1answer
85 views

Boolean constant for assert in if..else block

I have the following condition statement in Groovy: ...
1
vote
0answers
82 views

List builder in groovy

I'm a big fan of yield return found in C# and computation expressions found in F#. That is, language features which allow you to build streams of objects which are ...
0
votes
1answer
36 views

How can use array to imitate repeated individual instances?

I'm working an example to list directory contents. When I process each directory the code works. Now I'd like to put both directories in an array and iterate the array. I get an error when I declare ...
7
votes
1answer
2k views

Constructors and inheritance in Groovy

I am new to Groovy and I am having a little problem with constructors of subclasses. Basically, I have a base abstract class like ...
1
vote
2answers
304 views

Groovy: permutations() with size limit

I have a problem to solve. My algorithm is assigning Players to Positions. On the start I have a list of about 16 positions and 4 players. The problem is to assing every player to it's closest ...
3
votes
4answers
3k views

Groovy: find all elements in a list equal to the max element

Is there any simpler way to find all elements in a list that are equal to the max element. ...
4
votes
2answers
3k views

Returning Groovy class fields as a map

I want to get a map of all the fields in a class (aka value object) in a generic way. The following works fine for me: ...
7
votes
1answer
649 views

Generating a sequential number for app-wide use

I have to generate a sequential number for groovy-grails app wide use and came up with the following. However, is there a better way to do this? Domain classes: ...