2021-12-09 17:54:08 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class Connaissance {
|
|
|
|
String nom;
|
|
|
|
Condition visible;
|
|
|
|
List<Description> descriptions;
|
|
|
|
|
|
|
|
public Connaissance(
|
|
|
|
String nom,
|
|
|
|
Condition visible,
|
|
|
|
List<Description> descriptions) {
|
|
|
|
this.nom = nom;
|
|
|
|
this.visible = visible;
|
|
|
|
this.descriptions = descriptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
for (Description d : this.descriptions) {
|
|
|
|
if (d.condition.evaluer()) {
|
2022-01-18 18:49:37 +00:00
|
|
|
return this.nom + " (" + d + ")";
|
2021-12-09 17:54:08 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-18 18:49:37 +00:00
|
|
|
return "(no description)";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Connaissance search(List<Connaissance> list, String name) {
|
|
|
|
return list.stream().filter(o -> o.nom.equals(name)).findFirst()
|
|
|
|
.orElseThrow(() -> new IllegalArgumentException("No data found"));
|
2021-12-09 17:54:08 +00:00
|
|
|
}
|
|
|
|
}
|