mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 08:59:01 +00:00
docs: data transfer object + refactor
This commit is contained in:
@@ -67,15 +67,15 @@ public class App {
|
||||
|
||||
var customerResource = new CustomerResource(customers);
|
||||
|
||||
LOGGER.info("All customers:-");
|
||||
var allCustomers = customerResource.getAllCustomers();
|
||||
LOGGER.info("All customers:");
|
||||
var allCustomers = customerResource.customers();
|
||||
printCustomerDetails(allCustomers);
|
||||
|
||||
LOGGER.info("----------------------------------------------------------");
|
||||
|
||||
LOGGER.info("Deleting customer with id {1}");
|
||||
customerResource.delete(customerOne.getId());
|
||||
allCustomers = customerResource.getAllCustomers();
|
||||
customerResource.delete(customerOne.id());
|
||||
allCustomers = customerResource.customers();
|
||||
printCustomerDetails(allCustomers);
|
||||
|
||||
LOGGER.info("----------------------------------------------------------");
|
||||
@@ -83,7 +83,7 @@ public class App {
|
||||
LOGGER.info("Adding customer three}");
|
||||
var customerThree = new CustomerDto("3", "Lynda", "Blair");
|
||||
customerResource.save(customerThree);
|
||||
allCustomers = customerResource.getAllCustomers();
|
||||
allCustomers = customerResource.customers();
|
||||
printCustomerDetails(allCustomers);
|
||||
|
||||
// Example 2: Product DTO
|
||||
@@ -131,10 +131,10 @@ public class App {
|
||||
productResource.save(createProductRequestDto);
|
||||
LOGGER.info(
|
||||
"####### List of products after adding PS5: {}",
|
||||
Arrays.toString(productResource.getProducts().toArray()));
|
||||
Arrays.toString(productResource.products().toArray()));
|
||||
}
|
||||
|
||||
private static void printCustomerDetails(List<CustomerDto> allCustomers) {
|
||||
allCustomers.forEach(customer -> LOGGER.info(customer.getFirstName()));
|
||||
allCustomers.forEach(customer -> LOGGER.info(customer.firstName()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user