<?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/"
		>
<channel>
	<title>Comments on: Functional Java, Filtering and Ordering with Google Collections (part 3)</title>
	<atom:link href="http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/</link>
	<description>Satisfy your cravings</description>
	<lastBuildDate>Tue, 20 Dec 2011 11:07:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Martin Harris</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-274</link>
		<dc:creator>Martin Harris</dc:creator>
		<pubDate>Thu, 11 Feb 2010 11:01:55 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-274</guid>
		<description>Love your posts, and the photography.  I have been posting similar stuff on my blog, but more problem / solution focused, and to be honest have not done as good a job as you due to time constraints.

Have you looked at the Spring 3 release and SPeL?  You can solve similar problems with that.  It overlaps, and covers different areas.  In fact if you look at what you can do with SPeL, Hamcrest and Guava the combined extra power is fantastic.

With SPeL you miss out on this ability to form an iterable backed by the original collection, but in some cases it can still be of use.  I think your example from above would look a bit like this.  Excuse any mistakes I am free coding this!

Iterable filtered = filter(names, or(or(equalTo(&quot;Aleksander&quot;),equalTo(&quot;Jaran&quot;)), lengthLessThan(5)));

List filtered = (List) parser.parseExpression(&quot;#names.?[(Name == &#039;Aleksander&#039; &#124;&#124; Name == &#039;Jaran&#039;) &amp;&amp; Name &lt; 5 ]&quot;).getValue(names);

Not as pretty by any means, but interesting all the same.

See for detail:
http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch07s02.html</description>
		<content:encoded><![CDATA[<p>Love your posts, and the photography.  I have been posting similar stuff on my blog, but more problem / solution focused, and to be honest have not done as good a job as you due to time constraints.</p>
<p>Have you looked at the Spring 3 release and SPeL?  You can solve similar problems with that.  It overlaps, and covers different areas.  In fact if you look at what you can do with SPeL, Hamcrest and Guava the combined extra power is fantastic.</p>
<p>With SPeL you miss out on this ability to form an iterable backed by the original collection, but in some cases it can still be of use.  I think your example from above would look a bit like this.  Excuse any mistakes I am free coding this!</p>
<p>Iterable filtered = filter(names, or(or(equalTo(&#8220;Aleksander&#8221;),equalTo(&#8220;Jaran&#8221;)), lengthLessThan(5)));</p>
<p>List filtered = (List) parser.parseExpression(&#8220;#names.?[(Name == 'Aleksander' || Name == 'Jaran') &amp;&amp; Name &lt; 5 ]&quot;).getValue(names);</p>
<p>Not as pretty by any means, but interesting all the same.</p>
<p>See for detail:<br />
<a href="http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch07s02.html" rel="nofollow">http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch07s02.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Computing Map on Google Collections &#124; satukubik</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-104</link>
		<dc:creator>Computing Map on Google Collections &#124; satukubik</dc:creator>
		<pubDate>Fri, 13 Nov 2009 13:42:59 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-104</guid>
		<description>[...] Functional Java Filtering and Ordering with Google Collections [...]</description>
		<content:encoded><![CDATA[<p>[...] Functional Java Filtering and Ordering with Google Collections [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sboulay</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-71</link>
		<dc:creator>sboulay</dc:creator>
		<pubDate>Tue, 03 Nov 2009 13:59:56 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-71</guid>
		<description>here is an example that just got posted that uses google collections and tries to get around exactly what I pointed out. Notice that the person is trying to create property so you don&#039;t have to use strings. Similarly, JPA 2.0 uses a meta model to get around this. 

http://blog.javabien.net/2009/11/02/google-collections-and-enhanced-javabeans/</description>
		<content:encoded><![CDATA[<p>here is an example that just got posted that uses google collections and tries to get around exactly what I pointed out. Notice that the person is trying to create property so you don&#8217;t have to use strings. Similarly, JPA 2.0 uses a meta model to get around this. </p>
<p><a href="http://blog.javabien.net/2009/11/02/google-collections-and-enhanced-javabeans/" rel="nofollow">http://blog.javabien.net/2009/11/02/google-collections-and-enhanced-javabeans/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sboulay</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-70</link>
		<dc:creator>sboulay</dc:creator>
		<pubDate>Tue, 03 Nov 2009 13:42:27 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-70</guid>
		<description>I guess it&#039;s a matter of taste. If you use closures alot it seems much more natural to do it the way that it is done in c#. The Scala example is pretty close. In fact, almost all programming languages do it this way (groovy, ruby, scala, fan, c#), java is really the odd one out here. I personally don&#039;t like &#039;with(&quot;firstname&quot;,&quot;aleksander&quot;)&#039; . Using strings by passes the benefits you get from the complier i.e making a spelling mistake.</description>
		<content:encoded><![CDATA[<p>I guess it&#8217;s a matter of taste. If you use closures alot it seems much more natural to do it the way that it is done in c#. The Scala example is pretty close. In fact, almost all programming languages do it this way (groovy, ruby, scala, fan, c#), java is really the odd one out here. I personally don&#8217;t like &#8216;with(&#8220;firstname&#8221;,&#8221;aleksander&#8221;)&#8217; . Using strings by passes the benefits you get from the complier i.e making a spelling mistake.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sakuraba</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-69</link>
		<dc:creator>Sakuraba</dc:creator>
		<pubDate>Tue, 03 Nov 2009 13:37:07 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-69</guid>
		<description>Thanks for your answer, cant wait for your next blog post!


Does this mean one no longer needs LambdaJ when working with Google Collections?</description>
		<content:encoded><![CDATA[<p>Thanks for your answer, cant wait for your next blog post!</p>
<p>Does this mean one no longer needs LambdaJ when working with Google Collections?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aleksander Stensby</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-67</link>
		<dc:creator>Aleksander Stensby</dc:creator>
		<pubDate>Tue, 03 Nov 2009 10:35:07 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-67</guid>
		<description>@sboulay: I have to say that I agree with YeFFreY. That line of C# code is hardly what you can call readable.

Now, what if I tell you all that with a little bit of functional magic we can write the following fully valid line of java code:
&lt;code&gt;
Iterable&lt;Person&gt; filteredList = filter(persons, with(&quot;firstName&quot;, &quot;aleksander&quot;));
&lt;/code&gt;
We can even write the following:
&lt;code&gt;
List&lt;Person&gt; list = orderBy(&quot;lastName&quot;).sortedCopy(filter(persons, with(&quot;firstName&quot;, &quot;aleksander&quot;)));
&lt;/code&gt;

Now that&#039;s pretty cool - given the fact that it&#039;s plain old Java...</description>
		<content:encoded><![CDATA[<p>@sboulay: I have to say that I agree with YeFFreY. That line of C# code is hardly what you can call readable.</p>
<p>Now, what if I tell you all that with a little bit of functional magic we can write the following fully valid line of java code:<br />
<code><br />
Iterable
<person> filteredList = filter(persons, with("firstName", "aleksander"));
</person></code><br />
We can even write the following:<br />
<code><br />
List
<person> list = orderBy("lastName").sortedCopy(filter(persons, with("firstName", "aleksander")));
</person></code></p>
<p>Now that&#8217;s pretty cool &#8211; given the fact that it&#8217;s plain old Java&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aleksander Stensby</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-66</link>
		<dc:creator>Aleksander Stensby</dc:creator>
		<pubDate>Tue, 03 Nov 2009 10:19:05 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-66</guid>
		<description>Hi Sakuraba! Yes there is actually! By combining Functions and the Multimap collection in Google Collections we can do just that! The next and final part of this blog series will cover just that! So stay tuned :)</description>
		<content:encoded><![CDATA[<p>Hi Sakuraba! Yes there is actually! By combining Functions and the Multimap collection in Google Collections we can do just that! The next and final part of this blog series will cover just that! So stay tuned <img src='http://codemunchies.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sakuraba</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-65</link>
		<dc:creator>Sakuraba</dc:creator>
		<pubDate>Tue, 03 Nov 2009 09:15:45 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-65</guid>
		<description>Is there an equivalent to the &quot;groupBy&quot; closure from Groovy?

def listOfPersons = [[ name: &#039;Clark&#039;, city: &#039;London&#039; ], [ name: &#039;Sharma&#039;, city: &#039;London&#039; ], ...]
def groupedPersons = listOfPersons.groupBy{ it.city }
println groupedPersons
-&gt;
[London:[[name:Clark, city:London], [name:Sharma, city:London]], SomeOtherTown: [.......]]


I really miss that feature in Java. Being able to transform a list of objects into a map by supplying a &quot;grouping&quot; function.</description>
		<content:encoded><![CDATA[<p>Is there an equivalent to the &#8220;groupBy&#8221; closure from Groovy?</p>
<p>def listOfPersons = [[ name: 'Clark', city: 'London' ], [ name: 'Sharma', city: 'London' ], &#8230;]<br />
def groupedPersons = listOfPersons.groupBy{ it.city }<br />
println groupedPersons<br />
-&gt;<br />
[London:[[name:Clark, city:London], [name:Sharma, city:London]], SomeOtherTown: [.......]]</p>
<p>I really miss that feature in Java. Being able to transform a list of objects into a map by supplying a &#8220;grouping&#8221; function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: YeFFreY</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-64</link>
		<dc:creator>YeFFreY</dc:creator>
		<pubDate>Tue, 03 Nov 2009 08:57:15 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-64</guid>
		<description>And you find the c# line readable ??</description>
		<content:encoded><![CDATA[<p>And you find the c# line readable ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sboulay</title>
		<link>http://codemunchies.com/2009/11/functional-java-filtering-and-ordering-with-google-collections-part-3/comment-page-1/#comment-61</link>
		<dc:creator>sboulay</dc:creator>
		<pubDate>Mon, 02 Nov 2009 21:48:52 +0000</pubDate>
		<guid isPermaLink="false">http://codemunchies.com/?p=245#comment-61</guid>
		<description>Even with Google collections it&#039;s pretty bad and unreadable compared to say c#.

IList sortedPeople = people.Where(p =&gt; p.FirstName.Equals(&quot;Steve&quot;)).OrderBy(p =&gt; p.LastName).ToList();</description>
		<content:encoded><![CDATA[<p>Even with Google collections it&#8217;s pretty bad and unreadable compared to say c#.</p>
<p>IList sortedPeople = people.Where(p =&gt; p.FirstName.Equals(&#8220;Steve&#8221;)).OrderBy(p =&gt; p.LastName).ToList();</p>
]]></content:encoded>
	</item>
</channel>
</rss>

