Skip to content

Commit

Permalink
Change oid field to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
McNaBry committed Oct 18, 2023
1 parent 8ca3b9a commit 2029b22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/main/java/seedu/address/model/person/Recruiter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.model.person;

import java.util.Objects;
import java.util.Optional;
import java.util.Set;

import seedu.address.commons.util.ToStringBuilder;
Expand All @@ -12,17 +13,17 @@
*/
public class Recruiter extends Contact {

private final Id oid;
private final Optional<Id> oid;

/**
* Every field except oid must be present and not null.
*/
public Recruiter(Name name, Id id, Phone phone, Email email, Url url, Address address, Set<Tag> tags, Id oid) {
super(name, id, phone, email, url, address, tags);
this.oid = oid;
this.oid = Optional.ofNullable(oid);
}

public Id getOrganizationId() {
public Optional<Id> getOrganizationId() {
return oid;
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/address/storage/JsonAdaptedContact.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ public JsonAdaptedContact(Contact source) {
position = ((Organization) source).getPosition().jobPosition;
oid = "";
} else if (source.getType() == Type.RECRUITER) {
Recruiter recruiter = (Recruiter) source;
status = "";
position = "";
Id tmp = ((Recruiter) source).getOrganizationId();
oid = tmp == null ? null : tmp.value;
oid = recruiter.getOrganizationId()
.map(oid -> oid.value)
.orElse(null);
}

type = source.getType().toString();
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/seedu/address/ui/ContactCard.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.ui;

import java.util.Comparator;
import java.util.Optional;
import java.util.function.Supplier;

import javafx.fxml.FXML;
Expand Down Expand Up @@ -97,14 +98,14 @@ public ContactCard(Contact contact, int displayedIndex) {
case RECRUITER: {
Recruiter recruiter = (Recruiter) contact;

final Id linkedOrgId = recruiter.getOrganizationId();
final Optional<Id> linkedOrgId = recruiter.getOrganizationId();

setVboxInnerLabelText(
linkedParentOrganization, () -> linkedOrgId == null
? null
: String.format(
"from %s (%s)", "organization" /* TODO: Use org name instead */, linkedOrgId.value
)
linkedParentOrganization, () -> linkedOrgId.map(oid ->
String.format(
"from %s (%s)", "organization" /* TODO: Use org name instead */, oid.value
))
.orElse(null)
);
cardPaneInnerVbox.getChildren().removeAll(status, position);
break;
Expand Down

0 comments on commit 2029b22

Please sign in to comment.