This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-website.git
The following commit(s) were added to refs/heads/asf-site by this push:
new f7af81b minor refactor
f7af81b is described below
commit f7af81b4a8facc53b59f11e78abed752a45c78ca
Author: Paul King <[email protected]>
AuthorDate: Mon Dec 8 14:01:12 2025 +1000
minor refactor
---
site/src/site/blog/fruity-eclipse-grouping.adoc | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/site/src/site/blog/fruity-eclipse-grouping.adoc
b/site/src/site/blog/fruity-eclipse-grouping.adoc
index e1c9a79..cf0ca67 100644
--- a/site/src/site/blog/fruity-eclipse-grouping.adoc
+++ b/site/src/site/blog/fruity-eclipse-grouping.adoc
@@ -269,19 +269,19 @@ Which has this output:
----
Speaking of fruit, we should consider this last example
-also using Guava (Google's collection library):
+also using Guava (Google's collection library). For
+Guava, the `ImmutableMultimap` class has an `inverse` method:
[source,groovy]
----
-def fruitColors = HashMultimap.create()
-fruitColors.putAll('red', ['🍒', '🍎'])
-fruitColors.putAll('green', ['🍎', '🍌', '🥑'])
-fruitColors.put('yellow', '🍌')
-println fruitColors
+def fruitColors = new ImmutableMultimap.Builder<String, String>()
+ .putAll("red", ["🍒", "🍎"])
+ .putAll("green", ["🍎", "🍌", "🥑"])
+ .put("yellow", "🍌")
+ .build()
-def flipped = HashMultimap.create()
-Multimaps.invertFrom(fruitColors, flipped)
-println flipped
+println fruitColors
+println fruitColors.inverse()
----
Which has almost identical output:
@@ -291,6 +291,10 @@ Which has almost identical output:
{🥑=[green], 🍎=[red, green], 🍌=[yellow, green], 🍒=[red]}
----
+The `inverse` method is available on `ImmutableListMultimap` and
`ImmutableSetMultimap` instances;
+for other cases, there is an `invertFrom` utility method
+in the `Multimaps` class.
+
== Further information
* Repo with example code:
https://github.com/paulk-asert/fruity-eclipse-collections