6

Groovy 4.0.0 adds SQL-like querying

 2 years ago
source link: https://www.infoworld.com/article/3649128/groovy-400-adds-sql-like-querying.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Groovy 4.0.0 adds SQL-like querying

Groovy-integrated queries, sealed types, and switch expressions make their debut in the latest upgrade of the popular JVM language.

By Paul Krill

Editor at Large,

InfoWorld | Feb 2, 2022 1:22 pm PST

Groovy 4.0.0 has arrived as a production release. The latest upgrade to the JVM-based language introduces new SQL-like query capabilities, sealed types, and switch expressions.

GINQ, also known as Groovy-integrated Query or GQuery, is an incubating feature in Groovy 4.0.0. It supports querying collections in a SQL-like style. This might involve lists or maps, domain objects, or collections returned when processing such as JSON, XML, and other structured data. In a future version of Groovy, plans call for GQuery support for SQL databases where an optimized SQL query is generated based on the GQuery expression.

[ Also on InfoWorld: JDK 18: What’s new in Java 18 ]

Groovy 4.0.0 also debuts sealed types and switch expressions. Sealed types, which restrict which other classes or interfaces may extend or implement them, can be used in instances such as creating enhanced enum-like hierarchies. With switch expressions, Groovy gains a convenient programming alternative to switch statements, which Groovy already has had, according to release notes.

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

0 seconds of 21 minutes, 50 secondsVolume 0%
Loading ad
  • Native records for Java Development Kit (JDK) 16 and record-like classes, also known as emulated records, are incubating features. Record-like classes have features of native records but do not have the same information at the bytecode level as native records; thus, they will not be recognized as records by a Java compiler in cross-integration scenarios.
  • Some select type checkers are bundled within the optional groovy-typecheckers module to encourage further use of the extensible type-checking mechanism.
  • Select macro methods are bundled within the optional groovy-macro-library module to encourage further use of macros.
  • A JavaShell feature, also in an incubating state, enables developers to more easily work with snippets of code. This capability is the Java equivalent of GroovyShell.
  • POJO annotation is featured in an incubating state.
  • An optional, incubating Groovy contracts module supports a design-by-contract style of programming. It provides contract annotations supporting the specification of class-invariants, pre-conditions, and post-conditions on Groovy interfaces and classes.
  • TOML (Tom’s Obvious Minimal Language) files are supported, also an incubating feature.
  • GString performance has been improved.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK