Groovy 4.. has arrived as a output release. The most recent upgrade to the JVM-based language introduces new SQL-like query abilities, sealed styles, and change expressions.

GINQ, also regarded as Groovy-built-in Question or GQuery, is an incubating aspect in Groovy 4… It supports querying collections in a SQL-like design and style. This may well contain lists or maps, domain objects, or collections returned when processing this kind of as JSON, XML, and other structured facts. In a foreseeable future edition of Groovy, programs contact for GQuery assistance for SQL databases wherever an optimized SQL question is produced based on the GQuery expression.

Groovy 4.. also debuts sealed sorts and switch expressions. Sealed types, which prohibit which other classes or interfaces could extend or employ them, can be employed in instances this sort of as making improved enum-like hierarchies. With switch expressions, Groovy gains a easy programming substitute to swap statements, which Groovy now has had, in accordance to release notes.

Announced January 28 by the Apache Groovy team, Groovy 4.. can be downloaded from groovy.apache.org. Other capabilities in Groovy 4. involve:

  • Indigenous documents for Java Enhancement Kit (JDK) 16 and record-like lessons, also identified as emulated information, are incubating characteristics. File-like courses have options of native records but do not have the similar facts at the bytecode level as native records as a result, they will not be identified as information by a Java compiler in cross-integration situations.
  • Some find kind checkers are bundled inside of the optional groovy-typecheckers module to really encourage even more use of the extensible style-checking mechanism.
  • Pick macro solutions are bundled within just the optional groovy-macro-library module to stimulate further use of macros.
  • A JavaShell function, also in an incubating condition, enables developers to a lot more simply do the job with snippets of code. This capacity is the Java equal of GroovyShell.
  • POJO annotation is featured in an incubating point out.
  • An optional, incubating Groovy contracts module supports a design-by-agreement design of programming. It delivers contract annotations supporting the specification of class-invariants, pre-situations, and put up-conditions on Groovy interfaces and courses.
  • TOML (Tom’s Obvious Minimal Language) documents are supported, also an incubating aspect.
  • GString effectiveness has been improved.

Copyright © 2022 IDG Communications, Inc.