for(Continent continent : continentList)
{
for(Country country : continent.getCountries())
{
for(City city : country.getCities())
{
//Do stuff with city objects
}
}
}
上記のようなネストしたループでLists.transformを使いたい場合は、
FluentIterable.from(continentList)
.transformAndConcat(Continent.getCountriesFunction())
.transformAndConcat(Country.getCitiesFunction())
. //filter //tranform //find //toList() //etc.
のようにtransformAndConcat()
を使えば出来なくもないが、メンテしづらくなるためお勧め出来ないとのこと。
java - Guava iterators, and iterating over a list within a list object - Stack Overflow