diff --git a/src/main/java/ch/zhaw/gartenverwaltung/io/JsonPlantDatabase.java b/src/main/java/ch/zhaw/gartenverwaltung/io/JsonPlantDatabase.java index 4ae2435..5591acd 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/io/JsonPlantDatabase.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/io/JsonPlantDatabase.java @@ -46,9 +46,6 @@ public class JsonPlantDatabase implements PlantDatabase { */ @Override public List getPlantList(HardinessZone zone) throws IOException, HardinessZoneNotSetException { - if (zone == null) { - throw new HardinessZoneNotSetException(); - } if (plantMap.isEmpty() || zone != currentZone) { loadPlantList(zone); } @@ -60,9 +57,6 @@ public class JsonPlantDatabase implements PlantDatabase { */ @Override public Optional getPlantById(long id) throws HardinessZoneNotSetException, IOException { - if (currentZone == null) { - throw new HardinessZoneNotSetException(); - } if (plantMap.isEmpty()) { loadPlantList(currentZone); } @@ -75,7 +69,10 @@ public class JsonPlantDatabase implements PlantDatabase { * @param zone The {@link HardinessZone} for which data is to be loaded * @throws IOException If the database cannot be accessed */ - private void loadPlantList(HardinessZone zone) throws IOException { + private void loadPlantList(HardinessZone zone) throws IOException, HardinessZoneNotSetException { + if (zone == null) { + throw new HardinessZoneNotSetException(); + } if (dataSource != null) { currentZone = zone; ObjectMapper mapper = new ObjectMapper();