Skip to content

Commit

Permalink
Merge pull request #31 from cathrkri/28-userregistry-charityregistry-…
Browse files Browse the repository at this point in the history
…and-donationregistry

Modifications: Registry classes
  • Loading branch information
meenaksj authored Mar 3, 2026
2 parents 28d21d0 + 14e82dd commit 6929afa
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
test
package ntnu.sytemutvikling.team6.models;

import java.util.*;

public class CharityRegistry{
private final List<Charity> charities;

public CharityRegistry(){
this.charities = new ArrayList<>();
}

public List<Charity> getAllCharities(){
return Collections.unmodifiableList(charities);
}

public Optional<Charity> findCharityById(UUID charityId){
if(charityId == null){
throw new IllegalArgumentException("CharityId can not be null.");
}
return charities.stream()
.filter(charity -> charityId.equals(charity.getId()))
.findFirst();
}

public void addCharity(Charity charity){
if(charity == null){
throw new IllegalArgumentException("Charity can not be null.");
}
charities.add(charity);
}

public boolean removeCharity(UUID charityId){
if(charityId == null){
throw new IllegalArgumentException("CharityId can not be null.");
}
return charities.removeIf(charity -> charityId.equals(charity.getId()));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
package ntnu.sytemutvikling.team6.models;

import java.util.*;

public class DonationRegistry {
private final List<Donation> donations;

public DonationRegistry(){
this.donations = new ArrayList<>();
}

public List<Donation> getAllDonations(){
return Collections.unmodifiableList(donations);
}

public Optional<Donation> findDonationById(UUID donationId){
if(donationId == null){
throw new IllegalArgumentException("DonationId can not be null.");
}
return donations.stream()
.filter(donations -> donationId.equals(donations.getId()))
.findFirst();
}

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.getId));
}

}

0 comments on commit 6929afa

Please sign in to comment.