diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/Main.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/Main.java index d265ebe..b30c2e3 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/Main.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/Main.java @@ -1,7 +1,7 @@ package ntnu.sytemutvikling.team6; public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Donation.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Donation.java index c72fbee..1fdaa6f 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Donation.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Donation.java @@ -1,81 +1,74 @@ package ntnu.sytemutvikling.team6.models; -import ntnu.sytemutvikling.team6.models.user.User; - import java.time.LocalDateTime; import java.util.UUID; +import ntnu.sytemutvikling.team6.models.user.User; public class Donation { - /* UUID for uniquely identifying each donation */ - private UUID charityId; - - /* Ammount of money donated */ - private double amount; - - /* Date and time of the donation */ - private LocalDateTime date; - - /* The charity that received the donation */ - private Charity charity; - - /* The user/donor that made the donation */ - private User donor; - - /** - * Is the donation made anonymously? - * This can be null if the donation was made anonymously. - * - */ - private boolean isAnonymous; - - /** - * Constructor for creating a new donation. - * The charityId is generated automatically using UUID. - * If the donation is made anonymously, the isAnonymous parameter is set to true. - * @param amount - * @param date - * @param charity - * @param donor - */ - public Donation(double amount, LocalDateTime date, Charity charity, User donor) { - this.charityId = UUID.randomUUID(); - this.amount = amount; - this.date = date; - this.charity = charity; - this.donor = donor; - - - // ASSUMES that this is the way to get the anonymous setting from the user's settings. - if (donor.getSettings().isAnonymous() == false) { - this.isAnonymous = true; - } else { - this.isAnonymous = false; - - } + /* UUID for uniquely identifying each donation */ + private UUID charityId; + + /* Ammount of money donated */ + private double amount; + + /* Date and time of the donation */ + private LocalDateTime date; + + /* The charity that received the donation */ + private Charity charity; + + /* The user/donor that made the donation */ + private User donor; + + /** Is the donation made anonymously? This can be null if the donation was made anonymously. */ + private boolean isAnonymous; + + /** + * Constructor for creating a new donation. The charityId is generated automatically using UUID. + * If the donation is made anonymously, the isAnonymous parameter is set to true. + * + * @param amount + * @param date + * @param charity + * @param donor + */ + public Donation(double amount, LocalDateTime date, Charity charity, User donor) { + this.charityId = UUID.randomUUID(); + this.amount = amount; + this.date = date; + this.charity = charity; + this.donor = donor; + + // ASSUMES that this is the way to get the anonymous setting from the user's settings. + if (donor.getSettings().isAnonymous() == false) { + this.isAnonymous = true; + } else { + this.isAnonymous = false; } + } - /* Getters for the donation's attributes */ - public boolean isAnonymous() { - return isAnonymous; - } + /* Getters for the donation's attributes */ + public boolean isAnonymous() { + return isAnonymous; + } - public UUID getCharityId() { - return charityId; - } + public UUID getCharityId() { + return charityId; + } - public double getAmount() { - return amount; - } + public double getAmount() { + return amount; + } - public LocalDateTime getDate() { - return date; - } + public LocalDateTime getDate() { + return date; + } - public Charity getCharity() { - return charity; - } + public Charity getCharity() { + return charity; + } - public User getDonor() { - return donor; - } + public User getDonor() { + return donor; + } } diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/DonationRegistry.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/DonationRegistry.java index a84ec79..ff6d4e2 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/DonationRegistry.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/DonationRegistry.java @@ -3,37 +3,36 @@ import java.util.*; public class DonationRegistry { - private final List donations; + private final List donations; - public DonationRegistry(){ - this.donations = new ArrayList<>(); - } + public DonationRegistry() { + this.donations = new ArrayList<>(); + } - public List getAllDonations(){ - return Collections.unmodifiableList(donations); - } + public List getAllDonations() { + return Collections.unmodifiableList(donations); + } - public Optional findDonationById(UUID donationId){ - if(donationId == null){ - throw new IllegalArgumentException("DonationId can not be null."); - } - return donations.stream() + public Optional findDonationById(UUID donationId) { + if (donationId == null) { + throw new IllegalArgumentException("DonationId can not be null."); + } + return donations.stream() .filter(donations -> donationId.equals(donations.getCharityId())) .findFirst(); - } + } - public void addDonation(Donation donation){ - if(donation == null){ - throw new IllegalArgumentException("Donation can not be null."); - } - donations.add(donation); + public void addDonation(Donation donation) { + if (donation == null) { + throw new IllegalArgumentException("Donation can not be null."); } + donations.add(donation); + } - public boolean removeDonation(UUID donationId){ - if(donationId == null){ - throw new IllegalArgumentException("DonationId can not be null."); - } - return donations.removeIf(donation -> donationId.equals(donation.getCharityId())); + public boolean removeDonation(UUID donationId) { + if (donationId == null) { + throw new IllegalArgumentException("DonationId can not be null."); } - + return donations.removeIf(donation -> donationId.equals(donation.getCharityId())); + } } diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Feedback.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Feedback.java index fa3e393..f753e8a 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Feedback.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Feedback.java @@ -1,62 +1,62 @@ package ntnu.sytemutvikling.team6.models; -import ntnu.sytemutvikling.team6.models.user.User; - import java.time.LocalDateTime; import java.util.UUID; +import ntnu.sytemutvikling.team6.models.user.User; public class Feedback { - /* Feedback id */ - private UUID feedbackId; - - /** - * The author of the feedback - * If annonymous the presentation of the user will be "Anonymous". - */ - private User user; - - /* The details of the feedback*/ - private String comment; - - /* The date and time when the feedback was given */ - private LocalDateTime date; - - /* Is the feedback given anonymously? */ - private boolean isAnonymous; - - /** - * Constructor for creating a new feedback. - * - * @param user The user who gives the feedback. - * @param comment The content of the feedback. - */ - public Feedback(User user, String comment) { - this.feedbackId = UUID.randomUUID(); - this.user = user; - this.comment = comment; - this.date = LocalDateTime.now(); - - this.isAnonymous = user.getSettings().isAnonymous(); - } - - /** - * Getters for the feedback's attributes. - * - * @return The feedback's attributes. - */ - public UUID getFeedbackId() { - return feedbackId; - } - public String getComment() { - return comment; - } - public LocalDateTime getDate() { - return date; - } - public User getUser() { - return user; - } - public boolean isAnonymous() { - return isAnonymous; - } + /* Feedback id */ + private UUID feedbackId; + + /** The author of the feedback If annonymous the presentation of the user will be "Anonymous". */ + private User user; + + /* The details of the feedback*/ + private String comment; + + /* The date and time when the feedback was given */ + private LocalDateTime date; + + /* Is the feedback given anonymously? */ + private boolean isAnonymous; + + /** + * Constructor for creating a new feedback. + * + * @param user The user who gives the feedback. + * @param comment The content of the feedback. + */ + public Feedback(User user, String comment) { + this.feedbackId = UUID.randomUUID(); + this.user = user; + this.comment = comment; + this.date = LocalDateTime.now(); + + this.isAnonymous = user.getSettings().isAnonymous(); + } + + /** + * Getters for the feedback's attributes. + * + * @return The feedback's attributes. + */ + public UUID getFeedbackId() { + return feedbackId; + } + + public String getComment() { + return comment; + } + + public LocalDateTime getDate() { + return date; + } + + public User getUser() { + return user; + } + + public boolean isAnonymous() { + return isAnonymous; + } } diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/UserRegistry.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/UserRegistry.java index 7b97e02..c858e31 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/UserRegistry.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/UserRegistry.java @@ -1,6 +1,3 @@ package ntnu.sytemutvikling.team6.models; -public class UserRegistry { - - -} +public class UserRegistry {} diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Inbox.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Inbox.java index 2aa0605..b560092 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Inbox.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Inbox.java @@ -5,17 +5,15 @@ // Enhetstester mangler /** - * Represents a user's inbox that contains messages. - * Provides methods to add, remove and get messages. + * Represents a user's inbox that contains messages. Provides methods to add, remove and get + * messages. * - * @author Robin Strand Prestmo + * @author Robin Strand Prestmo */ public class Inbox { private final List messages; - /** - * Creates an empty inbox with no messages. - */ + /** Creates an empty inbox with no messages. */ public Inbox() { this.messages = new ArrayList<>(); } diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Language.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Language.java index 0afb14c..ddc5d82 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Language.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Language.java @@ -7,4 +7,4 @@ */ public enum Language { ENGLISH -} \ No newline at end of file +} diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Message.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Message.java index eba920f..ef9707b 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Message.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Message.java @@ -8,7 +8,7 @@ /** * Represents a message. * - * @author Robin Strand Prestmo + * @author Robin Strand Prestmo */ public class Message { private final UUID id; @@ -18,18 +18,15 @@ public class Message { private final LocalDateTime timeAndDate; /** - * Creates a message with a unique identifier. - * The message includes a title, a string who it's from, - * content and the time and date. + * Creates a message with a unique identifier. The message includes a title, a string who it's + * from, content and the time and date. * * @param title the title of the message * @param from who the message is from * @param content the content of the message * @throws IllegalArgumentException if title, from or content is null or blank. */ - public Message(String title, - String from, - String content) { + public Message(String title, String from, String content) { if (title == null || title.isBlank()) { throw new IllegalArgumentException("Title cannot be null or blank."); @@ -69,4 +66,4 @@ public String getContent() { public LocalDateTime getTimeAndDate() { return timeAndDate; } -} \ No newline at end of file +} diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Settings.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Settings.java index 6bbc685..dd76557 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Settings.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/Settings.java @@ -12,21 +12,17 @@ public class Settings { private Language language; private boolean anonymous; - /** - * Sets standard settings. - * LightMode enabled, language set to English, - * Anonymous disabled - */ + /** Sets standard settings. LightMode enabled, language set to English, Anonymous disabled */ public Settings() { this(true, Language.ENGLISH, false); } + /** * Creates settings for a user. * * @param lightMode choose between light or dark mode * @param language choose language * @param anonymous choose if user is anonymous - * */ public Settings(boolean lightMode, Language language, boolean anonymous) { if (language == null) { @@ -37,16 +33,12 @@ public Settings(boolean lightMode, Language language, boolean anonymous) { this.anonymous = anonymous; } - /** - * Toggles between light and dark mode - */ + /** Toggles between light and dark mode */ public void toggleLightMode() { lightMode = !lightMode; } - /** - * Toggles anonymous mode on and off - */ + /** Toggles anonymous mode on and off */ public void toggleAnonymousMode() { anonymous = !anonymous; } @@ -56,12 +48,12 @@ public void toggleAnonymousMode() { * * @param newLanguage the language to change to. */ - public void changeLanguage(Language newLanguage) { - if (newLanguage == null) { - throw new IllegalArgumentException("Language cannot be null"); - } + public void changeLanguage(Language newLanguage) { + if (newLanguage == null) { + throw new IllegalArgumentException("Language cannot be null"); + } language = newLanguage; - } + } public boolean isLightMode() { return lightMode; diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/User.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/User.java index ba4a298..64594a0 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/User.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/user/User.java @@ -6,8 +6,8 @@ /** * Represents a user in the system. * - *

A user has a unique identifier, personal information, a hashed password, a role, - * settings and an inbox. + *

A user has a unique identifier, personal information, a hashed password, a role, settings and + * an inbox. * *

The password is never stored ad plain text. It is hashed using {@link PasswordHasher} * @@ -36,24 +36,16 @@ public class User { * @param inbox the user“s inbox * @throws IllegalArgumentException if any required argument is invalid. */ - public User(UUID id, - String name, - String email, - String password, - Role role, - Settings settings, - Inbox inbox) { - if (id == null) { - throw new IllegalArgumentException("ID cannot be null."); - } + public User( + String name, String email, String password, Role role, Settings settings, Inbox inbox) { if (name == null || name.isBlank()) { throw new IllegalArgumentException("Name cannot be null or blank."); } if (email == null || email.isBlank() || !email.contains("@") || !email.contains(".")) { - throw new IllegalArgumentException("Email cannot be null or blank," - + " and must contain '@' and '.'"); + throw new IllegalArgumentException( + "Email cannot be null or blank," + " and must contain '@' and '.'"); } if (role == null) { @@ -68,7 +60,7 @@ public User(UUID id, throw new IllegalArgumentException("Inbox cannot be null"); } - this.id = id; + this.id = UUID.randomUUID(); this.name = name; this.email = email; this.passwordHash = passwordHasher.getHashPassword(password); @@ -137,8 +129,8 @@ public void setPassword(String password) { */ public void setEmail(String email) { if (email == null || email.isBlank() || !email.contains("@") || !email.contains(".")) { - throw new IllegalArgumentException("Email cannot be null or blank," - + " and must contains '@' and '.'"); + throw new IllegalArgumentException( + "Email cannot be null or blank," + " and must contains '@' and '.'"); } this.email = email; } @@ -154,4 +146,4 @@ public void setEmail(String email) { public boolean checkPassword(String password) { return passwordHasher.isValidPassword(password, passwordHash); } -} \ No newline at end of file +} diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/security/PasswordHasher.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/security/PasswordHasher.java index 60b2876..8c2f7d9 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/security/PasswordHasher.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/security/PasswordHasher.java @@ -9,9 +9,8 @@ /** * A utility for hashing and verifying passwords using PBKDF2. * - *

The generated hash contains both a random salt and the hashed password, - * encoded as Base64 string. - *

+ *

The generated hash contains both a random salt and the hashed password, encoded as Base64 + * string. * * @author Robin Strand Prestmo */ diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/DonationService.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/DonationService.java index ea3b1d7..17692d5 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/DonationService.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/DonationService.java @@ -1,5 +1,3 @@ package ntnu.sytemutvikling.team6.service; -public class DonationService { - -} +public class DonationService {} diff --git a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/FeedbackService.java b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/FeedbackService.java index 8aedf7f..27eee23 100644 --- a/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/FeedbackService.java +++ b/helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/FeedbackService.java @@ -1,5 +1,3 @@ package ntnu.sytemutvikling.team6.service; -public class FeedbackService { - -} +public class FeedbackService {}