Skip to content

Commit 410e4c2

Browse files
committed
refactor: voucherFactory에서 switch문법 개선
1 parent fe1eecf commit 410e4c2

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/main/java/com/programmers/springweekly/domain/voucher/VoucherFactory.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@ public class VoucherFactory {
66

77
public static Voucher createVoucher(UUID voucherId, VoucherType voucherType, long discount) {
88

9-
switch (voucherType) {
10-
case FIXED -> {
11-
return new FixedAmountVoucher(voucherId, discount);
12-
}
13-
case PERCENT -> {
14-
return new PercentDiscountVoucher(voucherId, discount);
15-
}
16-
default -> throw new IllegalArgumentException("Input: " + voucherType + "바우처 타입이 없습니다.");
17-
}
9+
return switch (voucherType) {
10+
case FIXED -> new FixedAmountVoucher(voucherId, discount);
11+
case PERCENT -> new PercentDiscountVoucher(voucherId, discount);
12+
};
1813
}
19-
2014
}

0 commit comments

Comments
 (0)