import java.util.List; public class Objet { String nom; int taille; Condition visible; List descriptions; public Objet( String nom, int taille, Condition visible, List descriptions) { this.nom = nom; this.taille = taille; this.visible = visible; this.descriptions = descriptions; } @Override public String toString() { for (Description d : this.descriptions) { if (d.condition.evaluer()) { return this.nom + " (" + d + ")"; } } return "(no description)"; } public static Objet search(List list, String name) { return list.stream().filter(o -> o.nom.equals(name)).findFirst() .orElseThrow(() -> new IllegalArgumentException("No data found")); } }