I have the following model:
1 RepositoryDTO can have many ResourceDTOs, and in each ResourceDTO is exacly one TeamDTO.
So to get the TeamDTOs from the RepositoryDTO, I am doing the following:
RepositoryDTO repoDTO = ...
List<TeamDTO> teamsLinkedToRepo = getTeamsLinkedTo(repoDTO);
private List<TeamDTO> getTeamsLinkedTo(final RepositoryDTO repository) {
final List<TeamDTO> teamsLinkedToRepository = new ArrayList<TeamDTO>();
for (final ResourceDTO resourceDTO : repository.getResources()) {
teamsLinkedToRepository.add(resourceDTO.getTeam());
}
return teamsLinkedToRepository;
}
I'm just wondering is there a better idiom for doing this, maybe using Google Guava?
Keep simple things simple.
We used Google Guava excessively in one of our projects. And while it was less code and faster to read, it became a nightmare when debugging. So I advice to not use it until you get an huge advantage from it (and simple for-loops won't get any better with it).
With pure Java it's good code. There is no need to improve it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With