Posts by Hubert Klein Ikkink

Google Guava Goodness: Matching All Elements in a Collection

Posted on by  
Hubert Klein Ikkink

The Google Guava libraries has many useful classes and methods. Normally I write code in Groovy and I am used to working with collections in an intuitive way. But sometimes I need to work with Java on my project and then the Google Guava libraries are a great alternative. Suppose I want to check if all elements in a collection apply to a certain condition. In Groovy I would write this:

final List list = ['Groovy', 'Rocks']

assert list.every { it.contains('o') }

Continue reading →

shadow-left