<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://baidushabi.com</id>
    <title>四十五</title>
    <updated>2020-03-26T08:20:49.699Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://baidushabi.com"/>
    <link rel="self" href="https://baidushabi.com/atom.xml"/>
    <subtitle>随缘写写</subtitle>
    <logo>https://baidushabi.com/images/avatar.png</logo>
    <icon>https://baidushabi.com/favicon.ico</icon>
    <rights>All rights reserved 2020, 四十五</rights>
    <entry>
        <title type="html"><![CDATA[Groovy一时爽]]></title>
        <id>https://baidushabi.com/post/groovy-is-very-ok/</id>
        <link href="https://baidushabi.com/post/groovy-is-very-ok/">
        </link>
        <updated>2020-03-20T05:10:54.000Z</updated>
        <content type="html"><![CDATA[<h5 id="闭包火葬场">闭包火葬场。</h5>
<ul>
<li>each { } : return ==&gt; (Java) continue ----终止当前循环执行，继续后面的循环</li>
<li>find { } : return true ==&gt; (Java) break ----终止所有闭包循环，返回当前it；<br>
return false ==&gt; (Java) continue ----终止当前循环执行，继续后面的循环，如果最终没有return true，返回结果是null，find用于查找值，闭包参数用作终止条件（故需要布尔类型），也可以骚操作用来迭代。</li>
<li>with { } : 如果用来实例化类，别忘了返回值！<pre><code class="language-java">def jack = new Person().with {
     name = &quot;jack&quot;
     age = 12
     //不return自己，就会返回age，最后jack会变成12
     return it
 }
</code></pre>
</li>
<li>闭包嵌套，it傻傻分不清<pre><code class="language-java">each {
      it.each {
          println it
      }
  }
</code></pre>
</li>
</ul>
<h5 id="语法骚断腿使用需谨慎">语法骚断腿，使用需谨慎。</h5>
<pre><code class="language-java">      // 可以
      def s = (1..10000).sum()
      println s

      //不红，会报错
      println (1..10000).sum()

      //可以，等于第一个
      println((1..10000).sum())

      //可以，不会报错，但是不太红，不是我们想要的
      1..10000.each {
          println it
      }

      //可以
      (1..10000).each {
          println it
      }

      //索引0开始，用值需谨慎
      10000.times {

      }
</code></pre>
]]></content>
    </entry>
    <entry>
        <title type="html"><![CDATA[写一个maven插件]]></title>
        <id>https://baidushabi.com/post/write-a-maven-plugin/</id>
        <link href="https://baidushabi.com/post/write-a-maven-plugin/">
        </link>
        <updated>2019-03-06T05:06:45.000Z</updated>
        <content type="html"><![CDATA[<h5 id="核心类">核心类：</h5>
<p>AbstractMojo</p>
<h5 id="核心依赖注入">核心依赖注入：</h5>
<p>@Parameter(defaultValue = &quot;${project}&quot;, readonly = true)</p>
<h5 id="参数注入pom或-d">参数注入（pom或-D）：</h5>
<p>@Parameter(property = &quot;config.name&quot;)</p>
<h5 id="重写">重写：</h5>
<p>execute()</p>
<h5 id="配置pom">配置pom：</h5>
<pre><code class="language-xml">&lt;plugin&gt;
  &lt;groupId&gt;xxx&lt;/groupId&gt;
  &lt;artifactId&gt;xxx&lt;/artifactId&gt;
  &lt;!--注意使用最新版本--&gt;
  &lt;version&gt;1.1&lt;/version&gt;
  &lt;configuration&gt;
      &lt;name&gt;xxxx.xxxx.xxx&lt;/name&gt;
  &lt;/configuration&gt;
  &lt;executions&gt;
      &lt;execution&gt;
          &lt;phase&gt;process-resources&lt;/phase&gt;
          &lt;goals&gt;
              &lt;goal&gt;xxx&lt;/goal&gt;
          &lt;/goals&gt;
      &lt;/execution&gt;
  &lt;/executions&gt;
&lt;/plugin&gt;
</code></pre>
]]></content>
    </entry>
</feed>