Groovy 3 adds the YamlBuilder
class to create YAML output using a Groovy syntax. The YamlBuilder
is closely related to JsonBuilder
that is described in a previous post. We define a hierarchy using a builder syntax where we can use primitive types, strings, collections and objects. Once we have build our structure we can use the toString()
method to get a string representation in YAML format.
In the following example we use YamlBuilder
to create YAML:
Continue reading →
Groovy 3 adds the average
method to collections to calculate the average of the items in the collections. When the items are numbers simply the average is calculated. But we can also use a closure as argument to transform an item into a number value and then the average on that number value is calculated.
In the following example code we use the average method on a list of numbers and strings. And we use a closure to first transform an element before calculating the average:
Continue reading →
Spring Boot Admin describes several ways of connecting clients to the admin server.
If your Spring Boot applications are running on kubernetes or openshift then Spring Boot Admin can use
the Spring Cloud Kubernetes discovery client. In this blogpost i’ll show you how.
Continue reading →
This week at work a colleague showed a nice feature of the Pattern
class in Java: we can easily turn a Pattern
into a Predicate
with the asPredicate
and asMatchPredicate
methods. The asPredicate
method return a predicate for testing if the pattern can be found given string. And the asMatchPredicate
return a predicate for testing if the pattern matches a given string.
In the following example code we use both methods to create predicates:
Continue reading →