public class RecetteController {
public Recette getRecette(String idRecette, OptionsRecette options) {
Recette fetched = RecetteUtils.fetchRecetteById(idRecette);
return new Recette(
fetched.getId(),
fetched.getTitre(),
fetched.getIngredients().stream().map(ingredient -> new Ingredient(
ingredient.getNom(),
ingredient.getQuantite() * options.getNbPersonnes(),
ingredient.getUnite()
))
.collect(Collectors.toList()),
fetched.getEtapes().stream().map(etape -> new Etape(
etape.getDescription(),
etape.getDuree() * (options.getNbPersonnes() / 2.0),
etape.getUnite()
))
.collect(Collectors.toList())
);
}
}