Skip to content

Commit

Permalink
refactor: minor changes to OrganizationRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
emilfa committed Mar 1, 2026
1 parent ee4a9ca commit e2c0f1a
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,48 @@
import edu.group5.app.model.Repository;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
* Handles business logic associated with organizations
* Handles the business logic associated with organizations
*/
public class OrganizationRepo extends Repository {
private final HashMap<Integer, Organization> content;
public class OrganizationRepository extends Repository {
private final Map<Integer, Organization> content;

/**
* Creates a new Organization Repository
*
* @param content holds all current organizations in the repository
* @param content holds all current organizations in the repository; must not be null
* @throws NullPointerException if content is null
*/
public OrganizationRepo(HashMap<Integer, Organization> content) {
public OrganizationRepository(Map<Integer, Organization> content) {
this.content = Objects.requireNonNull(content, "content cannot be null");
super(content);
}

/**
* Returns the organizations within the repository.
* @return all organizations within the repository.
*/
@Override
public Map<Integer, Organization> getContent() {
return content;
}

/**
* Gets all trusted organizations in the repository
* @return all organizations with trusted = true
*/
public HashMap<Integer, Organization> getTrustedOrganizations() {
HashMap<Integer, Organization> trustedOrgs = new HashMap<>();
public Map<Integer, Organization> getTrustedOrganizations() {
Map<Integer, Organization> trustedOrganizations = new HashMap<>();

content.forEach((orgNr, org) -> {
if (org.trusted()) {
trustedOrgs.put(orgNr, org);
trustedOrganizations.put(orgNr, org);
}
});

return trustedOrgs;
return trustedOrganizations;
}
}

0 comments on commit e2c0f1a

Please sign in to comment.