-
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.
feat: created OrganizationRepo class
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/edu/group5/app/model/organization/OrganizationRepo.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,39 @@ | ||
| package edu.group5.app.model.organization; | ||
|
|
||
| import edu.group5.app.model.Repository; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Handles business logic associated with organizations | ||
| */ | ||
| public class OrganizationRepo implements Repository { | ||
| private HashMap<Integer, Organization> content; | ||
|
|
||
| /** | ||
| * Creates a new Organization Repository | ||
| * | ||
| * @param content holds all current organizations | ||
| * @throws NullPointerException if content is null | ||
| */ | ||
| public OrganizationRepo(HashMap<Integer, Organization> content) { | ||
| this.content = Objects.requireNonNull(content, "content cannot be null"); | ||
| } | ||
|
|
||
| public HashMap<Integer, Organization> getContent() { | ||
| return content; | ||
| } | ||
|
|
||
| public HashMap<Integer, Organization> getTrustedOrganizations() { | ||
| HashMap<Integer, Organization> trustedOrgs = new HashMap<>(); | ||
|
|
||
| content.forEach((orgNr, org) -> { | ||
| if (org.trusted()) { | ||
| trustedOrgs.put(orgNr, org); | ||
| } | ||
| }); | ||
|
|
||
| return trustedOrgs; | ||
| } | ||
| } |