Groovy 4.. has arrived as a production release. The latest improve to the JVM-centered language introduces new SQL-like query capabilities, sealed types, and change expressions.

GINQ, also identified as Groovy-built-in Question or GQuery, is an incubating element in Groovy 4… It supports querying collections in a SQL-like model. This may possibly require lists or maps, area objects, or collections returned when processing this sort of as JSON, XML, and other structured facts. In a long term version of Groovy, options simply call for GQuery support for SQL databases where by an optimized SQL query is generated based on the GQuery expression.

Groovy 4.. also debuts sealed varieties and switch expressions. Sealed varieties, which prohibit which other lessons or interfaces may prolong or put into practice them, can be employed in situations this kind of as making increased enum-like hierarchies. With swap expressions, Groovy gains a convenient programming choice to swap statements, which Groovy presently has had, according to launch notes.

Declared January 28 by the Apache Groovy workforce, Groovy 4.. can be downloaded from groovy.apache.org. Other capabilities in Groovy 4. incorporate:

  • Indigenous data for Java Growth Package (JDK) 16 and record-like lessons, also recognized as emulated data, are incubating functions. File-like classes have features of indigenous records but do not have the similar details at the bytecode degree as native data consequently, they will not be recognized as records by a Java compiler in cross-integration situations.
  • Some pick out kind checkers are bundled within just the optional groovy-typecheckers module to persuade further use of the extensible type-examining mechanism.
  • Pick macro strategies are bundled in the optional groovy-macro-library module to encourage additional use of macros.
  • A JavaShell attribute, also in an incubating point out, enables builders to more very easily function with snippets of code. This ability is the Java equal of GroovyShell.
  • POJO annotation is highlighted in an incubating condition.
  • An optional, incubating Groovy contracts module supports a design and style-by-contract fashion of programming. It delivers agreement annotations supporting the specification of class-invariants, pre-disorders, and article-conditions on Groovy interfaces and lessons.
  • TOML (Tom’s Obvious Minimum Language) files are supported, also an incubating feature.
  • GString functionality has been enhanced.

Copyright © 2022 IDG Communications, Inc.