Skip to content

Commit 76bde6c

Browse files
committed
refactor: 네이밍 수정, NPE방지를 위해 isEmpty가 아닌 Collection Utils isEmpty로 처리
1 parent de8ee99 commit 76bde6c

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/main/java/com/programmers/springweekly/ConsoleApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public void run(String... args) {
2828
ProgramMenu selectMenu = ProgramMenu.from(console.inputMessage());
2929

3030
switch (selectMenu) {
31-
case CUSTOMER -> consoleCustomer.run();
32-
case VOUCHER -> consoleVoucher.run();
31+
case CUSTOMER -> consoleCustomer.menu();
32+
case VOUCHER -> consoleVoucher.menu();
3333
case EXIT -> {
3434
console.outputExitMessage();
3535
running = false;

src/main/java/com/programmers/springweekly/ConsoleCustomer.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.UUID;
99
import lombok.RequiredArgsConstructor;
1010
import org.springframework.stereotype.Component;
11+
import org.springframework.util.CollectionUtils;
1112

1213
@Component
1314
@RequiredArgsConstructor
@@ -16,7 +17,7 @@ public class ConsoleCustomer {
1617
private final CustomerController customerController;
1718
private final Console console;
1819

19-
public void run() {
20+
public void menu() {
2021
console.outputCustomerMenuGuide();
2122
CustomerMenu customerMenu = CustomerMenu.from(console.inputMessage());
2223

@@ -31,14 +32,14 @@ public void run() {
3132
}
3233

3334
private void selectCustomer() {
34-
CustomerListResponse customerList = customerController.findAll();
35+
CustomerListResponse customerListResponse = customerController.findAll();
3536

36-
if (customerList.getCustomerList().isEmpty()) {
37+
if (CollectionUtils.isEmpty(customerListResponse.getCustomerList())) {
3738
console.outputErrorMessage("고객이 저장되어 있지 않습니다.");
3839
return;
3940
}
4041

41-
console.outputGetCustomerList(customerList);
42+
console.outputGetCustomerList(customerListResponse);
4243
}
4344

4445
private void deleteCustomer() {
@@ -68,14 +69,14 @@ private void createCustomer() {
6869
}
6970

7071
private void getBlackList() {
71-
CustomerListResponse customerBlacklist = customerController.getBlackList();
72+
CustomerListResponse customerBlacklistResponse = customerController.getBlackList();
7273

73-
if (customerBlacklist.getCustomerList().isEmpty()) {
74+
if (CollectionUtils.isEmpty(customerBlacklistResponse.getCustomerList())) {
7475
console.outputErrorMessage("블랙 리스트인 고객이 없습니다.");
7576
return;
7677
}
7778

78-
console.outputGetCustomerList(customerBlacklist);
79+
console.outputGetCustomerList(customerBlacklistResponse);
7980
}
80-
81+
8182
}

src/main/java/com/programmers/springweekly/ConsoleVoucher.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.UUID;
1111
import lombok.RequiredArgsConstructor;
1212
import org.springframework.stereotype.Component;
13+
import org.springframework.util.CollectionUtils;
1314

1415
@Component
1516
@RequiredArgsConstructor
@@ -18,7 +19,7 @@ public class ConsoleVoucher {
1819
private final VoucherController voucherController;
1920
private final Console console;
2021

21-
public void run() {
22+
public void menu() {
2223
console.outputVoucherMenuGuide();
2324
VoucherMenu voucherMenu = VoucherMenu.from(console.inputMessage());
2425

@@ -64,7 +65,7 @@ private void deleteVoucher() {
6465
private void selectVoucher() {
6566
VoucherListResponse voucherListResponse = voucherController.findAll();
6667

67-
if (voucherListResponse.getVoucherList().isEmpty()) {
68+
if (CollectionUtils.isEmpty(voucherListResponse.getVoucherList())) {
6869
console.outputErrorMessage("저장된 바우처가 없습니다.");
6970
return;
7071
}

0 commit comments

Comments
 (0)