From 6aeda395c32260397fae5cc9d03f97287b6b02d2 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Sun, 11 Dec 2022 14:58:15 +0100 Subject: [PATCH] Javadocs and code cleanup --- .../ch/zhaw/gartenverwaltung/Settings.java | 66 +++++++++++++++---- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/Settings.java b/src/main/java/ch/zhaw/gartenverwaltung/Settings.java index 8433dce..491db5d 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/Settings.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/Settings.java @@ -6,21 +6,58 @@ import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import java.util.List; +import java.util.Objects; +/** + * Singleton Class to store default Settings and User Settings + */ public class Settings { - private static final Settings instance; - private HardinessZone currentHardinessZone = HardinessZone.ZONE_8A; - private final BooleanProperty showTutorial = new SimpleBooleanProperty(false); - private SmtpCredentials smtpCredentials = new SmtpCredentials("imap.gmail.com", "587", "pm3.hs22.it21b.win.team1@gmail.com", "pm3.hs22.it21b.win.team1@gmail.com", "bisefhhjtrrhtoqr", true); - // Gmail Address: pm3.hs22.it21b.win.team1@gmail.com - // Gmail Passwort: Gartenverwaltung.PM3.2022 - // E-Mail Inbox: https://www.mailinator.com/v4/public/inboxes.jsp?to=pm3.hs22.it21b.win.team1 - private String mailNotificationReceivers = "pm3.hs22.it21b.win.team1@mailinator.com"; - private String mailNotificationSubjectTemplate = "Task %s is due!"; // {0} = Task Name - private String mailNotificationTextTemplate = "Dear user\nYour gardentask %s for plant %s is due at %tF. Don't forget to confirm in your application if the task is done.\nTask description:\n%s"; // {0} = Task Name, {1} = plantname, {2} = nextExecution, {3} = Task description + /* + * The Class instance to use everywhere + */ + private static final Settings instance; + /** + * The current Hardiness zone initialized as default value Zone_8A + */ + private HardinessZone currentHardinessZone = HardinessZone.ZONE_8A; + /** + * Setting to show or hide the Tutorial in Main Menu + */ + private final BooleanProperty showTutorial = new SimpleBooleanProperty(false); + /** + * The SMTP Credentials which are used to send E-Mail Notifications + * The following Google Account is created for Testing: + * E-Mail Address: pm3.hs22.it21b.win.team1@gmail.com + * Account Password: Gartenverwaltung.PM3.2022 + * SMTP Password: bisefhhjtrrhtoqr + */ + private SmtpCredentials smtpCredentials = new SmtpCredentials("imap.gmail.com", "587", "pm3.hs22.it21b.win.team1@gmail.com", "pm3.hs22.it21b.win.team1@gmail.com", "bisefhhjtrrhtoqr", true); + /** + * List of Receivers for E-Mailnotifications. Multiple E-Mailadresses can be separated by ";" + * Following Public E-mail address was used for Testing: pm3.hs22.it21b.win.team1@mailinator.com + * The E-Mail inbox of this address can be found here: https://www.mailinator.com/v4/public/inboxes.jsp?to=pm3.hs22.it21b.win.team1 + */ + private String mailNotificationReceivers = "pm3.hs22.it21b.win.team1@mailinator.com"; + /** + * String Template to create E-Mail Subject for Notifications + * Variables: Task Name + */ + private String mailNotificationSubjectTemplate = "Task %s is due!"; + /** + * String Template to create E-Mail Text for Notifications + * Variables: Task Name, plant Name, nextExecution, Task description + */ + private String mailNotificationTextTemplate = "Dear user\nYour gardentask %s for plant %s is due at %tF. Don't forget to confirm in your application if the task is done.\nTask description:\n%s"; + + /** + * Location of the garden can be set by user (Used for Weather Service) + */ private String location = ""; + /* + Create Instance of Settings + */ static { instance = new Settings(); } @@ -29,14 +66,21 @@ public class Settings { return Settings.instance; } + /** + * Private constructor to prevent Classes from creating more instances + */ private Settings() {} public HardinessZone getCurrentHardinessZone() { return currentHardinessZone; } + /** + * Method to set the current Hardiness Zone. If no Hardiness Zone is given the default zone (ZONE_8A) will be used. + * @param currentHardinessZone the new Hardiness Zone + */ public void setCurrentHardinessZone(HardinessZone currentHardinessZone) { - this.currentHardinessZone = currentHardinessZone; + this.currentHardinessZone = Objects.requireNonNullElse(currentHardinessZone, HardinessZone.ZONE_8A); } public void setShowTutorial (boolean showTutorial) {