Skip to content

Commit

Permalink
Updated APICharityData
Browse files Browse the repository at this point in the history
Added javadoc descriptions, throws an exception if org_number is invalid, and automatically normalizes the value of org_number.
  • Loading branch information
roaraf committed Mar 4, 2026
1 parent 5c8c8a6 commit 9cb3206
Showing 1 changed file with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,36 +1,91 @@
package ntnu.sytemutvikling.team6.models;

/**
* Represents data parsed from the IK API JSON response.
* Instances are immutable; to update any value, a new object must be created.
* <p>
* Receives data directly from {@link APICharityScraper} or {@link IKOrganizationScraper}.
* </p>
* <p>
* {@code org_number} should be a unique number, as it is used as a primary key
* in {@link DatabaseManager}.
* </p>
*/

public class APICharityData {
private final String org_number;
private final String name;
private final String status;
private final String url;
private final boolean is_pre_approved;

/**
* Constructs a new APICharityData object.
* @param org_number a unique number that identifies the organization
* @param name the name of the organization
* @param status {@code approved} for approved organizations,
* {@code obs} for non-approved organizations
* @param url the URL for more info about the organization on the IK domain
* @param is_pre_approved whether the organization was pre-approved
*/

public APICharityData(String org_number, String name, String status, String url, boolean is_pre_approved) {
this.org_number = org_number;
if (org_number == null || org_number.isBlank()) {
throw new IllegalArgumentException("ERROR: Org number cannot be null or blank");
}
this.org_number = org_number.replaceAll("\\s", "");
this.name = name;
this.status = status;
this.url = url;
this.is_pre_approved = is_pre_approved;
}

/**
* Returns the organization number. Must not be {@code null} or blank.
*
* @return the organization number
*/

public String getOrg_number() {
return this.org_number;
}

/**
* Returns the name of the organization. Whitespace removed.
*
* @return the name of the organization
*/

public String getName() {
return name;
}

/**
* Returns whether the organization is approved or not
* @return the approved status of the organization
*/

public String getStatus() {
return status;
}

/**
* Returns the URL of the organizations information page on IK
*
* @return the URL for more info about the organization
*/

public String getUrl() {
return url;
}

/**
* Returns whether the organization was pre-approved.
*
* @return {@code true} if organization was pre-approved <br>
* {@code false} otherwise
*/

public boolean getIs_pre_approved() {
return this.is_pre_approved;
}
Expand Down

0 comments on commit 9cb3206

Please sign in to comment.