Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [groovy]

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.

2
votes
1answer
45 views

Groovy script to get average price per group from different data arrays

I've been trying to learn Groovy lately and I tried to solve a problem which involves designing a routine that will calculate the average Product price per Group. I have the following data: ...
1
vote
2answers
56 views

Replace each element in a list [closed]

Here is how to transform a Zorglub (it is an API that I can not modify): Zorglub transformedZorglub = zorglub.transform() I am given a ...
0
votes
1answer
69 views

Spring: Creating a Mutable Common Command Object or Controller Interceptor

I'm integrating with a 3rd party vendor that has Users and Organizations in it. My tool is a user administration tool that ...
4
votes
0answers
102 views

File operations using Groovy

The idea is to read a file - "data" - and write the information to a new file - "output" - only if it meets the criteria (if the resource usage is more than a configured threshold). Content of the ...
1
vote
0answers
78 views

Display multiple video in video tag using timeduration in Grails Application

I've requirements to display video of some time duration in video tag. I've written following code for the same in my grails application. videoFeed.gsp ...
2
votes
0answers
146 views

Groovy Map/Reduce for Jenkins DSL

Jenkins DSL doesn't support collect and inject from what I can tell (I get missing method exceptions when I try), so I ...
0
votes
2answers
110 views

Is this FizzBuzz code idiomatic Groovy?

I'm new to Groovy but have some experience with Java, C and Python. I'd appreciate your feedback on Groovy style and features in this FizzBuzz code. Review Checklist Is it idiomatic Groovy code? Can ...
1
vote
1answer
110 views

Extract attachment between MIME boundary markers

I am trying to extract invoice which is surrounded between a boundary keyword in groovy, in the below example boudary key word is a92720f5836d4daaa4251e805cba228b ...
3
votes
1answer
4k views

Groovy optimize method to convert JSON to map

I have this method which creates a map from a JSON request parameter. Right now I've hard-coded JSON keys to convert it to map. Can it be converted to a generic method which converts a request's JSON ...
1
vote
1answer
59 views

Finding duplicate invoices

I have a invoiceList which is a List<Map<String:String>> and am trying to find out if all the invoices have same <...
2
votes
1answer
170 views

Combine lists of objects with no duplicates

I have 2 groovy sql resultset, I need to combine the result set so that project_no should be unique and case_no can have ...
4
votes
1answer
165 views

More groovifed way of sublist with varying range

Student list of 50 students and a teacher list of 3 teachers. Section XML as the output where each teacher is assigned to a section, and up to 20 students are assigned in that section. Need to loop ...
3
votes
1answer
74 views

Converting regular text phrase to Pig Latin in Groovy

Am I using the best conventions or are there better ways? ...
2
votes
0answers
65 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 ...
23
votes
2answers
242 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 ...
9
votes
2answers
22k 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
70 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
1answer
43 views

Dynamic field performance

A have a model with a dynamic field like so: ...
7
votes
1answer
142 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
104 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
503 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
923 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. ...
9
votes
0answers
155 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
33 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. ...
7
votes
1answer
679 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
21 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
142 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
141 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): ...
24
votes
1answer
429 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
294 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
294 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
4k 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
104 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
164 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
24 views

GroupBy field with and without white spaces

I have these invoices listed: ...
1
vote
2answers
93 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
3k views

Regex to extract selective lines

I have a list of error messages: ...
4
votes
1answer
295 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
2answers
183 views

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

I have a string array: ...
3
votes
1answer
9k 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
365 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
409 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: <...
3
votes
1answer
54 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
192 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
29 views
0
votes
1answer
195 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
181 views

Better way to assert correct return values in Groovy

I have written a function that returns me the duplicates of a list: ...
4
votes
1answer
321 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
82 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
96 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: ...