{"id":318735,"date":"2021-02-27T21:00:30","date_gmt":"2021-02-27T21:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=318735"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=318735","title":{"rendered":"Pattern matching \u0432 Java 8"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u041c\u043d\u043e\u0433\u0438\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u044f\u0437\u044b\u043a\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c (pattern matching) \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u044f\u0437\u044b\u043a\u0430. <br \/>  \u042f\u0437\u044b\u043a Java \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c. \u0418 \u0432 Java 16 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 instanceof, \u043a\u0430\u043a \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0438\u0447\u0438.<br \/>  \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043e \u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u043e \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u0435\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0435\u0433\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c. <br \/>  \u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441 \u0442\u0435\u0445 \u0438\u043b\u0438 \u0438\u043d\u044b\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 Java. \u0411\u043b\u0430\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Java 8, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 pattern matching \u0432 \u0432\u0438\u0434\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. <br \/>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0438 \u043a\u0430\u043a \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>  <i><b>Constant pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0432\u043d\u043e\u0441\u0442\u044c \u0441 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438. \u0412 Java \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 switch \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0432\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u0430, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0432\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434 equals().<\/p>\n<pre><code class=\"java\">switch (data) {       case new Person(&quot;man&quot;)    -&gt; System.out.println(&quot;man&quot;);       case new Person(&quot;woman&quot;)  -&gt; System.out.println(&quot;woman&quot;);       case new Person(&quot;child&quot;) \t-&gt; System.out.println(&quot;child&quot;);               case null                 -&gt; System.out.println(&quot;Null value &quot;);       default                   -&gt; System.out.println(&quot;Default value: &quot; + data); }; <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438\u0445 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435 if. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0444\u043e\u0440\u043c\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0430\u043a \u0438 \u043a\u0430\u043a \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<br \/>  \u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.ConstantPattern.*;  matches(data).as(       new Person(&quot;man&quot;),    () -&gt;  System.out.println(&quot;man&quot;);       new Person(&quot;woman&quot;),  () -&gt;  System.out.println(&quot;woman&quot;);       new Person(&quot;child&quot;),  () -&gt;  System.out.println(&quot;child&quot;);               Null.class,           () -&gt;  System.out.println(&quot;Null value &quot;),       Else.class,           () -&gt;  System.out.println(&quot;Default value: &quot; + data) );  matches(data).as(       or(1, 2),    () -&gt;  System.out.println(&quot;1 or 2&quot;);       in(3, 6),    () -&gt;  System.out.println(&quot;between 3 and 6&quot;);       in(7),       () -&gt;  System.out.println(&quot;7&quot;);               Null.class,  () -&gt;  System.out.println(&quot;Null value &quot;),       Else.class,  () -&gt;  System.out.println(&quot;Default value: &quot; + data) ); <\/code><\/pre>\n<p>  <i><b>Tuple pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0432\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. <\/p>\n<pre><code class=\"java\">var (side, width) = border;  switch (side, width) {       case (&quot;top&quot;,    25) -&gt; System.out.println(&quot;top&quot;);       case (&quot;bottom&quot;, 30) -&gt; System.out.println(&quot;bottom&quot;);       case (&quot;left&quot;,   15) -&gt; System.out.println(&quot;left&quot;);               case (&quot;right&quot;,  15) -&gt; System.out.println(&quot;right&quot;);        case null         -&gt; System.out.println(&quot;Null value &quot;);       default           -&gt; System.out.println(&quot;Default value &quot;); };  for ((side, width) : listBorders) {       System.out.println(&quot;border: &quot; + [side + &quot;,&quot; + width]); \t } <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u0440\u043e\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0444\u043e\u0440\u043c\u0435 switch, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0438\u043b\u0438 \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u0446\u0438\u043a\u043b\u0435.<\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.TuplePattern.*;  let(border, (String side, int width) -&gt; {     System.out.println(&quot;border: &quot; + side + &quot;,&quot; + width); });  matches(side, width).as(       of(&quot;top&quot;,    25),  () -&gt; System.out.println(&quot;top&quot;);       of(&quot;bottom&quot;, 30),  () -&gt; System.out.println(&quot;bottom&quot;);       of(&quot;left&quot;,   15,  () -&gt; System.out.println(&quot;left&quot;);               of(&quot;right&quot;,  15),  () -&gt; System.out.println(&quot;right&quot;);                Null.class,    () -&gt; System.out.println(&quot;Null value&quot;),       Else.class,    () -&gt; System.out.println(&quot;Default value&quot;) );  foreach(listBorders, (String side, int width) -&gt; {      System.out.println(&quot;border: &quot; + side + &quot;,&quot; + width); \t } <\/code><\/pre>\n<p>  <i><b>Type test pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. <\/p>\n<pre><code class=\"java\">switch (data) {       case Integer i  -&gt; System.out.println(i * i);       case Byte    b  -&gt; System.out.println(b * b);       case Long    l  -&gt; System.out.println(l * l);               case String  s  -&gt; System.out.println(s * s);       case null       -&gt; System.out.println(&quot;Null value &quot;);       default         -&gt; System.out.println(&quot;Default value: &quot; + data); }; <\/code><\/pre>\n<p>  \u0412 Java \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0438\u043f, \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u0438\u043f\u0443 \u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u043a\u043e\u0434 \u0441\u0442\u0430\u0435\u0442 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435. <\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.VerifyPattern.matches;  matches(data).as(       Integer.class, i  -&gt; { System.out.println(i * i); },       Byte.class,    b  -&gt; { System.out.println(b * b); },       Long.class,    l  -&gt; { System.out.println(l * l); },       String.class,  s  -&gt; { System.out.println(s * s); },       Null.class,    () -&gt; { System.out.println(&quot;Null value &quot;); },       Else.class,    () -&gt; { System.out.println(&quot;Default value: &quot; + data); } ); <\/code><\/pre>\n<p>  <i><b>Guard pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. <\/p>\n<pre><code class=\"java\">switch (data) {       case Integer i &amp;&amp; i != 0     -&gt; System.out.println(i * i);       case Byte    b &amp;&amp; b &gt; -1     -&gt; System.out.println(b * b);       case Long    l &amp;&amp; l &lt; 5      -&gt; System.out.println(l * l);       case String  s &amp;&amp; !s.empty() -&gt; System.out.println(s * s);       case null                    -&gt; System.out.println(&quot;Null value &quot;);       default                      -&gt; System.out.println(&quot;Default: &quot; + data); }; <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f: lessThan\/lt, greaterThan\/gt, lessThanOrEqual\/le, greaterThanOrEqual\/ge, equal\/eq, notEqual\/ne. \u0410 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043c\u0435\u043d\u0438\u0442\u044c: always\/yes, never\/no. <\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.GuardPattern.matches;  matches(data).as(                  Integer.class, i  -&gt; i != 0,  i  -&gt; { System.out.println(i * i); },       Byte.class,    b  -&gt; b &gt; -1,  b  -&gt; { System.out.println(b * b); },       Long.class,    l  -&gt; l == 5,  l  -&gt; { System.out.println(l * l); },       Null.class,    () -&gt; { System.out.println(&quot;Null value &quot;); },       Else.class,    () -&gt; { System.out.println(&quot;Default value: &quot; + data); } );  matches(data).as(                  Integer.class, ne(0),  i  -&gt; { System.out.println(i * i); },       Byte.class,    gt(-1), b  -&gt; { System.out.println(b * b); },       Long.class,    eq(5),  l  -&gt; { System.out.println(l * l); },       Null.class,    () -&gt; { System.out.println(&quot;Null value &quot;); },       Else.class,    () -&gt; { System.out.println(&quot;Default value: &quot; + data); } ); <\/code><\/pre>\n<p>  <i><b>Deconstruction pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438 \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435. <\/p>\n<pre><code class=\"java\">let (int w, int h) = figure;   switch (figure) {       case Rectangle(int w, int h) -&gt; out.println(&quot;square: &quot; + (w * h));       case Circle   (int r)        -&gt; out.println(&quot;square: &quot; + (2 * Math.PI * r));       default                      -&gt; out.println(&quot;Default square: &quot; + 0); };     for ((int w, int h) :  listFigures) {       System.out.println(&quot;square: &quot; + (w * h)); } <\/code><\/pre>\n<p>  \u0412 Java \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0438\u043f, \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u0438\u043f\u0443, \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044f\u043c \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.DeconstructPattern.*;  Figure figure = new Rectangle();  let(figure, (int w, int h) -&gt; {       System.out.println(&quot;border: &quot; + w + &quot; &quot; + h)); });  matches(figure).as(       Rectangle.class, (int w, int h) -&gt; out.println(&quot;square: &quot; + (w * h)),       Circle.class,    (int r)        -&gt; out.println(&quot;square: &quot; + (2 * Math.PI * r)),       Else.class,      ()             -&gt; out.println(&quot;Default square: &quot; + 0) );     foreach(listRectangles, (int w, int h) -&gt; {       System.out.println(&quot;square: &quot; + (w * h)); }); <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435, \u043a\u043b\u0430\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 <a href=\"https:\/\/habr.com\/ru\/users\/extract\/\" class=\"user_link\">Extract<\/a>. <br \/>  \u0412\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b IntRef, FloatRef \u0438 \u0442.\u0434. <br \/>  \u0427\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0438\u0439\u043e\u043c\u044b \u0441 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c LambdaMetafactory.<\/p>\n<pre><code class=\"java\">@Extract public void deconstruct(IntRef width, IntRef height) {       width.set(this.width);       height.set(this.height);  } <\/code><\/pre>\n<p>  <i><b>Property pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044f\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043e \u0438\u0445 \u0438\u043c\u0435\u043d\u0430\u043c. <\/p>\n<pre><code class=\"java\">let (w: int w, h:int h) = figure;   switch (figure) {       case Rectangle(w: int w == 5,  h: int h == 10) -&gt; out.println(&quot;sqr: &quot; + (w * h));       case Rectangle(w: int w == 10, h: int h == 15) -&gt; out.println(&quot;sqr: &quot; + (w * h));       case Circle   (r: int r) -&gt; out.println(&quot;sqr: &quot; + (2 * Math.PI * r));       default                  -&gt; out.println(&quot;Default sqr: &quot; + 0); };     for ((w: int w, h: int h) :  listRectangles) {       System.out.println(&quot;square: &quot; + (w * h)); } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u0434\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c.<br \/>  \u0427\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0438\u0439\u043e\u043c\u044b \u0441 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c LambdaMetafactory.<\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.PropertyPattern.*;    Figure figure = new Rectangle();  let(figure, of(&quot;w&quot;, &quot;h&quot;), (int w, int h) -&gt; {       System.out.println(&quot;border: &quot; + w + &quot; &quot; + h)); });  matches(figure).as(       Rect.class,    of(&quot;w&quot;, 5,  &quot;h&quot;, 10), (int w, int h) -&gt; out.println(&quot;sqr: &quot; + (w * h)),       Rect.class,    of(&quot;w&quot;, 10, &quot;h&quot;, 15), (int w, int h) -&gt; out.println(&quot;sqr: &quot; + (w * h)),       Circle.class,  of(&quot;r&quot;), (int r)  -&gt; out.println(&quot;sqr: &quot; + (2 * Math.PI * r)),       Else.class,    ()                -&gt; out.println(&quot;Default sqr: &quot; + 0) );     foreach(listRectangles, of(&quot;x&quot;, &quot;y&quot;), (int w, int h) -&gt; {       System.out.println(&quot;square: &quot; + (w * h)); }); <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<pre><code class=\"java\">Figure figure = new Rect();  let(figure, Rect::w, Rect::h, (int w, int h) -&gt; {       System.out.println(&quot;border: &quot; + w + &quot; &quot; + h)); });  matches(figure).as(       Rect.class,    Rect::w, Rect::h, (int w, int h) -&gt; System.out.println(&quot;sqr: &quot; + (w * h)),       Circle.class,  Circle::r, (int r)  -&gt; System.out.println(&quot;sqr: &quot; + (2 * Math.PI * r)),       Else.class,    ()                  -&gt; System.out.println(&quot;Default sqr: &quot; + 0) );     foreach(listRectangles, Rect::w, Rect::h, (int w, int h) -&gt; {       System.out.println(&quot;square: &quot; + (w * h)); }); <\/code><\/pre>\n<p>  <i><b>Position pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f. <\/p>\n<pre><code class=\"java\">switch (data) {       case Circle(5)   -&gt; System.out.println(&quot;small circle&quot;);       case Circle(15)  -&gt; System.out.println(&quot;middle circle&quot;);       case null        -&gt; System.out.println(&quot;Null value &quot;);       default          -&gt; System.out.println(&quot;Default value: &quot; + data); }; <\/code><\/pre>\n<p>  \u0412 Java \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0438\u043f, \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u0438\u043f\u0443, \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044f\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0432\u043d\u043e\u0441\u0442\u044c.<br \/>  \u0427\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.PositionPattern.*;  matches(data).as(                  Circle.class,  of(5),  () -&gt; { System.out.println(&quot;small circle&quot;); },       Circle.class,  of(15), () -&gt; { System.out.println(&quot;middle circle&quot;); },       Null.class,            () -&gt; { System.out.println(&quot;Null value &quot;); },       Else.class,            () -&gt; { System.out.println(&quot;Default value: &quot; + data); } ); <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044f, \u044d\u0442\u0438 \u043f\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 <a href=\"https:\/\/habr.com\/ru\/users\/exclude\/\" class=\"user_link\">Exclude<\/a>. \u042d\u0442\u0438 \u043f\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438.<\/p>\n<pre><code class=\"java\">class Circle {       private int radius;       \t         @Exclude       private int temp;  } <\/code><\/pre>\n<p>  <i><b>Static pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438 \u0434\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. <\/p>\n<pre><code class=\"java\">  switch (some) {       case Result.value(var v) -&gt; System.out.println(&quot;value: &quot; + v);       case Result.error(var e) -&gt; System.out.println(&quot;error: &quot; + e);       default                    -&gt; System.out.println(&quot;Default value&quot;); }; <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u043e \u0434\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430, \u043d\u043e \u0438\u043c\u044f \u0434\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 <a href=\"https:\/\/habr.com\/ru\/users\/extract\/\" class=\"user_link\">Extract<\/a>, \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u044f\u0432\u043d\u043e.<br \/>  \u0427\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0438\u0439\u043e\u043c\u044b \u0441 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c LambdaMetafactory.<\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.StaticPattern.*;  matches(figure).as(       Result.class, of(&quot;value&quot;), (var v) -&gt; System.out.println(&quot;value: &quot; + v),       Result.class, of(&quot;error&quot;), (var e) -&gt; System.out.println(&quot;error: &quot; + e),       Else.class, () -&gt; System.out.println(&quot;Default value&quot;) );  <\/code><\/pre>\n<p>  <i><b>Sequence pattern<\/b><\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"java\">List&lt;Integer&gt; list = ...;    switch (list) {       case empty()     -&gt; System.out.println(&quot;Empty value&quot;);       case head(var h) -&gt; System.out.println(&quot;list head: &quot; + h);       case tail(var t) -&gt; System.out.println(&quot;list tail: &quot; + t);                   default          -&gt; System.out.println(&quot;Default value&quot;); }; <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.SequencePattern.*;  List&lt;Integer&gt; list = List.of(1, 2, 3);  matches(figure,       empty() ()      -&gt; System.out.println(&quot;Empty value&quot;),       head(), (var h) -&gt; System.out.println(&quot;list head: &quot; + h),       tail(), (var t) -&gt; System.out.println(&quot;list tail: &quot; + t),             Else.class, ()  -&gt; System.out.println(&quot;Default value&quot;) );    <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043a\u0430\u043a \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u0444\u0438\u0447\u0438 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"java\">import static org.kl.jpml.pattern.CommonPattern.*;  var rect = lazy(Rectangle::new); var result = elvis(rect.get(), new Rectangle());     with(rect, it -&gt; {    it.setWidth(5);    it.setHeight(10); });     when(     side == Side.LEFT,  () -&gt; System.out.println(&quot;left  value&quot;),     side == Side.RIGHT, () -&gt; System.out.println(&quot;right value&quot;) );     repeat(3, () -&gt; {    System.out.println(&quot;three time&quot;); )     int even = self(number).takeIf(it -&gt; it % 2 == 0); int odd  = self(number).takeUnless(it -&gt; it % 2 == 0); <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c pattern matching \u0441\u0438\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Java 8 \u043c\u043e\u0436\u043d\u043e \u0441\u044d\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 pattern matching \u0441\u0430\u043c\u044b\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u044f\u0437\u044b\u043a\u0430.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0434 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 github: <a href=\"https:\/\/github.com\/klappdev\/jpml\" rel=\"nofollow noopener noreferrer\">link<\/a>. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043e\u0442\u0437\u044b\u0432\u0430\u043c, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e.<\/div>\n<p> \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\/post\/544560\/\"> https:\/\/habr.com\/ru\/post\/544560\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u041c\u043d\u043e\u0433\u0438\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u044f\u0437\u044b\u043a\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c (pattern matching) \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u044f\u0437\u044b\u043a\u0430. <br \/>  \u042f\u0437\u044b\u043a Java \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c. \u0418 \u0432 Java 16 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 instanceof, \u043a\u0430\u043a \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0438\u0447\u0438.<br \/>  \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043e \u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439.  <\/p>\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-318735","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/318735","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=318735"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/318735\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=318735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=318735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=318735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}