| 
									
										
										
										
											2016-08-30 13:29:12 +02:00
										 |  |  | @startuml | 
					
						
							|  |  |  | package com.iluwatar.dao { | 
					
						
							|  |  |  |   class App { | 
					
						
							|  |  |  |     - DB_URL : String {static} | 
					
						
							|  |  |  |     - log : Logger {static} | 
					
						
							|  |  |  |     + App() | 
					
						
							|  |  |  |     - addCustomers(customerDao : CustomerDao) {static} | 
					
						
							|  |  |  |     - createDataSource() : DataSource {static} | 
					
						
							|  |  |  |     - createSchema(dataSource : DataSource) {static} | 
					
						
							|  |  |  |     - deleteSchema(dataSource : DataSource) {static} | 
					
						
							|  |  |  |     + generateSampleCustomers() : List<Customer> {static} | 
					
						
							|  |  |  |     + main(args : String[]) {static} | 
					
						
							|  |  |  |     - performOperationsUsing(customerDao : CustomerDao) {static} | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-09-18 17:51:09 +03:00
										 |  |  |   class Customer { | 
					
						
							|  |  |  |     - firstName : String | 
					
						
							|  |  |  |     - id : int | 
					
						
							|  |  |  |     - lastName : String | 
					
						
							|  |  |  |     + Customer(id : int, firstName : String, lastName : String) | 
					
						
							|  |  |  |     + equals(that : Object) : boolean | 
					
						
							|  |  |  |     + getFirstName() : String | 
					
						
							|  |  |  |     + getId() : int | 
					
						
							|  |  |  |     + getLastName() : String | 
					
						
							|  |  |  |     + hashCode() : int | 
					
						
							|  |  |  |     + setFirstName(firstName : String) | 
					
						
							|  |  |  |     + setId(id : int) | 
					
						
							|  |  |  |     + setLastName(lastName : String) | 
					
						
							|  |  |  |     + toString() : String | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-11-26 12:51:06 +01:00
										 |  |  |   interface CustomerDao { | 
					
						
							|  |  |  |     + add(Customer) : boolean {abstract} | 
					
						
							|  |  |  |     + delete(Customer) : boolean {abstract} | 
					
						
							|  |  |  |     + getAll() : Stream<Customer> {abstract} | 
					
						
							|  |  |  |     + getById(int) : Optional<Customer> {abstract} | 
					
						
							|  |  |  |     + update(Customer) : boolean {abstract} | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-11 21:46:56 +02:00
										 |  |  |   class CustomerSchemaSql { | 
					
						
							| 
									
										
										
										
											2016-11-26 12:51:06 +01:00
										 |  |  |     + CREATE_SCHEMA_SQL : String {static} | 
					
						
							|  |  |  |     + DELETE_SCHEMA_SQL : String {static} | 
					
						
							| 
									
										
										
										
											2017-02-11 21:46:56 +02:00
										 |  |  |     - CustomerSchemaSql() | 
					
						
							| 
									
										
										
										
											2016-11-26 12:51:06 +01:00
										 |  |  |   } | 
					
						
							|  |  |  |   class DbCustomerDao { | 
					
						
							|  |  |  |     - dataSource : DataSource | 
					
						
							|  |  |  |     + DbCustomerDao(dataSource : DataSource) | 
					
						
							|  |  |  |     + add(customer : Customer) : boolean | 
					
						
							|  |  |  |     - createCustomer(resultSet : ResultSet) : Customer | 
					
						
							|  |  |  |     + delete(customer : Customer) : boolean | 
					
						
							|  |  |  |     + getAll() : Stream<Customer> | 
					
						
							|  |  |  |     + getById(id : int) : Optional<Customer> | 
					
						
							|  |  |  |     - getConnection() : Connection | 
					
						
							|  |  |  |     - mutedClose(connection : Connection) | 
					
						
							|  |  |  |     + update(customer : Customer) : boolean | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   class InMemoryCustomerDao { | 
					
						
							|  |  |  |     - idToCustomer : Map<Integer, Customer> | 
					
						
							|  |  |  |     + InMemoryCustomerDao() | 
					
						
							|  |  |  |     + add(customer : Customer) : boolean | 
					
						
							|  |  |  |     + delete(customer : Customer) : boolean | 
					
						
							|  |  |  |     + getAll() : Stream<Customer> | 
					
						
							|  |  |  |     + getById(id : int) : Optional<Customer> | 
					
						
							|  |  |  |     + update(customer : Customer) : boolean | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-08-30 13:29:12 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-09-18 17:51:09 +03:00
										 |  |  | DbCustomerDao ..|> CustomerDao  | 
					
						
							| 
									
										
										
										
											2016-11-26 12:51:06 +01:00
										 |  |  | InMemoryCustomerDao ..|> CustomerDao  | 
					
						
							| 
									
										
										
										
											2016-08-30 13:29:12 +02:00
										 |  |  | @enduml |