-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from NewsFit-jolp/fix/category_enum
Fix/category enum
- Loading branch information
Showing
4 changed files
with
33 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 28 additions & 1 deletion
29
src/main/java/com/example/newsfit/domain/article/entity/Category.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
package com.example.newsfit.domain.article.entity; | ||
|
||
public enum Category { | ||
정치, 경제, 사회, 생활_문화, 세계, 기술_IT, 연예, 스포츠 | ||
정치("정치"), | ||
경제("경제"), | ||
사회("사회"), | ||
생활_문화("생활/문화"), | ||
세계("세계"), | ||
기술_IT("기술/IT"), | ||
연예("연예"), | ||
스포츠("스포츠"); | ||
|
||
private final String displayName; | ||
|
||
Category(String displayName) { | ||
this.displayName = displayName; | ||
} | ||
|
||
public static Category fromDisplayName(String displayName) { | ||
for (Category category : Category.values()) { | ||
if (category.displayName.equals(displayName)) { | ||
return category; | ||
} | ||
} | ||
throw new IllegalArgumentException("Unknown category: " + displayName); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return displayName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters