-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#83] Feat : RestaurantType을 생성하고 RestaurantName에서 식단을 제공 하는 식당인지 고정 …
…메뉴를 제공하는 식당인지 확인한다
- Loading branch information
1 parent
838938e
commit 54eed6e
Showing
4 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/ssu/eatssu/domain/menu/exception/RestaurantNotFoundException.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ssu.eatssu.domain.menu.exception; | ||
|
||
public class RestaurantNotFoundException extends IllegalArgumentException { | ||
|
||
public RestaurantNotFoundException() { | ||
super("해당 식당이 존재하지 않습니다."); | ||
} | ||
|
||
public RestaurantNotFoundException(String s) { | ||
super(s); | ||
} | ||
|
||
public RestaurantNotFoundException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
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
28 changes: 21 additions & 7 deletions
28
src/main/java/ssu/eatssu/domain/restaurant/RestaurantName.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,29 +1,43 @@ | ||
package ssu.eatssu.domain.restaurant; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import java.util.Arrays; | ||
import lombok.Getter; | ||
|
||
import java.util.Locale; | ||
import ssu.eatssu.domain.menu.exception.RestaurantNotFoundException; | ||
|
||
@Getter | ||
public enum RestaurantName { | ||
DODAM("도담 식당", 6000), | ||
DORMITORY("기숙사 식당", 5000), | ||
FOOD_COURT("푸드 코트", 0), | ||
SNACK_CORNER("스낵 코너", 0), | ||
HAKSIK("학생 식당", 5000); | ||
DODAM(RestaurantType.VARIABLE, "도담 식당", 6000), | ||
DORMITORY(RestaurantType.VARIABLE, "기숙사 식당", 5000), | ||
FOOD_COURT(RestaurantType.FIXED, "푸드 코트", 0), | ||
SNACK_CORNER(RestaurantType.FIXED, "스낵 코너", 0), | ||
HAKSIK(RestaurantType.VARIABLE, "학생 식당", 5000); | ||
|
||
private RestaurantType restaurantType; | ||
private String description; | ||
private Integer price; | ||
|
||
@JsonCreator | ||
public static RestaurantName from(String description) { | ||
return RestaurantName.valueOf(description.toUpperCase(Locale.ROOT)); | ||
return Arrays.stream(RestaurantName.values()) | ||
.filter(d -> d.getDescription().equals(description)) | ||
.findAny() | ||
.orElseThrow(RestaurantNotFoundException::new); | ||
} | ||
|
||
RestaurantName(String description, Integer price) { | ||
RestaurantName(RestaurantType restaurantType, String description, Integer price) { | ||
this.restaurantType = restaurantType; | ||
this.description = description; | ||
this.price = price; | ||
} | ||
|
||
public static boolean isFixed(RestaurantName restaurantName) { | ||
return restaurantName.getRestaurantType() == RestaurantType.FIXED; | ||
} | ||
|
||
public static boolean isVariable(RestaurantName restaurantName) { | ||
return restaurantName.getRestaurantType() == RestaurantType.VARIABLE; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/ssu/eatssu/domain/restaurant/RestaurantType.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package ssu.eatssu.domain.restaurant; | ||
|
||
public enum RestaurantType { | ||
FIXED, | ||
VARIABLE | ||
} |