Effective Java with Groovy - Enabling Order
This post shows how does Groovy make it convenient for you to implement Comparable and Comparator interfaces.…
This post shows how does Groovy make it convenient for you to implement Comparable and Comparator interfaces.…
Java introduced NIO 2 APIs with version 1.7. I wrote an article several years ago, after seeing not many developers make use of the new API. With this API, you would use java.nio.file.Path instead of java.io.File to represent a file. To get an instance…
We have seen Micronaut BlockingHttpClient in action and how to use exchange and retrieve methods to interact with an HTTP endpoint. What happens if your endpoint returns HTTP status code greater than or equal to 400 (they indicate that it's an error)? To explore this, let's create an endpoint that…
In a previous post exploring scripting basics, we saw how binding was used to supply command-line arguments to scripts. In this post, let's explore the design of binding further. class BindingDemo { static void main(String[] args) { Binding sampleBinding = new Binding() println sampleBinding.variables sampleBinding.message = "Hello" println sampleBinding.variables println…
I was mentoring this developer, and he was working on a piece of UI which involved a lot of JavaScript. The timeframe was before sing-page apps became the norm. So the team was using JQuery. Day by day, the functionality started getting more sophisticated. A part of the feature was…
Let's start with the following code making use of the traditional for loop. List<String> languages = List.of("Java", "Groovy", "Kotlin"); // List.of() requires Java 9 or above for (int i = 0; i < languages.size(); i++) { System.out.println(languages.get(i)); } Compare the above code to…
In a previous post, we saw Gradle's continuous build in action. If you use Test Driven Development at work, you will be running your tests after every code change. Let's leverage Gradle's continuous build so that you don't have to trigger the tests every time you change your code manually.…
I have written about my thoughts on hot loading in general in this post. Micronaut from version 1.2 started supporting continuous build, but you had to manually add the configuration entries to your project. With the 2.0 version, Micronaut supports 'continuous build' out of the box. Both Gradle…
In a previous post, we explored the simplicity of scripting mode offered by Groovy. We arrived at the following code. String message = args.length > 0 ? "Hello ${args[0]}" : "Hello" println message Let's make the functionality slightly more sophisticated. Say, we want to send a custom message as the optional…
More than a decade ago, when I started my profession as a software developer, one of the most significant pain for developers was waiting for your application server to start so that they could verify their code changes. Hence there were efforts to make live reloading happen without restarting the…