-
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.
- Loading branch information
1 parent
77602bc
commit d4dd7e0
Showing
7 changed files
with
60 additions
and
18 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
30 changes: 20 additions & 10 deletions
30
src/main/java/com/seoultech/sanEseo/post/domain/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,17 +1,27 @@ | ||
package com.seoultech.sanEseo.post.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
public enum Category { | ||
DODREAM, CUSTOM; | ||
DODREAM(0), CUSTOM(1); | ||
|
||
public static Category from(int category) { | ||
if (category == 1) { | ||
return DODREAM; | ||
} else if (category == 2) { | ||
return CUSTOM; | ||
} else { | ||
throw new IllegalArgumentException("Unknown category: " + category); | ||
} | ||
private final int value; | ||
|
||
Category(int value) { | ||
this.value = value; | ||
} | ||
|
||
@JsonValue | ||
public int getValue() { | ||
return value; | ||
} | ||
|
||
} | ||
public static Category from(int value) { | ||
for (Category category : values()) { | ||
if (category.getValue() == value) { | ||
return category; | ||
} | ||
} | ||
throw new IllegalArgumentException("Unknown category value: " + value); | ||
} | ||
} |
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
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