From bd53d0644a50730ad9ad2ecb173ed88e06df4600 Mon Sep 17 00:00:00 2001 From: David Guler Date: Fri, 14 Oct 2022 15:16:27 +0200 Subject: [PATCH] feat: PlantDB types and interfaces Created the types and interfaces relating to the PlantDatabase --- .../ch/zhaw/gartenverwaltung/io/PlantDatabase.java | 12 ++++++++++++ .../ch/zhaw/gartenverwaltung/types/GrowthPhase.java | 9 +++++++++ .../zhaw/gartenverwaltung/types/GrowthPhaseType.java | 5 +++++ .../zhaw/gartenverwaltung/types/HardinessZone.java | 9 +++++++++ .../java/ch/zhaw/gartenverwaltung/types/Plant.java | 11 +++++++++++ 5 files changed, 46 insertions(+) create mode 100644 src/main/java/ch/zhaw/gartenverwaltung/io/PlantDatabase.java create mode 100644 src/main/java/ch/zhaw/gartenverwaltung/types/GrowthPhase.java create mode 100644 src/main/java/ch/zhaw/gartenverwaltung/types/GrowthPhaseType.java create mode 100644 src/main/java/ch/zhaw/gartenverwaltung/types/HardinessZone.java create mode 100644 src/main/java/ch/zhaw/gartenverwaltung/types/Plant.java diff --git a/src/main/java/ch/zhaw/gartenverwaltung/io/PlantDatabase.java b/src/main/java/ch/zhaw/gartenverwaltung/io/PlantDatabase.java new file mode 100644 index 0000000..f0d9bf9 --- /dev/null +++ b/src/main/java/ch/zhaw/gartenverwaltung/io/PlantDatabase.java @@ -0,0 +1,12 @@ +package ch.zhaw.gartenverwaltung.io; + +import ch.zhaw.gartenverwaltung.types.Plant; +import ch.zhaw.gartenverwaltung.types.HardinessZone; + +import java.util.List; +import java.util.Optional; + +public interface PlantDatabase { + List getPlantList(HardinessZone zone); + Optional getPlantById(long id); +} diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/GrowthPhase.java b/src/main/java/ch/zhaw/gartenverwaltung/types/GrowthPhase.java new file mode 100644 index 0000000..665b895 --- /dev/null +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/GrowthPhase.java @@ -0,0 +1,9 @@ +package ch.zhaw.gartenverwaltung.types; + +import java.util.Date; + +public record GrowthPhase(Date startDate, + Date endDate, + GrowthPhaseType type, + HardinessZone zone) { +} diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/GrowthPhaseType.java b/src/main/java/ch/zhaw/gartenverwaltung/types/GrowthPhaseType.java new file mode 100644 index 0000000..99e5d2b --- /dev/null +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/GrowthPhaseType.java @@ -0,0 +1,5 @@ +package ch.zhaw.gartenverwaltung.types; + +public enum GrowthPhaseType { + SOW, PLANT, HARVEST +} diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/HardinessZone.java b/src/main/java/ch/zhaw/gartenverwaltung/types/HardinessZone.java new file mode 100644 index 0000000..5d0bc91 --- /dev/null +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/HardinessZone.java @@ -0,0 +1,9 @@ +package ch.zhaw.gartenverwaltung.types; + +/** + * Represents the available hardiness zones + * (Subject to later expansion) + */ +public enum HardinessZone { + ZONE_8A +} diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/Plant.java b/src/main/java/ch/zhaw/gartenverwaltung/types/Plant.java new file mode 100644 index 0000000..99336e7 --- /dev/null +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/Plant.java @@ -0,0 +1,11 @@ +package ch.zhaw.gartenverwaltung.types; + +import java.util.List; + +public record Plant( + long id, + String name, + String description, + int spacing, + List lifecycle) { +}