<div dir="ltr"><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>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<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>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's just Java.<br>
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">3) Isn't that a fluent API overuse? How about something like:</span></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif">I don'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'm not sure I see the point/difference of the sample you've shown.<br>
</font><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("</span><a href="http://maven.apache.org/POM/4.0.0" target="_blank" style="font-family:arial,sans-serif;font-size:13px">http://maven.apache.org/POM/4.0.0</a><span style="font-family:arial,sans-serif;font-size:13px">") ?</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">"</span><a href="http://maven.apache.org/POM/4.0.0" target="_blank" style="font-family:arial,sans-serif;font-size:13px">http://maven.apache.org/POM/4.0.0</a><span style="font-family:arial,sans-serif;font-size:13px">") ?</span></div>
<div><br></div><div>I agree, some kind of more general structure here would probably be better.<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><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's all a matter of taste :)</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 2, 2014 at 7:26 PM, Ondrej Zizka <span dir="ltr"><<a href="mailto:ozizka@redhat.com" target="_blank">ozizka@redhat.com</a>></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'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'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>
"xmls").with("doctype", DOCTYPE_POM); }<br>
void perform( MavenPomInfo mpi ){ ... }<br>
}<br>
);<br>
}}.run();<br>
<br>
It's verbose now but with Java 8 lambdas, it would be less.<br>
<br>
While it's a bit more verbose, it would have obvious benefits of better<br>
debuggability, and would better leverage Java's features like<br>
inheritance (imagine AbstractXmlFileRule and it'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("<a href="http://maven.apache.org/POM/4.0.0" target="_blank">http://maven.apache.org/POM/4.0.0</a>") ?<br>
doctype is a property... Better .with(PropNames.DOCTYPE,<br>
"<a href="http://maven.apache.org/POM/4.0.0" target="_blank">http://maven.apache.org/POM/4.0.0</a>") ?<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">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>"Simpler is better."
</div>