====================================================================
key의 중복을 허용하는 Map이 있는가?
X (List가 중복 허용함, 대신 key, value 구분은 없다)
Item 생성시 고유 sequence 번호 부여 -> sequence 번호만 loginId별로 저장하여 찾을 때 사용
아니면 각 아이디마다 저장소를 따로 만들어서 보관할 수 있는가 -> 저장소를 저장하는 방법
저장소 말고 class 객체를 만들어서 관리하기
Item을 저장할 객체를 따로 만들기 -> Map <String, ItemSaveObject> 으로 ItemRepository에 저장하기 (String은 loginId)
====================================================================
public enum ItemType {
HEALTH("건강"), MEDICAL("의료");
private final String description;
ItemType(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
}
@NotNull
private ItemType itemType;
@ModelAttribute("itemTypes")
public ItemType[] itemTypes(){
return ItemType.values();
}
ModelAttribute의 특별한 사용법
ItemType[] ~ ItemType.values()는 ENUM의 모든 정보를 배열로 반환한다.
<div>
<div th:each="type : ${itemTypes}">
<input type="radio" th:field="*{itemType}" th:value="${type.name()}">
<label th:for="${#ids.prev('itemType')}" th:text="${type.description}"></label>
</div>
</div>
@NotBlank
private Integer price;