Skip to content

Commit

Permalink
Merge pull request #1624 from woowacourse/hotfix/no-issue
Browse files Browse the repository at this point in the history
fix: Dapartment.getPart 메서드 수정
  • Loading branch information
wonyongChoi05 authored Nov 23, 2023
2 parents ab5cc4c + fc3261a commit 0d0b21e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Department(Long id, String part, String term) {
this.part = Part.getPartByName(part);
this.term = Term.getTermByName(term);
}

public Part getPart() {
return part;
}
Expand Down
10 changes: 6 additions & 4 deletions backend/src/main/java/wooteco/prolog/member/domain/Part.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ public enum Part {

private final String name;

public static Part getPartByName(String name) {
public boolean isContainedBy(String name) {
if (name == null) {
return false;
}
return Arrays.stream(values())
.filter(part -> part.name.equals(name))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("name과 일치하는 part가 존재하지 않습니다."));
.anyMatch(p -> p.name.equals(name));
}

}

0 comments on commit 0d0b21e

Please sign in to comment.