-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Fix OrganizationRepository constructor and update related classes
- Loading branch information
Fredrik Marjoni
committed
Mar 5, 2026
1 parent
fb67556
commit 6c34cfc
Showing
8 changed files
with
70 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/edu/group5/app/model/user/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package edu.group5.app.model.user; | ||
|
|
||
| import java.util.HashMap; | ||
|
|
||
| import edu.group5.app.model.DBRepository; | ||
|
|
||
| public class UserRepository extends DBRepository<Integer, User>{ | ||
|
|
||
| /** | ||
| * Constructs DonationRepository using Hashmap, | ||
| * and extends the content from DBRepository. | ||
| * @param content the underlying map used to store donations, | ||
| * where the key represents the donation ID | ||
| */ | ||
| public UserRepository(HashMap<Integer, User> content) { | ||
| super(content); | ||
| if (content == null) { | ||
| throw new IllegalArgumentException("Content cannot be null"); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Adds a new donation to the repository | ||
| * <p> | ||
| * The donation is stored using its {@code donationId} as the key. | ||
| * If a donation with the same ID already exists, the donation | ||
| * will not be added. | ||
| * </p> | ||
| * | ||
| * @param donation the donation to add | ||
| * @return {@code true} if the donation was successfully added, and | ||
| * {@code false} if a donation with the same ID already exists | ||
| */ | ||
| public boolean addUser(User user) { | ||
| if (user == null) { | ||
| throw new IllegalArgumentException("Donation cannot be null"); | ||
| } | ||
| if (content.containsKey(user.getUserId())){ | ||
| return false; | ||
| } | ||
| content.put(user.getUserId(), user); | ||
| return true; | ||
| } | ||
|
|
||
| public User findUserByEmail(String email) { | ||
| return null; | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters