<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Making Java &#8220;Groovier&#8221; with LambdaJ</title>
	<atom:link href="http://mattstine.com/2009/10/09/making-java-groovier-with-lambdaj/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattstine.com/2009/10/09/making-java-groovier-with-lambdaj/</link>
	<description>Thoughts on Java, Groovy, Grails, Agile Development, etc. etc. etc.</description>
	<lastBuildDate>Tue, 17 May 2011 16:24:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Steve</title>
		<link>http://mattstine.com/2009/10/09/making-java-groovier-with-lambdaj/#comment-90</link>
		<dc:creator><![CDATA[Steve]]></dc:creator>
		<pubDate>Mon, 12 Oct 2009 17:25:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattstine.com/?p=257#comment-90</guid>
		<description><![CDATA[I thought this trick would be needed:

Collections.emptyList() can not be used in the ternary as I have it without casting the return result so create a private function that returns Collection.emptyList() to replace the inline call.]]></description>
		<content:encoded><![CDATA[<p>I thought this trick would be needed:</p>
<p>Collections.emptyList() can not be used in the ternary as I have it without casting the return result so create a private function that returns Collection.emptyList() to replace the inline call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sakuraba</title>
		<link>http://mattstine.com/2009/10/09/making-java-groovier-with-lambdaj/#comment-89</link>
		<dc:creator><![CDATA[Sakuraba]]></dc:creator>
		<pubDate>Mon, 12 Oct 2009 07:00:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattstine.com/?p=257#comment-89</guid>
		<description><![CDATA[While I like Closures and they way groovy decorates existing JDK classes with them, I think that most of the &quot;hard-to-read&quot;-ness in the original code stems rather from too long class/variable names and crappy formatting than from the absence of Closures.]]></description>
		<content:encoded><![CDATA[<p>While I like Closures and they way groovy decorates existing JDK classes with them, I think that most of the &#8220;hard-to-read&#8221;-ness in the original code stems rather from too long class/variable names and crappy formatting than from the absence of Closures.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://mattstine.com/2009/10/09/making-java-groovier-with-lambdaj/#comment-88</link>
		<dc:creator><![CDATA[Steve]]></dc:creator>
		<pubDate>Mon, 12 Oct 2009 05:07:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattstine.com/?p=257#comment-88</guid>
		<description><![CDATA[Matt,

  I think you can do what you want with just the core Java classes. First, I would make it an error for businessActivityBinMetaClassList to ever be null.  You could use Collections.emptyList() instead.

You would create a utility class:

class FunctionalMap&lt;I&gt; {
  Converter &lt;I&gt; func;
  FunctionalMap(Converter&lt;I&gt; c) { func = c;}

List map(List&lt;I&gt; src) {
  List val = (src.isEmpty()) ? Collections.emptyList() : new ArrayList();
  for (I i : src) {
    val.add(convert(i));
  }
  return val;
}
}
and use it like this:

FunctionalMap inToOut = new FunctionalMap(myConverter);

List myOutList = inToOut.map(myData);

Sorry about the formatting.  With this approach I think you could even make an implementation using SynchronousQueue instead of a List for continuous conversion using multithreading.

There would be no need for the static method or helper class, just define inToOut where it is needed and call map.

Another approach might be to make FunctionalUtil and have a static map method that takes the converter.

Thoughts?

Steve]]></description>
		<content:encoded><![CDATA[<p>Matt,</p>
<p>  I think you can do what you want with just the core Java classes. First, I would make it an error for businessActivityBinMetaClassList to ever be null.  You could use Collections.emptyList() instead.</p>
<p>You would create a utility class:</p>
<p>class FunctionalMap<i> {<br />
  Converter </i><i> func;<br />
  FunctionalMap(Converter</i><i> c) { func = c;}</p>
<p>List map(List</i><i> src) {<br />
  List val = (src.isEmpty()) ? Collections.emptyList() : new ArrayList();<br />
  for (I i : src) {<br />
    val.add(convert(i));<br />
  }<br />
  return val;<br />
}<br />
}<br />
and use it like this:</p>
<p>FunctionalMap inToOut = new FunctionalMap(myConverter);</p>
<p>List myOutList = inToOut.map(myData);</p>
<p>Sorry about the formatting.  With this approach I think you could even make an implementation using SynchronousQueue instead of a List for continuous conversion using multithreading.</p>
<p>There would be no need for the static method or helper class, just define inToOut where it is needed and call map.</p>
<p>Another approach might be to make FunctionalUtil and have a static map method that takes the converter.</p>
<p>Thoughts?</p>
<p>Steve</i></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Fusco</title>
		<link>http://mattstine.com/2009/10/09/making-java-groovier-with-lambdaj/#comment-87</link>
		<dc:creator><![CDATA[Mario Fusco]]></dc:creator>
		<pubDate>Sun, 11 Oct 2009 21:07:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattstine.com/?p=257#comment-87</guid>
		<description><![CDATA[Hi Matt,

sorry but I never tried to use lambdaj from a Groovy test class, so at the moment I don&#039;t have a clear idea of what is going wrong. It seems that for some reason Groovy doesn&#039;t work well with the cglib proxies generated by lambdaj and if this is the problem I am afraid there is no solution for it.

However could you send to my email the code you are using, so I can reproduce this issue by myself?

Just for curiosity did you try my solution from a plain Java test class? Does it work in that case?

Bye
Mario]]></description>
		<content:encoded><![CDATA[<p>Hi Matt,</p>
<p>sorry but I never tried to use lambdaj from a Groovy test class, so at the moment I don&#8217;t have a clear idea of what is going wrong. It seems that for some reason Groovy doesn&#8217;t work well with the cglib proxies generated by lambdaj and if this is the problem I am afraid there is no solution for it.</p>
<p>However could you send to my email the code you are using, so I can reproduce this issue by myself?</p>
<p>Just for curiosity did you try my solution from a plain Java test class? Does it work in that case?</p>
<p>Bye<br />
Mario</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://mattstine.com/2009/10/09/making-java-groovier-with-lambdaj/#comment-86</link>
		<dc:creator><![CDATA[Matt]]></dc:creator>
		<pubDate>Sun, 11 Oct 2009 19:46:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattstine.com/?p=257#comment-86</guid>
		<description><![CDATA[Mario,

Thanks for your response! This looks great. However, I&#039;m having some problems getting it to run from my Groovy test class....here&#039;s the result:

Caught: groovy.lang.MissingMethodException: No signature of method: $java.lang.Iterable$$EnhancerByCGLIB$$d94f4d3d.getSrmMetaClassId() is applicable for argument types: () values: []
	at CollectExamples.getSrmMetaClassIdListLambdaJTwo(Collect.groovy:36)
	at Collect.run(Collect.groovy:87)

Not sure what I&#039;m doing wrong...any ideas?

Thanks,

Matt]]></description>
		<content:encoded><![CDATA[<p>Mario,</p>
<p>Thanks for your response! This looks great. However, I&#8217;m having some problems getting it to run from my Groovy test class&#8230;.here&#8217;s the result:</p>
<p>Caught: groovy.lang.MissingMethodException: No signature of method: $java.lang.Iterable$$EnhancerByCGLIB$$d94f4d3d.getSrmMetaClassId() is applicable for argument types: () values: []<br />
	at CollectExamples.getSrmMetaClassIdListLambdaJTwo(Collect.groovy:36)<br />
	at Collect.run(Collect.groovy:87)</p>
<p>Not sure what I&#8217;m doing wrong&#8230;any ideas?</p>
<p>Thanks,</p>
<p>Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Fusco</title>
		<link>http://mattstine.com/2009/10/09/making-java-groovier-with-lambdaj/#comment-85</link>
		<dc:creator><![CDATA[Mario Fusco]]></dc:creator>
		<pubDate>Sat, 10 Oct 2009 13:45:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattstine.com/?p=257#comment-85</guid>
		<description><![CDATA[Hi Matt,

My name is Mario Fusco and I am the main developer of the lambdaj project. Thanks a lot for your interest in my project. Actually your example could be a lot improved as it follows:

public static List getSrmMetaClassIdListJava(List businessActivityBinMetaClassList) {
.      return (businessActivityBinMetaClassList != null) ?
			filter(notNullValue(), extract(businessActivityBinMetaClassList, on(BusinessActivityBinMetaClass.class).getSrmMetaClass().getSrmMetaClassId())) :
			new ArrayList();
}

So you can achieve what you need with just one line of code and without having any inner class. Indeed lambdaj does all the null checks for you. Almost better than Groovy, isn&#039;t it :)
Let me know if it works.

Cheers
Mario]]></description>
		<content:encoded><![CDATA[<p>Hi Matt,</p>
<p>My name is Mario Fusco and I am the main developer of the lambdaj project. Thanks a lot for your interest in my project. Actually your example could be a lot improved as it follows:</p>
<p>public static List getSrmMetaClassIdListJava(List businessActivityBinMetaClassList) {<br />
.      return (businessActivityBinMetaClassList != null) ?<br />
			filter(notNullValue(), extract(businessActivityBinMetaClassList, on(BusinessActivityBinMetaClass.class).getSrmMetaClass().getSrmMetaClassId())) :<br />
			new ArrayList();<br />
}</p>
<p>So you can achieve what you need with just one line of code and without having any inner class. Indeed lambdaj does all the null checks for you. Almost better than Groovy, isn&#8217;t it <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Let me know if it works.</p>
<p>Cheers<br />
Mario</p>
]]></content:encoded>
	</item>
</channel>
</rss>

