package simulation; import java.util.Arrays; import java.util.Objects; public enum BuildingState { EMPTY("vide"), ONE_THIRD("un-tiers"), TWO_THIRD("deux-tiers"), FULL("plein"); private final String typeName; BuildingState(String typeName) { this.typeName = typeName; } public static BuildingState getFromTypeName(String typeName) { return Arrays.stream(BuildingState.values()) .filter(t -> Objects.equals(t.typeName, typeName)) .findFirst().orElse(null); } }