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
30 views

Rijndael key expansion

I am writing Rijndael for academic purpose, following wikipedia's description. https://en.wikipedia.org/wiki/Rijndael_key_schedule I would like to know, if up to this point it is correct, both from ...
18
votes
2answers
134 views

Simon, Mat's Mug, what's the (rating) difference?

This is a part of the code for the almighty bot @Duga (That's me!). Every evening, 15 minutes before "RELOAD" (00:00 UTC), I post the reputation differences for some Code Review users. Example ...
6
votes
1answer
375 views

Preventing XSS attacks in a Spring MVC application controller

One of the URL in my application is vulnerable to XSS attack, so I am handling it in the below way. I created a util class: ...
0
votes
1answer
37 views

Groovy pathfinding algorithm

I have created a bit of path-finding code in response to this code golf question. Since this is one of my first large bits of code in Groovy that I have written, I would like to see how I could ...
0
votes
0answers
102 views

Groovy script to migrate Jenkins projects from Mask Passwords to EnvInject plugin

I used this snippet in the Jenkins script console to enable EnvInject on all projects (aka. jobs) which were using Mask Passwords: ...
0
votes
1answer
20 views

Dynamic field performance

A have a model with a dynamic field like so: ...
7
votes
1answer
64 views

Sentence building DSL

Cardshifter is an online trading card game, made by a gang of Code Review community members. Cards can have a bunch of different, and sometimes complex effects, and descriptions for these are ...
6
votes
1answer
73 views

Grooving Project Euler # 8

I recently watched a video course on groovy and started working on some of the Project euler problems to flex my groovy* muscle. (This is problem #8) The four adjacent digits in the 1000-digit ...
14
votes
2answers
141 views

Builder pattern for users in document database

I'm attempting to make a builder pattern that makes sense and is practical for storing user data in a flexible way in a document database. The DB I chose is MongoDB, and I'm using its Java API ...
5
votes
0answers
191 views

A Groovier way of inserting and updating database records

I've written a simple little Groovy class handling my database interactions. All it has to do is check if a row exists in a target table with primary key values which match those of an incoming map. ...
7
votes
0answers
70 views

Multithreaded Groovy Mandelbrot

Seeing as it's October, I thought I'd do the community challenge. Due to my inexperience coding in Groovy, I decided to give Groovy a go. I'm not sure how well I followed Groovy conventions, and the ...
3
votes
1answer
29 views

Optimize time for file download

This is the working code snippet to download file from a URL. I want to know if there is any optimization I can do to download the file faster. ...
6
votes
1answer
155 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
19 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 ...
4
votes
1answer
117 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
50 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
351 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
177 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
66 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 ...
7
votes
2answers
1k 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
85 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
89 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 ...
4
votes
1answer
23 views

GroupBy field with and without white spaces

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

Optimize groovy DAO

I have a DocDao which is configured with the docDataSource as below docDataSource configuration from applicationContext.xml ...
1
vote
2answers
80 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
114 views

Regex to extract selective lines

I have a list of error messages: ...
4
votes
1answer
114 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
94 views

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

I have a string array: ...
1
vote
1answer
530 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
313 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
70 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
46 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
83 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
26 views
0
votes
1answer
77 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: ...
5
votes
1answer
93 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
201 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
67 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
69 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
61 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
1answer
326 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
52 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
4k 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
327 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: ...
3
votes
3answers
225 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
171 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
215 views

Boolean constant for assert in if..else block

I have the following condition statement in Groovy: ...
1
vote
0answers
100 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
38 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 ...
9
votes
1answer
6k 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 ...