<div dir="ltr">Sure, take this example:<div><br></div><div>







<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="courier new, monospace">                    .addRule()<br>
                    .when(Selection.exists(XMLFile.<span class="">class</span>, <span class="">&quot;xmls&quot;</span>)<br>                                .with(Element.DOCTYPE, <span class="">&quot;<a href="http://maven.apache.org/POM/4.0.0">http://maven.apache.org/POM/4.0.0</a>&quot;</span>)<br>
                    )<br>                    .perform(Iteration.over(XMLFile.<span class="">class</span>, <span class="">&quot;xmls&quot;</span>, <span class="">&quot;pom&quot;</span>).as(MavenPomFile.<span class="">class</span>)<br>
                                .perform(<br>                                            Graph.replace(Selection.current(XMLFile.<span class="">class</span>))<br>                                                        .with(Selection.current(MavenPomFile.<span class="">class</span>))<br>
                                )<br>                    )</font></blockquote>








<p class=""><font face="courier new, monospace"><br></font></p><p class=""><font face="courier new, monospace">Now co</font>nsider what would happen if we were to parameterize the DOCTYPE statement:</p><p class=""><br></p>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="courier new, monospace">                    .addRule()<br>
</font><font face="courier new, monospace">                    .when(Selection.exists(XMLFile.<span class="">class</span>, <span class="">&quot;xmls&quot;</span>)<br></font><font face="courier new, monospace">                                .<span class="">with(Element.DOCTYPE, &quot;http://{domain}/POM/4.0.0&quot;</span>)<br>
</font><font face="courier new, monospace">                    )</font></blockquote><p class=""><br></p><p class="">What if we want to match some domains and not others? Well, we&#39;ll need to configure the parameter:</p>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="courier new, monospace">                    .addRule()<br>
                    .when(Selection.exists(XMLFile.<span class="">class</span>, <span class="">&quot;xmls&quot;</span>)<br>                                .<span class="">with(Element.DOCTYPE, &quot;http://{domain}/POM/4.0.0&quot;</span>)<br>
                    )<br>                    .where(&quot;domain&quot;).matches(&quot;(<a href="http://maven.apache.org">maven.apache.org</a>|<a href="http://jboss.org/maven|example\\.(com|org|net)">jboss.org/maven|example\\.(com|org|net)</a>)&quot;).convertedBy(new URLDomainConverter()).bindsTo(new GraphBinding(&quot;xml&gt;domain&quot;))</font></blockquote>
<p class=""><font face="courier new, monospace"><br></font></p><p class=""><font face="courier new, monospace">T</font>his would both ensure that the parameter matches only what was contained in the regular expression, but also adds a converter which stores the value in the graph (somehow) as a URLDomain (which just for example&#39;s sake is a @VertexFrame annotated interface.) Keep in mind that this is just a hypothetical example.</p>
<p class="">The full battery of parameter configuration options are:</p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">.where(String param)<br></font><font face="courier new, monospace">.matches(String regex)<br></font><font face="courier new, monospace">.constrainedBy(Constraint constraint)<br></font><font face="courier new, monospace">.convertedBy(Converter converter)<br>
</font><font face="courier new, monospace">.validatedBy(Validator validator)<br></font><font face="courier new, monospace">.bindsTo(Binding binding)<br></font><font face="courier new, monospace">.configuredBy(ParameterConfigurator configurator) // can do any of the above</font></blockquote>
<p class=""><br></p><p class="">~Lincoln</p><p class=""><br></p></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 5, 2014 at 11:05 AM, Jess Sightler <span dir="ltr">&lt;<a href="mailto:jsightle@redhat.com" target="_blank">jsightle@redhat.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Could you explain the &quot;where&quot; clause in more detail here? I have
    seen this a few times in your examples, but I&#39;m not entirely clear
    on what it is doing. :)<div><div class="h5"><br>
    <br>
    <br>
    <div>On 05/05/2014 10:33 AM, Lincoln Baxter,
      III wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div style="font-family:arial,sans-serif;font-size:13px">.addRule() </div>
        <div style="font-family:arial,sans-serif;font-size:13px">.when()
          // if</div>
        <div style="font-family:arial,sans-serif;font-size:13px">
          .perform() // then</div>
        <div style="font-family:arial,sans-serif;font-size:13px">.otherwise()
          // else</div>
        <div style="font-family:arial,sans-serif;font-size:13px">.where(&quot;paramName1&quot;).configuredBy(...).where(&quot;paramName2&quot;)
          // configure parameters</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Mon, May 5, 2014 at 10:23 AM,
          Lincoln Baxter, III <span dir="ltr">&lt;<a href="mailto:lincolnbaxter@gmail.com" target="_blank">lincolnbaxter@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div><span style="font-family:arial,sans-serif;font-size:13px">1)
                  The  (when, perform) structure would be basic for all
                  rules?</span>
                <div>
                  <br>
                </div>
              </div>
              <div>Yes, there are actually a few more structures:</div>
              <div><br>
              </div>
              <div>.addRule() </div>
              <div>.when() // if</div>
              <div>.perform() // then</div>
              <div>.otherwise() // else
                <div><br>
                  <br style="font-family:arial,sans-serif;font-size:13px">
                  <span style="font-family:arial,sans-serif;font-size:13px">2)
                    This seems like it will build object tree, which
                    will then be</span><br style="font-family:arial,sans-serif;font-size:13px">
                  <span style="font-family:arial,sans-serif;font-size:13px">processed,
                    right? No space for custom code?</span><br style="font-family:arial,sans-serif;font-size:13px">
                  <br>
                </div>
                You can already do exactly what you just suggested :)
                Custom code is no problem, it just accepts an object
                like any normal Java code - it&#39;s just Java.
                <div>
                  <br>
                  <br style="font-family:arial,sans-serif;font-size:13px">
                  <span style="font-family:arial,sans-serif;font-size:13px">3)
                    Isn&#39;t that a fluent API overuse? How about something
                    like:</span></div>
              </div>
              <div><font face="arial, sans-serif"><br>
                </font></div>
              <div><font face="arial, sans-serif">I don&#39;t know what you
                  are referring to here as overuse, but yes, I am
                  exaggerating the use of the fluent API to make a
                  point. The rules could be completely un-fluent and
                  still use these same APIs. I&#39;m not sure I see the
                  point/difference of the sample you&#39;ve shown.<br>
                </font>
                <div>
                  <div><span style="font-family:arial,sans-serif;font-size:13px"><br>
                    </span></div>
                  <div><span style="font-family:arial,sans-serif;font-size:13px">4)
                      .withDoctype(&quot;</span><a href="http://maven.apache.org/POM/4.0.0" style="font-family:arial,sans-serif;font-size:13px" target="_blank">http://maven.apache.org/POM/4.0.0</a><span style="font-family:arial,sans-serif;font-size:13px">&quot;) ?</span><br style="font-family:arial,sans-serif;font-size:13px">

                    <span style="font-family:arial,sans-serif;font-size:13px">doctype
                      is a property...  Better .with(PropNames.DOCTYPE,</span><br style="font-family:arial,sans-serif;font-size:13px">
                    <span style="font-family:arial,sans-serif;font-size:13px">&quot;</span><a href="http://maven.apache.org/POM/4.0.0" style="font-family:arial,sans-serif;font-size:13px" target="_blank">http://maven.apache.org/POM/4.0.0</a><span style="font-family:arial,sans-serif;font-size:13px">&quot;) ?</span></div>

                  <div><br>
                  </div>
                </div>
                <div>I agree, some kind of more general structure here
                  would probably be better.
                  <div><br style="font-family:arial,sans-serif;font-size:13px">
                    <br style="font-family:arial,sans-serif;font-size:13px">
                    <span style="font-family:arial,sans-serif;font-size:13px">5)
                      Could the variable be filled outside .when () ?
                      But perhaps just a</span><br style="font-family:arial,sans-serif;font-size:13px">
                    <span style="font-family:arial,sans-serif;font-size:13px">matter
                      of taste.</span><span style="font-family:arial,sans-serif;font-size:13px"><br>
                    </span></div>
                </div>
              </div>
              <div><span style="font-family:arial,sans-serif;font-size:13px"><br>
                </span></div>
              <div><span style="font-family:arial,sans-serif;font-size:13px">Absolutely
                  you could - and yes, it&#39;s all a matter of taste :)</span></div>
            </div>
            <div class="gmail_extra">
              <div>
                <div><br>
                  <br>
                  <div class="gmail_quote">
                    On Fri, May 2, 2014 at 7:26 PM, Ondrej Zizka <span dir="ltr">&lt;<a href="mailto:ozizka@redhat.com" target="_blank">ozizka@redhat.com</a>&gt;</span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
                      <br>
                      WRT rules API, as proposed at<br>
                      <a href="https://github.com/windup/windup/blob/master/engine/config/api/src/main/java/org/jboss/windup/addon/config/example/MavenExampleConfigurationProvider.java#L22" target="_blank">https://github.com/windup/windup/blob/master/engine/config/api/src/main/java/org/jboss/windup/addon/config/example/MavenExampleConfigurationProvider.java#L22</a><br>

                      <br>
                      It&#39;s nice, with some comments.<br>
                      <br>
                      I know it was typed in a hurry, but anyway:<br>
                      <br>
                      1) The  (when, perform) structure would be basic
                      for all rules?<br>
                      <br>
                      2) This seems like it will build object tree,
                      which will then be<br>
                      processed, right? No space for custom code?<br>
                      <br>
                      3) Isn&#39;t that a fluent API overuse? How about
                      something like:<br>
                      <br>
                      new ConfigBuilder( ... ){{<br>
                           addRule( new MavenPomRule( this, ... ){<br>
                                    boolean when(  ) { return
                      Selection.exists(XMLFile.class,<br>
                      &quot;xmls&quot;).with(&quot;doctype&quot;, DOCTYPE_POM); }<br>
                                    void perform( MavenPomInfo mpi ){
                      ... }<br>
                               }<br>
                           );<br>
                      }}.run();<br>
                      <br>
                      It&#39;s verbose now but with Java 8 lambdas, it would
                      be less.<br>
                      <br>
                      While it&#39;s a bit more verbose, it would have
                      obvious benefits of better<br>
                      debuggability, and would better leverage Java&#39;s
                      features like<br>
                      inheritance (imagine AbstractXmlFileRule and it&#39;s
                      subclasses for<br>
                      whatever one would want to do with a XML file,
                      having few of its<br>
                      properties passed as parameters.<br>
                      <br>
                      Btw this code above is inspired by Wicket and GWT.<br>
                      <br>
                      4) .withDoctype(&quot;<a href="http://maven.apache.org/POM/4.0.0" target="_blank">http://maven.apache.org/POM/4.0.0</a>&quot;)
                      ?<br>
                      doctype is a property...  Better
                      .with(PropNames.DOCTYPE,<br>
                      &quot;<a href="http://maven.apache.org/POM/4.0.0" target="_blank">http://maven.apache.org/POM/4.0.0</a>&quot;)
                      ?<br>
                      <br>
                      5) Could the variable be filled outside .when () ?
                      But perhaps just a<br>
                      matter of taste.<br>
                      <br>
                      More later when we have some more examples.<br>
                      <br>
                      Nice!<br>
                      Ondra<br>
                      _______________________________________________<br>
                      windup-dev mailing list<br>
                      <a href="mailto:windup-dev@lists.jboss.org" target="_blank">windup-dev@lists.jboss.org</a><br>
                      <a href="https://lists.jboss.org/mailman/listinfo/windup-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/windup-dev</a><br>
                    </blockquote>
                  </div>
                  <br>
                  <br clear="all">
                  <div><br>
                  </div>
                </div>
              </div>
              <span><font color="#888888">-- <br>
                  Lincoln Baxter, III<br>
                  <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
                  &quot;Simpler is better.&quot;
                </font></span></div>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        Lincoln Baxter, III<br>
        <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
        &quot;Simpler is better.&quot;
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
windup-dev mailing list
<a href="mailto:windup-dev@lists.jboss.org" target="_blank">windup-dev@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/windup-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/windup-dev</a></pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
windup-dev mailing list<br>
<a href="mailto:windup-dev@lists.jboss.org">windup-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/windup-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/windup-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Lincoln Baxter, III<br>
<a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>&quot;Simpler is better.&quot;
</div>