mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 03:01:12 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -38,17 +38,16 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* The Data Transfer Object pattern is a design pattern in which an data transfer object is used to
|
||||
* serve related information together to avoid multiple call for each piece of information.
|
||||
*
|
||||
* <p>In the first example, {@link App} is a customer details consumer i.e. client to
|
||||
* request for customer details to server. {@link CustomerResource} act as server to serve customer
|
||||
* information. {@link CustomerDto} is data transfer object to share customer information.
|
||||
* <p>In the first example, {@link App} is a customer details consumer i.e. client to request for
|
||||
* customer details to server. {@link CustomerResource} act as server to serve customer information.
|
||||
* {@link CustomerDto} is data transfer object to share customer information.
|
||||
*
|
||||
* <p>In the second example, {@link App} is a product details consumer i.e. client to
|
||||
* request for product details to server. {@link ProductResource} acts as server to serve
|
||||
* product information. {@link ProductDto} is data transfer object to share product information.
|
||||
* <p>In the second example, {@link App} is a product details consumer i.e. client to request for
|
||||
* product details to server. {@link ProductResource} acts as server to serve product information.
|
||||
* {@link ProductDto} is data transfer object to share product information.
|
||||
*
|
||||
* <p>The pattern implementation is a bit different in each of the examples. The first can be
|
||||
* thought as a traditional example and the second is an enum based implementation.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class App {
|
||||
@@ -88,28 +87,32 @@ public class App {
|
||||
|
||||
// Example 2: Product DTO
|
||||
|
||||
Product tv = Product.builder().id(1L).name("TV").supplier("Sony").price(1000D).cost(1090D).build();
|
||||
Product tv =
|
||||
Product.builder().id(1L).name("TV").supplier("Sony").price(1000D).cost(1090D).build();
|
||||
Product microwave =
|
||||
Product.builder()
|
||||
.id(2L)
|
||||
.name("microwave")
|
||||
.supplier("Delonghi")
|
||||
.price(1000D)
|
||||
.cost(1090D).build();
|
||||
.cost(1090D)
|
||||
.build();
|
||||
Product refrigerator =
|
||||
Product.builder()
|
||||
.id(3L)
|
||||
.name("refrigerator")
|
||||
.supplier("Botsch")
|
||||
.price(1000D)
|
||||
.cost(1090D).build();
|
||||
.cost(1090D)
|
||||
.build();
|
||||
Product airConditioner =
|
||||
Product.builder()
|
||||
.id(4L)
|
||||
.name("airConditioner")
|
||||
.supplier("LG")
|
||||
.price(1000D)
|
||||
.cost(1090D).build();
|
||||
.cost(1090D)
|
||||
.build();
|
||||
List<Product> products =
|
||||
new ArrayList<>(Arrays.asList(tv, microwave, refrigerator, airConditioner));
|
||||
ProductResource productResource = new ProductResource(products);
|
||||
|
||||
Reference in New Issue
Block a user