Skip to content

Commit

Permalink
Change code to use parseUtil class
Browse files Browse the repository at this point in the history
  • Loading branch information
Ko-Khan committed Apr 3, 2024
1 parent 518bde7 commit e06232e
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@

import java.util.function.Predicate;

import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.article.exceptions.InvalidStatusException;

/**
* Ensures that an {@code Article}'s {@code Status} matches the given status
*/
public class ArticleMatchesStatusPredicate implements Predicate<Article> {
private Article.Status status;
private Enum<Article.Status> status;

/**
* Constructs an ArticleMatchesStatusPredicate
* @param s The string representation of the status
* @throws InvalidStatusException thrown when status entered is invalid.
*/
public ArticleMatchesStatusPredicate(String s) throws InvalidStatusException {
if (s.equals("PUBLISHED")) {
status = Article.Status.PUBLISHED;
} else if (s.equals("DRAFT")) {
status = Article.Status.DRAFT;
} else if (s.equals("ARCHIVED")) {
status = Article.Status.ARCHIVED;
} else {
try {
status = ParserUtil.parseStatus(s);
} catch (ParseException e) {

Check warning on line 24 in src/main/java/seedu/address/model/article/ArticleMatchesStatusPredicate.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/article/ArticleMatchesStatusPredicate.java#L23-L24

Added lines #L23 - L24 were not covered by tests
throw new InvalidStatusException();
}
}
Expand All @@ -49,7 +47,7 @@ public boolean equals(Object other) {
ArticleMatchesStatusPredicate otherArticleMatchesStatusPredicate = (ArticleMatchesStatusPredicate) other;
return this.status.equals(otherArticleMatchesStatusPredicate.getStatus());
}
public Article.Status getStatus() {
public Enum<Article.Status> getStatus() {
return this.status;
}
}

0 comments on commit e06232e

Please sign in to comment.