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

6
votes
1answer
32 views

Generation of Groovy source from parent Java class

I use Groovy to write business rules into big, long term Java software. Use Groovy in object way, that is not as groovy Script, but every elementary groovy source overrides some Java API class. i.e. ...
3
votes
0answers
12 views

Submitting forms on pages linked from a main page

In this scenario, the main page contains a list of links to the subpages. The requirement is to navigate to each page (if a condition passes) and perform some actions. I have written the loop using ...
-1
votes
0answers
16 views

How to simplify this multi component gradle.build? [closed]

I'm working on https://github.com/jadekler/git-java-websiteskeleton. It's a multi component skeleton with two components - products and users. I define an acceptance test gradle task at the root ...
3
votes
1answer
50 views

Scissors: A fluent API for manipulating lists using the familiar copy-cut-and-paste

What I've hastily named the Scissors API brings the cut-copy-paste paradigm made popular by word processors to the realm of list processing. The Scissors API is fluent, provides methods to manipulate ...
-1
votes
1answer
28 views

Is my Binary tree correct?

I have been watching this video: https://www.youtube.com/watch?v=M6lYob8STMI And here is the code of it in groovy (just the add method): ...
19
votes
1answer
225 views

A Groovy Election

Implementing the July 2015 Community Challenge seemed relevant considering it is election time. I decided to go with the strategy pattern as this can be implemented in many different ways. I did my ...
7
votes
2answers
66 views

Generating random HearthStone cards: Preparing the training data

For a little toy project of mine I need to have data available in a certain format in order to be able to feed into a Recurrent Neural Network (Long short term memory), it uses HearthStone card data ...
3
votes
2answers
49 views

Slurp JSON trading cards to valid HTML

For Cardshifter TCG we pretty frequently update our list of available cards, so I tried to think of a way to make it easy to transform an exported JSON file containing all the cards into a decent HTML ...
6
votes
2answers
137 views

Registration, login and logout in a Grails application

I'm completely new to Groovy, but have many years of Java experience, and recently I have started working on a Grails application, currently it contains the following: User and Person domain classes ...
7
votes
2answers
59 views

Append user input to a database

This is my first time writing a Swing+Groovy application that successfully inserts data to SQL tables. It may look like example code, but it is more test code, as I will eventually expand this to a ...
7
votes
1answer
42 views

Do you Connect with my Groove?

I'm new at groovy, and this is my first time writing a database connection script. It may seem like example code, but it is more like test code. It works as posted, and I'm planning to use this as a ...
2
votes
1answer
16 views

GroupBy field with and without white spaces

I have these invoices listed: ...
0
votes
0answers
32 views

Optimize groovy DAO

I have a DocDao which is configured with the docDataSource as below docDataSource configuration from applicationContext.xml ...
1
vote
2answers
64 views

Counting only weekend days between two timestamps

I am fairly new to the Groovy arena. I recently modified some code to add the following block. This code is added to remove dates we were supposed to remove from the total counts. This data goes on ...
2
votes
1answer
63 views

Regex to extract selective lines

I have a list of error messages: ...
2
votes
1answer
71 views

Groovy Map<String,List<Map<String,String>>> data manipulation method optimization

Am trying to update the Map<String,List<Map<String,String>>> invoices with the invoiceErrors as below ...
1
vote
1answer
55 views

Groovy method optimization to build <String, List<List>> tokens

I have a string array: ...
1
vote
1answer
121 views

Filtering a list based on conditions

I'm currently filtering a list based on several conditions, which may or may not be present: ...
3
votes
2answers
257 views

FizzBuzz-type program that reads/writes to Excel

I'm new to Groovy, and coming from PHP it's been a rough transition. The code below works. However, I would appreciate feedback on how better to write it and follow good practice with Groovy. I ...
2
votes
2answers
46 views

Remove list of files from another list of files by their name

In groovy I have a list of files A and also another list of files B. I want to remove all the files from A that have a filename that also occurs in the list of files B. I wrote the following code: ...
2
votes
1answer
44 views

Move a line in a file

In Groovy 1.8.6 I need to move a line just before another one. I'm interested in any improvements. ...
2
votes
0answers
35 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, ...
2
votes
1answer
23 views
0
votes
1answer
41 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
74 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
151 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
63 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
61 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
44 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
218 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
50 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
3k 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
236 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
199 views

Reporting success or failure of a child process

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 ...
3
votes
2answers
153 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
123 views

Boolean constant for assert in if..else block

I have the following condition statement in Groovy: ...
1
vote
0answers
92 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 ...
8
votes
1answer
4k 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
413 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
5k 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
5k 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
776 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: ...