{"id":341906,"date":"2022-11-29T15:00:07","date_gmt":"2022-11-29T15:00:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=341906"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=341906","title":{"rendered":"<span>\u042d\u0442\u0438 10 \u043d\u043e\u0432\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u0435\u043b\u0430\u044e\u0442 Groovy 4.0 \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0438\u043c<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/57c\/bc2\/7cc\/57cbc27cc18410bf061ab2f93364f60d.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/57c\/bc2\/7cc\/57cbc27cc18410bf061ab2f93364f60d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 (sealed) \u0442\u0438\u043f\u044b, switch-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0438\u043f\u044b record. \u042d\u0442\u043e \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u043e\u0432\u044b\u0445 \u0444\u0438\u0447, \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435 Groovy 4.0. \u0412 \u044d\u0442\u043e\u043c \u0432\u0438\u0434\u0435\u043e \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u0434\u0435\u0441\u044f\u0442\u044c \u0432\u0435\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 Groovy 4.0 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0437\u0430\u0442\u044f\u043d\u0443\u0442\u044b\u043c, \u043c\u044b \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u043c \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u043d\u0438\u0445. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d \u0434\u0430\u0442\u044c \u0432\u0430\u043c \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u043d\u043e\u0432\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/63861694003e93ef14dfb9f3\" data-style=\"\" id=\"63861694003e93ef14dfb9f3\" width=\"\"><\/div>\n<p>\u2139\ufe0f \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430: <a href=\"https:\/\/github.com\/wololock\/groovy-4-examples\"><u>https:\/\/github.com\/wololock\/groovy-4-examples<\/u><\/a><\/p>\n<h3>Switch-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u00a0<\/h3>\n<p>\u0412 Groovy \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b switch \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 Java. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u0438\u043b\u0438, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0440\u0430\u0432\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u043b\u0430\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 switch \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 Groovy. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c, \u0441\u043b\u0435\u0434\u0443\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c \u0432 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Java, Groovy \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438 switch-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c switch \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0439 \u0441 Java, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432, \u043d\u043e \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u0435\u0435.<\/p>\n<pre><code>switch (value) {     case null -> 'just a null'     case 0 -> 'zero'     case 1 -> 'one'     case { it instanceof List &amp;&amp; it.empty } -> 'an empty list'     case List -> 'a list'     case '007' -> 'James Bond'     case ~\/\\d+\/ -> 'a number'     default -> 'unknown' }<\/code><\/pre>\n<h3>Records (\u0417\u0430\u043f\u0438\u0441\u0438)<\/h3>\n<p>Records, \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 (\u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439) \u0442\u0438\u043f &#171;\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445&#187;, \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 Java 16. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0438 \u0432 Groovy. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0442\u043e\u0442 \u0436\u0435, \u0445\u043e\u0442\u044f Groovy \u0442\u0430\u043a\u0436\u0435 \u0432\u0432\u043e\u0434\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@RecordType<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e. \u0418 \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438\u0433\u0440\u044b, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0434\u043b\u044f Java, \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e Groovy \u0438\u0434\u0435\u0442 \u0432 \u043d\u043e\u0433\u0443 \u0441 \u043d\u043e\u0432\u0435\u0439\u0448\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0435\u0433\u043e \u0440\u043e\u0434\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<\/p>\n<pre><code>record Point(int x, int y) {}  def p1 = new Point(0, 0) def p2 = new Point(2, 4) def p3 = new Point(0, 0)  assert p1.x() == 0 assert p1.y() == 0 assert p2.x() == 2 assert p2.y() == 4 assert p1.toString() == 'Point[x=0, y=0]' assert p2.toString() == 'Point[x=2, y=4]' assert p1 == p3<\/code><\/pre>\n<h3>\u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 (Sealed) \u0442\u0438\u043f\u044b<\/h3>\n<p>\u042d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0444\u0438\u0447\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Java. \u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u0430\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b (\u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b) \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 sealed \u0442\u0438\u043f. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a \u044f\u0432\u043d\u043e (\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 &#171;permits&#187;), \u0442\u0430\u043a \u0438 \u043d\u0435\u044f\u0432\u043d\u043e (\u0431\u0435\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430), \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u041f\u043e\u0434\u043e\u0431\u043d\u043e records, Groovy \u0442\u0430\u043a\u0436\u0435 \u0432\u0432\u043e\u0434\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@Sealed<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b? \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0418\u043b\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a \u2014 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0435\u043c, \u043d\u0430 \u0447\u0442\u043e \u0432\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<pre><code>import groovy.transform.ToString  sealed interface Tree&lt;T> { }  @Singleton final class Empty implements Tree {     String toString() { \"Empty\" } }  @ToString final class Node&lt;T> implements Tree&lt;T> {     final T value     final Tree&lt;T> left, right      Node(T value, Tree&lt;T> left, Tree&lt;T> right) {         this.value = value         this.left = left         this.right = right     } }<\/code><\/pre>\n<h3>\u0421\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432 (\u0442\u0430\u0439\u043f-\u0447\u0435\u043a\u0435\u0440\u044b)<\/h3>\n<p>\u0425\u043e\u0442\u044f Groovy, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0432\u043e\u0438\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c, \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0431\u044b\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0438\u043c \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0442\u0438\u043f\u043e\u0432, \u0447\u0435\u043c Java. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <code>groovy-typecheckers<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0435\u043a\u0441-\u0447\u0435\u043a\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0432\u044b\u044f\u0432\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0432\u0430\u0448\u0438\u0445 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041a\u0430\u043a \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u2014 \u0432 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0441\u043a\u043e\u0431\u043a\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0435\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430 \u0438\u043b\u0438 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430. \u0417\u0434\u0435\u0441\u044c \u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 GroovyShell, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 MultipleCompilationErrorsException.<\/p>\n<pre><code>import groovy.transform.TypeChecked  @TypeChecked(extensions = 'groovy.typecheckers.RegexChecker') def testRegexChecker() {     def date = '2022-04-03'      assert date ==~ \/(\\d{4})-(\\d{1,2})-(\\d{1,2}\/ }<\/code><\/pre>\n<h3>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u043c\u0435\u0442\u043e\u0434\u044b<\/h3>\n<p>\u041c\u0430\u043a\u0440\u043e\u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 AST \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0438. \u0412\u044b\u0437\u043e\u0432 \u043c\u0430\u043a\u0440\u043e\u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u2014 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u043a\u0440\u043e\u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0442\u043e\u0434 <code>SV<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u041c\u0435\u0442\u043e\u0434 <code>SVI<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 Groovy inspect, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0430\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043d \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 range, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<pre><code>def num = 42 def list = [1 ,2, 3] def range = 0..5 def string = 'foo'  assert SV(num, list, range, string) == 'num=42, list=[1, 2, 3], range=[0, 1, 2, 3, 4, 5], string=foo'  assert SVI(range) == 'range=0..5'  assert NV(range) instanceof NamedValue  assert NV(string).name == 'string' &amp;&amp; NV(string).val == 'foo'<\/code><\/pre>\n<h3>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f @POJO<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 Groovy, \u0442\u043e \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u044d\u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>GroovyObject<\/code>. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u0441\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 Groovy. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Groovy \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c Java-\u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0432\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u043e\u0432\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438  <code>@POJO<\/code> . \u041b\u044e\u0431\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 @POJO, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0431\u0435\u0437 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f Groovy \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430. \u0422\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u043a\u043b\u0430\u0441\u0441 <code>PojoPoint<\/code>, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 Java.<\/p>\n<pre><code>import groovy.transform.CompileStatic import groovy.transform.Immutable import groovy.transform.stc.POJO  @POJO @Immutable @CompileStatic class PojoPoint {     int x, y      static void main(String[] args) {         PojoPoint point = new PojoPoint(1,1)         System.out.println(point.toString())     } }<\/code><\/pre>\n<h3>\u041a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b Groovy<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b Groovy \u043c\u043e\u0433\u0443\u0442 \u0441\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0430\u0441 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0431\u043b\u0430\u0433\u043e\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0441\u0442\u0430\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0439 \u043a\u043e\u0434. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>@Invariant<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043b\u0430\u0439\u0444\u0442\u0430\u0439\u043c\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u2014 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@Requires<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0435 \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u043c. \u0410 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@Ensures<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u2014 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0435 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0436\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0441 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u044f\u0432\u043d\u044b\u043c\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0442\u0435\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430. \u0418 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0434\u0430. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u044b\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b, \u0442\u043e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b Groovy \u2014 \u044d\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<pre><code>import groovy.contracts.Ensures import groovy.contracts.Invariant import groovy.contracts.Requires  @Invariant({ speed >= 0 }) class Rocket {     int speed = 0     boolean started = false      @Requires({ !started })     Rocket startEngine() { tap {started = true }}      @Requires({ started })     Rocket stopEngine() { tap { started = false }}      @Requires({ started })     @Ensures({ old.speed &lt; speed })     Rocket accelerate(int value) { tap { speed += value }} }<\/code><\/pre>\n<h3>GINQ<\/h3>\n<p>GINQ \u2014 Groovy-\u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u044d\u0442\u0430 \u0444\u0438\u0447\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0435\u0441\u044c \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u043e\u043c SQL-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432. GINQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f SQL-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u041a\u0430\u043a \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043f\u043e\u043b\u0435 <code>people<\/code> (\u043b\u044e\u0434\u0438). \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c GINQ, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435\u0445 \u043b\u044e\u0434\u0435\u0439 \u0432 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0435 18+ \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044f, \u0432\u0437\u044f\u0432 \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0431\u0443\u043a\u0432\u0430\u043c\u0438. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u0437\u043d\u0430\u044e, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 Groovy \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c GINQ \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 SQL, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0435 \u043f\u043e \u0442\u0438\u043f\u0443.<\/p>\n<pre><code>import groovy.json.JsonSlurper  def json = new JsonSlurper().parseText '''     {         \"people\": [             {\"name\": \"Alan\", \"age\": 11},             {\"name\": \"Mary\", \"age\": 26},             {\"name\": \"Eric\", \"age\": 34},             {\"name\": \"Elisabeth\", \"age\": 14},             {\"name\": \"Marc\", \"age\": 2},             {\"name\": \"Robert\", \"age\": 52},             {\"name\": \"Veronica\", \"age\": 32},             {\"name\": \"Alex\", \"age\": 17}         ]     }     '''  assert GQ {     from f in json.people     where f.age >= 18     orderby f.age in desc     limit 3     select f.name.toUpperCase().take(2)  }.toList() == ['RO', 'ER', 'VE']<\/code><\/pre>\n<h3>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 TOML<\/h3>\n<p>\u0412 Groovy 3 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 YAML, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 Groovy 4 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 TOML. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u0442\u0430\u043a\u0438\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0432 \u0441\u0432\u043e\u0435\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u0435. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u044b\u0432\u043e\u0434, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u043c TomlBuilder, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446, \u0430 \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u0435\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0430\u043c\u0438.<\/p>\n<pre><code>import groovy.toml.TomlBuilder import groovy.toml.TomlSlurper  String input = ''' # This is a TOML document (taken from https:\/\/toml.io)  title = \"TOML Example\"  [owner] name = \"Tom Preston-Werner\" dob = 1979-05-27T07:32:00-08:00  [database] enabled = true ports = [ 8000, 8001, 8002 ] data = [ [\"delta\", \"phi\"], [3.14] ] temp_targets = { cpu = 79.5, case = 72.0 }  [servers]  [servers.alpha] ip = \"10.0.0.1\" role = \"frontend\"  [servers.beta] ip = \"10.0.0.2\" role = \"backend\" '''  def toml = new TomlSlurper().parseText(input)  assert toml.title == 'TOML Example' assert toml.owner.name == 'Tom Preston-Werner' assert toml.database.ports == [8000, 8001, 8002] assert toml.servers.alpha.ip == '10.0.0.1' assert toml.servers.beta.ip == '10.0.0.2'   TomlBuilder builder = new TomlBuilder() builder {     title 'This is TOML document'     servers {         alpha {             ip '10.0.0.1'         }         beta {             ip '10.0.0.2'         }     } } assert builder.toString() == '''title = 'This is TOML document' servers.alpha.ip = '10.0.0.1' servers.beta.ip = '10.0.0.2' '''<\/code><\/pre>\n<h3>\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 JDK 8<\/h3>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f Java, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Groovy 4, \u2014 JDK 8. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u2014 &#171;\u043d\u043e \u043a\u0430\u043a Groovy \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u043f\u0438\u0441\u0438&#187;? \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u0432\u0430\u043c \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0436\u0443. \u0411\u0435\u0440\u0443 Java 17 \u0438 Groovy 4.0.1. \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \u0444\u0430\u0439\u043b \u043a\u043b\u0430\u0441\u0441\u0430, \u0438 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0435\u0433\u043e \u0432 IntelliJ, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430 Java, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0430 Java 8 \u0438 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435. \u041e\u0442\u043a\u0440\u044b\u0432 \u0444\u0430\u0439\u043b \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 IntelliJ, \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 &#171;\u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442&#187; \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0435 \u0440\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u0418 \u0432 \u044d\u0442\u043e\u043c \u0432\u0441\u044f \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430 Groovy \u2014 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0434\u0430\u0436\u0435 \u043d\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Java.<\/p>\n<hr\/>\n<p>\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 DevOps-\u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432 \u0438 Java-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u0435 <strong>\u00ab\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u043e\u0432 \u0432 Jenkins 123\u00bb<\/strong>. \u041d\u0430 \u0437\u0430\u043d\u044f\u0442\u0438\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u044b \u0432 Jenkins: \u0438\u0437 \u043a\u0430\u043a\u0438\u0445 \u0448\u0430\u0433\u043e\u0432 \u0438 \u0431\u043b\u043e\u043a\u043e\u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u0442; \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c groovy \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u043e\u0432 \u0438 \u0438\u0437\u0443\u0447\u0438\u043c \u0438\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0430 <a href=\"https:\/\/otus.pw\/NvzrU\/\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/702356\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/702356\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 (sealed) \u0442\u0438\u043f\u044b, switch-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0438\u043f\u044b record. \u042d\u0442\u043e \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u043e\u0432\u044b\u0445 \u0444\u0438\u0447, \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435 Groovy 4.0. \u0412 \u044d\u0442\u043e\u043c \u0432\u0438\u0434\u0435\u043e \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u0434\u0435\u0441\u044f\u0442\u044c \u0432\u0435\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 Groovy 4.0 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0437\u0430\u0442\u044f\u043d\u0443\u0442\u044b\u043c, \u043c\u044b \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u043c \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u043d\u0438\u0445. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d \u0434\u0430\u0442\u044c \u0432\u0430\u043c \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u043d\u043e\u0432\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/63861694003e93ef14dfb9f3\" data-style=\"\" id=\"63861694003e93ef14dfb9f3\" width=\"\"><\/div>\n<p>\u2139\ufe0f \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430: <a href=\"https:\/\/github.com\/wololock\/groovy-4-examples\"><u>https:\/\/github.com\/wololock\/groovy-4-examples<\/u><\/a><\/p>\n<h3>Switch-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u00a0<\/h3>\n<p>\u0412 Groovy \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b switch \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 Java. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u0438\u043b\u0438, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0440\u0430\u0432\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u043b\u0430\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 switch \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 Groovy. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c, \u0441\u043b\u0435\u0434\u0443\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c \u0432 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Java, Groovy \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438 switch-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c switch \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0439 \u0441 Java, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432, \u043d\u043e \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u0435\u0435.<\/p>\n<pre><code>switch (value) {     case null -> 'just a null'     case 0 -> 'zero'     case 1 -> 'one'     case { it instanceof List &amp;&amp; it.empty } -> 'an empty list'     case List -> 'a list'     case '007' -> 'James Bond'     case ~\/\\d+\/ -> 'a number'     default -> 'unknown' }<\/code><\/pre>\n<h3>Records (\u0417\u0430\u043f\u0438\u0441\u0438)<\/h3>\n<p>Records, \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 (\u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0439) \u0442\u0438\u043f &#171;\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445&#187;, \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 Java 16. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0438 \u0432 Groovy. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0442\u043e\u0442 \u0436\u0435, \u0445\u043e\u0442\u044f Groovy \u0442\u0430\u043a\u0436\u0435 \u0432\u0432\u043e\u0434\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@RecordType<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e. \u0418 \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438\u0433\u0440\u044b, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0434\u043b\u044f Java, \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e Groovy \u0438\u0434\u0435\u0442 \u0432 \u043d\u043e\u0433\u0443 \u0441 \u043d\u043e\u0432\u0435\u0439\u0448\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0435\u0433\u043e \u0440\u043e\u0434\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<\/p>\n<pre><code>record Point(int x, int y) {}  def p1 = new Point(0, 0) def p2 = new Point(2, 4) def p3 = new Point(0, 0)  assert p1.x() == 0 assert p1.y() == 0 assert p2.x() == 2 assert p2.y() == 4 assert p1.toString() == 'Point[x=0, y=0]' assert p2.toString() == 'Point[x=2, y=4]' assert p1 == p3<\/code><\/pre>\n<h3>\u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 (Sealed) \u0442\u0438\u043f\u044b<\/h3>\n<p>\u042d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0444\u0438\u0447\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Java. \u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u0430\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b (\u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b) \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 sealed \u0442\u0438\u043f. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a \u044f\u0432\u043d\u043e (\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 &#171;permits&#187;), \u0442\u0430\u043a \u0438 \u043d\u0435\u044f\u0432\u043d\u043e (\u0431\u0435\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430), \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u041f\u043e\u0434\u043e\u0431\u043d\u043e records, Groovy \u0442\u0430\u043a\u0436\u0435 \u0432\u0432\u043e\u0434\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@Sealed<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b? \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0418\u043b\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a \u2014 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0435\u043c, \u043d\u0430 \u0447\u0442\u043e \u0432\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<pre><code>import groovy.transform.ToString  sealed interface Tree&lt;T> { }  @Singleton final class Empty implements Tree {     String toString() { \"Empty\" } }  @ToString final class Node&lt;T> implements Tree&lt;T> {     final T value     final Tree&lt;T> left, right      Node(T value, Tree&lt;T> left, Tree&lt;T> right) {         this.value = value         this.left = left         this.right = right     } }<\/code><\/pre>\n<h3>\u0421\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432 (\u0442\u0430\u0439\u043f-\u0447\u0435\u043a\u0435\u0440\u044b)<\/h3>\n<p>\u0425\u043e\u0442\u044f Groovy, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0432\u043e\u0438\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c, \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0431\u044b\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0438\u043c \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0442\u0438\u043f\u043e\u0432, \u0447\u0435\u043c Java. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <code>groovy-typecheckers<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0435\u043a\u0441-\u0447\u0435\u043a\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0432\u044b\u044f\u0432\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0432\u0430\u0448\u0438\u0445 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041a\u0430\u043a \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u2014 \u0432 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0441\u043a\u043e\u0431\u043a\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0435\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430 \u0438\u043b\u0438 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430. \u0417\u0434\u0435\u0441\u044c \u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 GroovyShell, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 MultipleCompilationErrorsException.<\/p>\n<pre><code>import groovy.transform.TypeChecked  @TypeChecked(extensions = 'groovy.typecheckers.RegexChecker') def testRegexChecker() {     def date = '2022-04-03'      assert date ==~ \/(\\d{4})-(\\d{1,2})-(\\d{1,2}\/ }<\/code><\/pre>\n<h3>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u043c\u0435\u0442\u043e\u0434\u044b<\/h3>\n<p>\u041c\u0430\u043a\u0440\u043e\u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 AST \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0438. \u0412\u044b\u0437\u043e\u0432 \u043c\u0430\u043a\u0440\u043e\u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u2014 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u043a\u0440\u043e\u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0442\u043e\u0434 <code>SV<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u041c\u0435\u0442\u043e\u0434 <code>SVI<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 Groovy inspect, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0430\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043d \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 range, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<pre><code>def num = 42 def list = [1 ,2, 3] def range = 0..5 def string = 'foo'  assert SV(num, list, range, string) == 'num=42, list=[1, 2, 3], range=[0, 1, 2, 3, 4, 5], string=foo'  assert SVI(range) == 'range=0..5'  assert NV(range) instanceof NamedValue  assert NV(string).name == 'string' &amp;&amp; NV(string).val == 'foo'<\/code><\/pre>\n<h3>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f @POJO<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 Groovy, \u0442\u043e \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u044d\u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>GroovyObject<\/code>. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u0441\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 Groovy. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Groovy \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c Java-\u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0432\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u043e\u0432\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438  <code>@POJO<\/code> . \u041b\u044e\u0431\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 @POJO, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0431\u0435\u0437 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f Groovy \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430. \u0422\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u043a\u043b\u0430\u0441\u0441 <code>PojoPoint<\/code>, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 Java.<\/p>\n<pre><code>import groovy.transform.CompileStatic import groovy.transform.Immutable import groovy.transform.stc.POJO  @POJO @Immutable @CompileStatic class PojoPoint {     int x, y      static void main(String[] args) {         PojoPoint point = new PojoPoint(1,1)         System.out.println(point.toString())     } }<\/code><\/pre>\n<h3>\u041a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b Groovy<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b Groovy \u043c\u043e\u0433\u0443\u0442 \u0441\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0430\u0441 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0431\u043b\u0430\u0433\u043e\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0441\u0442\u0430\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0439 \u043a\u043e\u0434. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>@Invariant<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043b\u0430\u0439\u0444\u0442\u0430\u0439\u043c\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u2014 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@Requires<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0435 \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u043c. \u0410 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <code>@Ensures<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u2014 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0435 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u0442\u043e-\u0442\u043e \u0441\u043a\u0430\u0436\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0441 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u044f\u0432\u043d\u044b\u043c\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0442\u0435\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430. \u0418 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0434\u0430. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u044b\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b, \u0442\u043e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b Groovy \u2014 \u044d\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<pre><code>import groovy.contracts.Ensures import groovy.contracts.Invariant import groovy.contracts.Requires  @Invariant({ speed >= 0 }) class Rocket {     int speed = 0     boolean started = false      @Requires({ !started })     Rocket startEngine() { tap {started = true }}      @Requires({ started })     Rocket stopEngine() { tap { started = false }}      @Requires({ started })     @Ensures({ old.speed &lt; speed })     Rocket accelerate(int value) { tap { speed += value }} }<\/code><\/pre>\n<h3>GINQ<\/h3>\n<p>GINQ \u2014 Groovy-\u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u044d\u0442\u0430 \u0444\u0438\u0447\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0435\u0441\u044c \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u043e\u043c SQL-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432. GINQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f SQL-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u041a\u0430\u043a \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c JSON-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043f\u043e\u043b\u0435 <code>people<\/code> (\u043b\u044e\u0434\u0438). \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c GINQ, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435\u0445 \u043b\u044e\u0434\u0435\u0439 \u0432 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0435 18+ \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044f, \u0432\u0437\u044f\u0432 \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0431\u0443\u043a\u0432\u0430\u043c\u0438. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u0437\u043d\u0430\u044e, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 Groovy \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c GINQ \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 SQL, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0435 \u043f\u043e \u0442\u0438\u043f\u0443.<\/p>\n<pre><code>import groovy.json.JsonSlurper  def json = new JsonSlurper().parseText '''     {         \"people\": [             {\"name\": \"Alan\", \"age\": 11},             {\"name\": \"Mary\", \"age\": 26},             {\"name\": \"Eric\", \"age\": 34},             {\"name\": \"Elisabeth\", \"age\": 14},             {\"name\": \"Marc\", \"age\": 2},             {\"name\": \"Robert\", \"age\": 52},             {\"name\": \"Veronica\", \"age\": 32},             {\"name\": \"Alex\", \"age\": 17}         ]     }     '''  assert GQ {     from f in json.people     where f.age >= 18     orderby f.age in desc     limit 3     select f.name.toUpperCase().take(2)  }.toList() == ['RO', 'ER', 'VE']<\/code><\/pre>\n<h3>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 TOML<\/h3>\n<p>\u0412 Groovy 3 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 YAML, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 Groovy 4 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 TOML. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u0442\u0430\u043a\u0438\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0432 \u0441\u0432\u043e\u0435\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u0435. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u044b\u0432\u043e\u0434, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u043c TomlBuilder, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446, \u0430 \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u0435\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0430\u043c\u0438.<\/p>\n<pre><code>import groovy.toml.TomlBuilder import groovy.toml.TomlSlurper  String input = ''' # This is a TOML document (taken from https:\/\/toml.io)  title = \"TOML Example\"  [owner] name = \"Tom Preston-Werner\" dob = 1979-05-27T07:32:00-08:00  [database] enabled = true ports = [ 8000, 8001, 8002 ] data = [ [\"delta\", \"phi\"], [3.14] ] temp_targets = { cpu = 79.5, case = 72.0 }  [servers]  [servers.alpha] ip = \"10.0.0.1\" role = \"frontend\"  [servers.beta] ip = \"10.0.0.2\" role = \"backend\" '''  def toml = new TomlSlurper().parseText(input)  assert toml.title == 'TOML Example' assert toml.owner.name == 'Tom Preston-Werner' assert toml.database.ports == [8000, 8001, 8002] assert toml.servers.alpha.ip == '10.0.0.1' assert toml.servers.beta.ip == '10.0.0.2'   TomlBuilder builder = new TomlBuilder() builder {     title 'This is TOML document'     servers {         alpha {             ip '10.0.0.1'         }         beta {             ip '10.0.0.2'         }     } } assert builder.toString() == '''title = 'This is TOML document' servers.alpha.ip = <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-341906","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341906"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341906\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}