@@ -34,8 +34,31 @@ public ProductMetric(Long productId, Long viewCount, Long likeCount, Long salesV
3434 this .eventType = eventType ;
3535 }
3636
37- public static ProductMetric of (Long productId , Long viewCount , Long likeCount , Long salesVolume , ProductEventType eventType ) {
38- return new ProductMetric (productId , viewCount , likeCount , salesVolume , eventType );
37+ /*
38+ - [ ] 리팩토링 예정
39+ */
40+ public static ProductMetric of (Long productId , ProductEventType eventType ) {
41+ if (eventType == null ) {
42+ throw new IllegalArgumentException ("정의되지 않은 event type입니다." );
43+ }
44+
45+ return switch (eventType ) {
46+ case PRODUCT_VIEWED -> ofProductViewed (productId );
47+ case PRODUCT_LIKED -> ofProductLiked (productId );
48+ case PRODUCT_SALES -> ofProductSales (productId );
49+ };
50+ }
51+
52+ public static ProductMetric ofProductViewed (Long productId ) {
53+ return new ProductMetric (productId , 1L , 0L , 0L , ProductEventType .PRODUCT_VIEWED );
54+ }
55+
56+ public static ProductMetric ofProductLiked (Long productId ) {
57+ return new ProductMetric (productId , 0L , 1L , 0L , ProductEventType .PRODUCT_LIKED );
58+ }
59+
60+ public static ProductMetric ofProductSales (Long productId ) {
61+ return new ProductMetric (productId , 0L , 0L , 1L , ProductEventType .PRODUCT_SALES );
3962 }
4063
4164 public void increaseProductMetric (ProductEventType eventType ) {
0 commit comments