#1113 Add uml-reverse-mapper plugin
This commit is contained in:
parent
55769e9841
commit
0685a505d3
65
abstract-document/etc/abstract-document.urm.puml
Normal file
65
abstract-document/etc/abstract-document.urm.puml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.abstractdocument.domain.enums {
|
||||||
|
enum Property {
|
||||||
|
+ MODEL {static}
|
||||||
|
+ PARTS {static}
|
||||||
|
+ PRICE {static}
|
||||||
|
+ TYPE {static}
|
||||||
|
+ valueOf(name : String) : Property {static}
|
||||||
|
+ values() : Property[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.abstractdocument.domain {
|
||||||
|
class Car {
|
||||||
|
+ Car(properties : Map<String, Object>)
|
||||||
|
}
|
||||||
|
interface HasModel {
|
||||||
|
+ getModel() : Optional<String>
|
||||||
|
}
|
||||||
|
interface HasParts {
|
||||||
|
+ getParts() : Stream<Part>
|
||||||
|
}
|
||||||
|
interface HasPrice {
|
||||||
|
+ getPrice() : Optional<Number>
|
||||||
|
}
|
||||||
|
interface HasType {
|
||||||
|
+ getType() : Optional<String>
|
||||||
|
}
|
||||||
|
class Part {
|
||||||
|
+ Part(properties : Map<String, Object>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.abstractdocument {
|
||||||
|
abstract class AbstractDocument {
|
||||||
|
- properties : Map<String, Object>
|
||||||
|
# AbstractDocument(properties : Map<String, Object>)
|
||||||
|
+ children(key : String, constructor : Function<Map<String, Object>, T>) : Stream<T>
|
||||||
|
+ get(key : String) : Object
|
||||||
|
+ put(key : String, value : Object)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface Document {
|
||||||
|
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
|
||||||
|
+ get(String) : Object {abstract}
|
||||||
|
+ put(String, Object) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractDocument ..|> Document
|
||||||
|
Car ..|> HasModel
|
||||||
|
Car ..|> HasPrice
|
||||||
|
Car ..|> HasParts
|
||||||
|
Car --|> AbstractDocument
|
||||||
|
HasModel --|> Document
|
||||||
|
HasParts --|> Document
|
||||||
|
HasPrice --|> Document
|
||||||
|
HasType --|> Document
|
||||||
|
Part ..|> HasType
|
||||||
|
Part ..|> HasModel
|
||||||
|
Part ..|> HasPrice
|
||||||
|
Part --|> AbstractDocument
|
||||||
|
@enduml
|
101
abstract-factory/etc/abstract-factory.urm.puml
Normal file
101
abstract-factory/etc/abstract-factory.urm.puml
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.abstractfactory {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- army : Army
|
||||||
|
- castle : Castle
|
||||||
|
- king : King
|
||||||
|
+ App()
|
||||||
|
+ createKingdom(factory : KingdomFactory)
|
||||||
|
+ getArmy() : Army
|
||||||
|
~ getArmy(factory : KingdomFactory) : Army
|
||||||
|
+ getCastle() : Castle
|
||||||
|
~ getCastle(factory : KingdomFactory) : Castle
|
||||||
|
+ getKing() : King
|
||||||
|
~ getKing(factory : KingdomFactory) : King
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- setArmy(army : Army)
|
||||||
|
- setCastle(castle : Castle)
|
||||||
|
- setKing(king : King)
|
||||||
|
}
|
||||||
|
class FactoryMaker {
|
||||||
|
+ FactoryMaker()
|
||||||
|
+ makeFactory(type : KingdomType) : KingdomFactory {static}
|
||||||
|
}
|
||||||
|
enum KingdomType {
|
||||||
|
+ ELF {static}
|
||||||
|
+ ORC {static}
|
||||||
|
+ valueOf(name : String) : KingdomType {static}
|
||||||
|
+ values() : KingdomType[] {static}
|
||||||
|
}
|
||||||
|
interface Army {
|
||||||
|
+ getDescription() : String {abstract}
|
||||||
|
}
|
||||||
|
interface Castle {
|
||||||
|
+ getDescription() : String {abstract}
|
||||||
|
}
|
||||||
|
class ElfArmy {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ ElfArmy()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class ElfCastle {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ ElfCastle()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class ElfKing {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ ElfKing()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class ElfKingdomFactory {
|
||||||
|
+ ElfKingdomFactory()
|
||||||
|
+ createArmy() : Army
|
||||||
|
+ createCastle() : Castle
|
||||||
|
+ createKing() : King
|
||||||
|
}
|
||||||
|
interface King {
|
||||||
|
+ getDescription() : String {abstract}
|
||||||
|
}
|
||||||
|
interface KingdomFactory {
|
||||||
|
+ createArmy() : Army {abstract}
|
||||||
|
+ createCastle() : Castle {abstract}
|
||||||
|
+ createKing() : King {abstract}
|
||||||
|
}
|
||||||
|
class OrcArmy {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ OrcArmy()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class OrcCastle {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ OrcCastle()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class OrcKing {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ OrcKing()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class OrcKingdomFactory {
|
||||||
|
+ OrcKingdomFactory()
|
||||||
|
+ createArmy() : Army
|
||||||
|
+ createCastle() : Castle
|
||||||
|
+ createKing() : King
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KingdomType ..+ FactoryMaker
|
||||||
|
App --> "-castle" Castle
|
||||||
|
FactoryMaker ..+ App
|
||||||
|
App --> "-king" King
|
||||||
|
App --> "-army" Army
|
||||||
|
ElfArmy ..|> Army
|
||||||
|
ElfCastle ..|> Castle
|
||||||
|
ElfKing ..|> King
|
||||||
|
ElfKingdomFactory ..|> KingdomFactory
|
||||||
|
OrcArmy ..|> Army
|
||||||
|
OrcCastle ..|> Castle
|
||||||
|
OrcKing ..|> King
|
||||||
|
OrcKingdomFactory ..|> KingdomFactory
|
||||||
|
@enduml
|
53
acyclic-visitor/etc/acyclic-visitor.urm.puml
Normal file
53
acyclic-visitor/etc/acyclic-visitor.urm.puml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.acyclicvisitor {
|
||||||
|
interface AllModemVisitor {
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class ConfigureForDosVisitor {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ ConfigureForDosVisitor()
|
||||||
|
+ visit(hayes : Hayes)
|
||||||
|
+ visit(zoom : Zoom)
|
||||||
|
}
|
||||||
|
class ConfigureForUnixVisitor {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ ConfigureForUnixVisitor()
|
||||||
|
+ visit(zoom : Zoom)
|
||||||
|
}
|
||||||
|
class Hayes {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Hayes()
|
||||||
|
+ accept(modemVisitor : ModemVisitor)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface HayesVisitor {
|
||||||
|
+ visit(Hayes) {abstract}
|
||||||
|
}
|
||||||
|
abstract class Modem {
|
||||||
|
+ Modem()
|
||||||
|
+ accept(ModemVisitor) {abstract}
|
||||||
|
}
|
||||||
|
interface ModemVisitor {
|
||||||
|
}
|
||||||
|
class Zoom {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Zoom()
|
||||||
|
+ accept(modemVisitor : ModemVisitor)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface ZoomVisitor {
|
||||||
|
+ visit(Zoom) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AllModemVisitor --|> ZoomVisitor
|
||||||
|
AllModemVisitor --|> HayesVisitor
|
||||||
|
ConfigureForDosVisitor ..|> AllModemVisitor
|
||||||
|
ConfigureForUnixVisitor ..|> ZoomVisitor
|
||||||
|
Hayes --|> Modem
|
||||||
|
HayesVisitor --|> ModemVisitor
|
||||||
|
Zoom --|> Modem
|
||||||
|
ZoomVisitor --|> ModemVisitor
|
||||||
|
@enduml
|
31
adapter/etc/adapter.urm.puml
Normal file
31
adapter/etc/adapter.urm.puml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.adapter {
|
||||||
|
class App {
|
||||||
|
- App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Captain {
|
||||||
|
- rowingBoat : RowingBoat
|
||||||
|
+ Captain()
|
||||||
|
+ Captain(boat : RowingBoat)
|
||||||
|
~ row()
|
||||||
|
~ setRowingBoat(boat : RowingBoat)
|
||||||
|
}
|
||||||
|
~class FishingBoat {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
~ FishingBoat()
|
||||||
|
~ sail()
|
||||||
|
}
|
||||||
|
class FishingBoatAdapter {
|
||||||
|
- boat : FishingBoat
|
||||||
|
+ FishingBoatAdapter()
|
||||||
|
+ row()
|
||||||
|
}
|
||||||
|
interface RowingBoat {
|
||||||
|
+ row() {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FishingBoatAdapter --> "-boat" FishingBoat
|
||||||
|
Captain --> "-rowingBoat" RowingBoat
|
||||||
|
FishingBoatAdapter ..|> RowingBoat
|
||||||
|
@enduml
|
@ -0,0 +1,43 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.aggregator.microservices {
|
||||||
|
class Aggregator {
|
||||||
|
- informationClient : ProductInformationClient
|
||||||
|
- inventoryClient : ProductInventoryClient
|
||||||
|
+ Aggregator()
|
||||||
|
+ getProduct() : Product
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Product {
|
||||||
|
- productInventories : int
|
||||||
|
- title : String
|
||||||
|
+ Product()
|
||||||
|
+ getProductInventories() : int
|
||||||
|
+ getTitle() : String
|
||||||
|
+ setProductInventories(productInventories : int)
|
||||||
|
+ setTitle(title : String)
|
||||||
|
}
|
||||||
|
interface ProductInformationClient {
|
||||||
|
+ getProductTitle() : String {abstract}
|
||||||
|
}
|
||||||
|
class ProductInformationClientImpl {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ ProductInformationClientImpl()
|
||||||
|
+ getProductTitle() : String
|
||||||
|
}
|
||||||
|
interface ProductInventoryClient {
|
||||||
|
+ getProductInventories() : Integer {abstract}
|
||||||
|
}
|
||||||
|
class ProductInventoryClientImpl {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ ProductInventoryClientImpl()
|
||||||
|
+ getProductInventories() : Integer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Aggregator --> "-informationClient" ProductInformationClient
|
||||||
|
Aggregator --> "-inventoryClient" ProductInventoryClient
|
||||||
|
ProductInformationClientImpl ..|> ProductInformationClient
|
||||||
|
ProductInventoryClientImpl ..|> ProductInventoryClient
|
||||||
|
@enduml
|
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
@ -0,0 +1,12 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.information.microservice {
|
||||||
|
class InformationApplication {
|
||||||
|
+ InformationApplication()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class InformationController {
|
||||||
|
+ InformationController()
|
||||||
|
+ getProductTitle() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
@ -0,0 +1,12 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.inventory.microservice {
|
||||||
|
class InventoryApplication {
|
||||||
|
+ InventoryApplication()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class InventoryController {
|
||||||
|
+ InventoryController()
|
||||||
|
+ getProductInventories() : int
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
47
ambassador/etc/ambassador.urm.puml
Normal file
47
ambassador/etc/ambassador.urm.puml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.ambassador.util {
|
||||||
|
interface RandomProvider {
|
||||||
|
+ random() : double {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.ambassador {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Client {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- serviceAmbassador : ServiceAmbassador
|
||||||
|
+ Client()
|
||||||
|
~ useService(value : int) : long
|
||||||
|
}
|
||||||
|
class RemoteService {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- THRESHOLD : int {static}
|
||||||
|
- randomProvider : RandomProvider
|
||||||
|
- service : RemoteService {static}
|
||||||
|
- RemoteService()
|
||||||
|
~ RemoteService(randomProvider : RandomProvider)
|
||||||
|
+ doRemoteFunction(value : int) : long
|
||||||
|
~ getRemoteService() : RemoteService {static}
|
||||||
|
}
|
||||||
|
~interface RemoteServiceInterface {
|
||||||
|
+ FAILURE : int {static}
|
||||||
|
+ doRemoteFunction(int) : long {abstract}
|
||||||
|
}
|
||||||
|
class ServiceAmbassador {
|
||||||
|
- DELAY_MS : int {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- RETRIES : int {static}
|
||||||
|
~ ServiceAmbassador()
|
||||||
|
- checkLatency(value : int) : long
|
||||||
|
+ doRemoteFunction(value : int) : long
|
||||||
|
- safeCall(value : int) : long
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RemoteService --> "-service" RemoteService
|
||||||
|
Client --> "-serviceAmbassador" ServiceAmbassador
|
||||||
|
RemoteService --> "-randomProvider" RandomProvider
|
||||||
|
RemoteService ..|> RemoteServiceInterface
|
||||||
|
ServiceAmbassador ..|> RemoteServiceInterface
|
||||||
|
@enduml
|
@ -0,0 +1,48 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.api.gateway {
|
||||||
|
class ApiGateway {
|
||||||
|
- imageClient : ImageClient
|
||||||
|
- priceClient : PriceClient
|
||||||
|
+ ApiGateway()
|
||||||
|
+ getProductDesktop() : DesktopProduct
|
||||||
|
+ getProductMobile() : MobileProduct
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class DesktopProduct {
|
||||||
|
- imagePath : String
|
||||||
|
- price : String
|
||||||
|
+ DesktopProduct()
|
||||||
|
+ getImagePath() : String
|
||||||
|
+ getPrice() : String
|
||||||
|
+ setImagePath(imagePath : String)
|
||||||
|
+ setPrice(price : String)
|
||||||
|
}
|
||||||
|
interface ImageClient {
|
||||||
|
+ getImagePath() : String {abstract}
|
||||||
|
}
|
||||||
|
class ImageClientImpl {
|
||||||
|
+ ImageClientImpl()
|
||||||
|
+ getImagePath() : String
|
||||||
|
}
|
||||||
|
class MobileProduct {
|
||||||
|
- price : String
|
||||||
|
+ MobileProduct()
|
||||||
|
+ getPrice() : String
|
||||||
|
+ setPrice(price : String)
|
||||||
|
}
|
||||||
|
interface PriceClient {
|
||||||
|
+ getPrice() : String {abstract}
|
||||||
|
}
|
||||||
|
class PriceClientImpl {
|
||||||
|
+ PriceClientImpl()
|
||||||
|
+ getPrice() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ApiGateway --> "-imageClient" ImageClient
|
||||||
|
ApiGateway --> "-priceClient" PriceClient
|
||||||
|
ImageClientImpl ..|> ImageClient
|
||||||
|
PriceClientImpl ..|> PriceClient
|
||||||
|
@enduml
|
2
api-gateway/etc/api-gateway.urm.puml
Normal file
2
api-gateway/etc/api-gateway.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
@ -0,0 +1,12 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.image.microservice {
|
||||||
|
class ImageApplication {
|
||||||
|
+ ImageApplication()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class ImageController {
|
||||||
|
+ ImageController()
|
||||||
|
+ getImagePath() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
@ -0,0 +1,12 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.price.microservice {
|
||||||
|
class PriceApplication {
|
||||||
|
+ PriceApplication()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class PriceController {
|
||||||
|
+ PriceController()
|
||||||
|
+ getPrice() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
51
async-method-invocation/etc/async-method-invocation.urm.puml
Normal file
51
async-method-invocation/etc/async-method-invocation.urm.puml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.async.method.invocation {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
- callback(name : String) : AsyncCallback<T> {static}
|
||||||
|
- lazyval(value : T, delayMillis : long) : Callable<T> {static}
|
||||||
|
- log(msg : String) {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface AsyncCallback<T> {
|
||||||
|
+ onComplete(T, Optional<Exception>) {abstract}
|
||||||
|
}
|
||||||
|
interface AsyncExecutor {
|
||||||
|
+ endProcess(AsyncResult<T>) : T {abstract}
|
||||||
|
+ startProcess(Callable<T>) : AsyncResult<T> {abstract}
|
||||||
|
+ startProcess(Callable<T>, AsyncCallback<T>) : AsyncResult<T> {abstract}
|
||||||
|
}
|
||||||
|
interface AsyncResult<T> {
|
||||||
|
+ await() {abstract}
|
||||||
|
+ getValue() : T {abstract}
|
||||||
|
+ isCompleted() : boolean {abstract}
|
||||||
|
}
|
||||||
|
class ThreadAsyncExecutor {
|
||||||
|
- idx : AtomicInteger
|
||||||
|
+ ThreadAsyncExecutor()
|
||||||
|
+ endProcess(asyncResult : AsyncResult<T>) : T
|
||||||
|
+ startProcess(task : Callable<T>) : AsyncResult<T>
|
||||||
|
+ startProcess(task : Callable<T>, callback : AsyncCallback<T>) : AsyncResult<T>
|
||||||
|
}
|
||||||
|
-class CompletableResult<T> {
|
||||||
|
~ COMPLETED : int {static}
|
||||||
|
~ FAILED : int {static}
|
||||||
|
~ RUNNING : int {static}
|
||||||
|
~ callback : Optional<AsyncCallback<T>>
|
||||||
|
~ exception : Exception
|
||||||
|
~ lock : Object
|
||||||
|
~ state : int
|
||||||
|
~ value : T
|
||||||
|
~ CompletableResult<T>(callback : AsyncCallback<T>)
|
||||||
|
+ await()
|
||||||
|
+ getValue() : T
|
||||||
|
+ isCompleted() : boolean
|
||||||
|
~ setException(exception : Exception)
|
||||||
|
~ setValue(value : T)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CompletableResult ..+ ThreadAsyncExecutor
|
||||||
|
ThreadAsyncExecutor ..|> AsyncExecutor
|
||||||
|
CompletableResult ..|> AsyncResult
|
||||||
|
@enduml
|
30
balking/etc/balking.urm.puml
Normal file
30
balking/etc/balking.urm.puml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.balking {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface DelayProvider {
|
||||||
|
+ executeAfterDelay(long, TimeUnit, Runnable) {abstract}
|
||||||
|
}
|
||||||
|
class WashingMachine {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- delayProvider : DelayProvider
|
||||||
|
- washingMachineState : WashingMachineState
|
||||||
|
+ WashingMachine()
|
||||||
|
+ WashingMachine(delayProvider : DelayProvider)
|
||||||
|
+ endOfWashing()
|
||||||
|
+ getWashingMachineState() : WashingMachineState
|
||||||
|
+ wash()
|
||||||
|
}
|
||||||
|
enum WashingMachineState {
|
||||||
|
+ ENABLED {static}
|
||||||
|
+ WASHING {static}
|
||||||
|
+ valueOf(name : String) : WashingMachineState {static}
|
||||||
|
+ values() : WashingMachineState[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WashingMachine --> "-washingMachineState" WashingMachineState
|
||||||
|
WashingMachine --> "-delayProvider" DelayProvider
|
||||||
|
@enduml
|
58
bridge/etc/bridge.urm.puml
Normal file
58
bridge/etc/bridge.urm.puml
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.bridge {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface Enchantment {
|
||||||
|
+ apply() {abstract}
|
||||||
|
+ onActivate() {abstract}
|
||||||
|
+ onDeactivate() {abstract}
|
||||||
|
}
|
||||||
|
class FlyingEnchantment {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ FlyingEnchantment()
|
||||||
|
+ apply()
|
||||||
|
+ onActivate()
|
||||||
|
+ onDeactivate()
|
||||||
|
}
|
||||||
|
class Hammer {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- enchantment : Enchantment
|
||||||
|
+ Hammer(enchantment : Enchantment)
|
||||||
|
+ getEnchantment() : Enchantment
|
||||||
|
+ swing()
|
||||||
|
+ unwield()
|
||||||
|
+ wield()
|
||||||
|
}
|
||||||
|
class SoulEatingEnchantment {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ SoulEatingEnchantment()
|
||||||
|
+ apply()
|
||||||
|
+ onActivate()
|
||||||
|
+ onDeactivate()
|
||||||
|
}
|
||||||
|
class Sword {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- enchantment : Enchantment
|
||||||
|
+ Sword(enchantment : Enchantment)
|
||||||
|
+ getEnchantment() : Enchantment
|
||||||
|
+ swing()
|
||||||
|
+ unwield()
|
||||||
|
+ wield()
|
||||||
|
}
|
||||||
|
interface Weapon {
|
||||||
|
+ getEnchantment() : Enchantment {abstract}
|
||||||
|
+ swing() {abstract}
|
||||||
|
+ unwield() {abstract}
|
||||||
|
+ wield() {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sword --> "-enchantment" Enchantment
|
||||||
|
Hammer --> "-enchantment" Enchantment
|
||||||
|
FlyingEnchantment ..|> Enchantment
|
||||||
|
Hammer ..|> Weapon
|
||||||
|
SoulEatingEnchantment ..|> Enchantment
|
||||||
|
Sword ..|> Weapon
|
||||||
|
@enduml
|
100
builder/etc/builder.urm.puml
Normal file
100
builder/etc/builder.urm.puml
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.builder {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
enum Armor {
|
||||||
|
+ CHAIN_MAIL {static}
|
||||||
|
+ CLOTHES {static}
|
||||||
|
+ LEATHER {static}
|
||||||
|
+ PLATE_MAIL {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Armor {static}
|
||||||
|
+ values() : Armor[] {static}
|
||||||
|
}
|
||||||
|
enum HairColor {
|
||||||
|
+ BLACK {static}
|
||||||
|
+ BLOND {static}
|
||||||
|
+ BROWN {static}
|
||||||
|
+ RED {static}
|
||||||
|
+ WHITE {static}
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : HairColor {static}
|
||||||
|
+ values() : HairColor[] {static}
|
||||||
|
}
|
||||||
|
enum HairType {
|
||||||
|
+ BALD {static}
|
||||||
|
+ CURLY {static}
|
||||||
|
+ LONG_CURLY {static}
|
||||||
|
+ LONG_STRAIGHT {static}
|
||||||
|
+ SHORT {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : HairType {static}
|
||||||
|
+ values() : HairType[] {static}
|
||||||
|
}
|
||||||
|
class Hero {
|
||||||
|
- armor : Armor
|
||||||
|
- hairColor : HairColor
|
||||||
|
- hairType : HairType
|
||||||
|
- name : String
|
||||||
|
- profession : Profession
|
||||||
|
- weapon : Weapon
|
||||||
|
- Hero(builder : Builder)
|
||||||
|
+ getArmor() : Armor
|
||||||
|
+ getHairColor() : HairColor
|
||||||
|
+ getHairType() : HairType
|
||||||
|
+ getName() : String
|
||||||
|
+ getProfession() : Profession
|
||||||
|
+ getWeapon() : Weapon
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Builder {
|
||||||
|
- armor : Armor
|
||||||
|
- hairColor : HairColor
|
||||||
|
- hairType : HairType
|
||||||
|
- name : String
|
||||||
|
- profession : Profession
|
||||||
|
- weapon : Weapon
|
||||||
|
+ Builder(profession : Profession, name : String)
|
||||||
|
+ build() : Hero
|
||||||
|
+ withArmor(armor : Armor) : Builder
|
||||||
|
+ withHairColor(hairColor : HairColor) : Builder
|
||||||
|
+ withHairType(hairType : HairType) : Builder
|
||||||
|
+ withWeapon(weapon : Weapon) : Builder
|
||||||
|
}
|
||||||
|
enum Profession {
|
||||||
|
+ MAGE {static}
|
||||||
|
+ PRIEST {static}
|
||||||
|
+ THIEF {static}
|
||||||
|
+ WARRIOR {static}
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Profession {static}
|
||||||
|
+ values() : Profession[] {static}
|
||||||
|
}
|
||||||
|
enum Weapon {
|
||||||
|
+ AXE {static}
|
||||||
|
+ BOW {static}
|
||||||
|
+ DAGGER {static}
|
||||||
|
+ SWORD {static}
|
||||||
|
+ WARHAMMER {static}
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Weapon {static}
|
||||||
|
+ values() : Weapon[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Hero --> "-profession" Profession
|
||||||
|
Builder ..+ Hero
|
||||||
|
Hero --> "-armor" Armor
|
||||||
|
Builder --> "-hairColor" HairColor
|
||||||
|
Builder --> "-weapon" Weapon
|
||||||
|
Builder --> "-hairType" HairType
|
||||||
|
Hero --> "-hairColor" HairColor
|
||||||
|
Builder --> "-profession" Profession
|
||||||
|
Hero --> "-weapon" Weapon
|
||||||
|
Hero --> "-hairType" HairType
|
||||||
|
Builder --> "-armor" Armor
|
||||||
|
@enduml
|
57
business-delegate/etc/business-delegate.urm.puml
Normal file
57
business-delegate/etc/business-delegate.urm.puml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.business.delegate {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class BusinessDelegate {
|
||||||
|
- businessService : BusinessService
|
||||||
|
- lookupService : BusinessLookup
|
||||||
|
- serviceType : ServiceType
|
||||||
|
+ BusinessDelegate()
|
||||||
|
+ doTask()
|
||||||
|
+ setLookupService(businessLookup : BusinessLookup)
|
||||||
|
+ setServiceType(serviceType : ServiceType)
|
||||||
|
}
|
||||||
|
class BusinessLookup {
|
||||||
|
- ejbService : EjbService
|
||||||
|
- jmsService : JmsService
|
||||||
|
+ BusinessLookup()
|
||||||
|
+ getBusinessService(serviceType : ServiceType) : BusinessService
|
||||||
|
+ setEjbService(ejbService : EjbService)
|
||||||
|
+ setJmsService(jmsService : JmsService)
|
||||||
|
}
|
||||||
|
interface BusinessService {
|
||||||
|
+ doProcessing() {abstract}
|
||||||
|
}
|
||||||
|
class Client {
|
||||||
|
- businessDelegate : BusinessDelegate
|
||||||
|
+ Client(businessDelegate : BusinessDelegate)
|
||||||
|
+ doTask()
|
||||||
|
}
|
||||||
|
class EjbService {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ EjbService()
|
||||||
|
+ doProcessing()
|
||||||
|
}
|
||||||
|
class JmsService {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ JmsService()
|
||||||
|
+ doProcessing()
|
||||||
|
}
|
||||||
|
enum ServiceType {
|
||||||
|
+ EJB {static}
|
||||||
|
+ JMS {static}
|
||||||
|
+ valueOf(name : String) : ServiceType {static}
|
||||||
|
+ values() : ServiceType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BusinessLookup --> "-ejbService" EjbService
|
||||||
|
BusinessDelegate --> "-serviceType" ServiceType
|
||||||
|
Client --> "-businessDelegate" BusinessDelegate
|
||||||
|
BusinessDelegate --> "-businessService" BusinessService
|
||||||
|
BusinessDelegate --> "-lookupService" BusinessLookup
|
||||||
|
BusinessLookup --> "-jmsService" JmsService
|
||||||
|
EjbService ..|> BusinessService
|
||||||
|
JmsService ..|> BusinessService
|
||||||
|
@enduml
|
69
bytecode/etc/bytecode.urm.puml
Normal file
69
bytecode/etc/bytecode.urm.puml
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.bytecode {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
- interpretInstruction(instruction : String, vm : VirtualMachine) {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
enum Instruction {
|
||||||
|
+ ADD {static}
|
||||||
|
+ DIVIDE {static}
|
||||||
|
+ GET_AGILITY {static}
|
||||||
|
+ GET_HEALTH {static}
|
||||||
|
+ GET_WISDOM {static}
|
||||||
|
+ LITERAL {static}
|
||||||
|
+ PLAY_SOUND {static}
|
||||||
|
+ SET_AGILITY {static}
|
||||||
|
+ SET_HEALTH {static}
|
||||||
|
+ SET_WISDOM {static}
|
||||||
|
+ SPAWN_PARTICLES {static}
|
||||||
|
- value : int
|
||||||
|
+ getInstruction(value : int) : Instruction {static}
|
||||||
|
+ getIntValue() : int
|
||||||
|
+ valueOf(name : String) : Instruction {static}
|
||||||
|
+ values() : Instruction[] {static}
|
||||||
|
}
|
||||||
|
class VirtualMachine {
|
||||||
|
- stack : Stack<Integer>
|
||||||
|
- wizards : Wizard[]
|
||||||
|
+ VirtualMachine()
|
||||||
|
+ execute(bytecode : int[])
|
||||||
|
+ getAgility(wizard : int) : int
|
||||||
|
+ getHealth(wizard : int) : int
|
||||||
|
+ getStack() : Stack<Integer>
|
||||||
|
+ getWisdom(wizard : int) : int
|
||||||
|
+ getWizards() : Wizard[]
|
||||||
|
+ setAgility(wizard : int, amount : int)
|
||||||
|
+ setHealth(wizard : int, amount : int)
|
||||||
|
+ setWisdom(wizard : int, amount : int)
|
||||||
|
}
|
||||||
|
class Wizard {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- agility : int
|
||||||
|
- health : int
|
||||||
|
- numberOfPlayedSounds : int
|
||||||
|
- numberOfSpawnedParticles : int
|
||||||
|
- wisdom : int
|
||||||
|
+ Wizard()
|
||||||
|
+ getAgility() : int
|
||||||
|
+ getHealth() : int
|
||||||
|
+ getNumberOfPlayedSounds() : int
|
||||||
|
+ getNumberOfSpawnedParticles() : int
|
||||||
|
+ getWisdom() : int
|
||||||
|
+ playSound()
|
||||||
|
+ setAgility(agility : int)
|
||||||
|
+ setHealth(health : int)
|
||||||
|
+ setWisdom(wisdom : int)
|
||||||
|
+ spawnParticles()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.bytecode.util {
|
||||||
|
class InstructionConverterUtil {
|
||||||
|
+ InstructionConverterUtil()
|
||||||
|
+ convertToByteCode(instructions : String) : int[] {static}
|
||||||
|
- isValidInstruction(instruction : String) : boolean {static}
|
||||||
|
- isValidInt(value : String) : boolean {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
119
caching/etc/caching.urm.puml
Normal file
119
caching/etc/caching.urm.puml
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.caching.constants {
|
||||||
|
class CachingConstants {
|
||||||
|
+ ADD_INFO : String {static}
|
||||||
|
+ USER_ACCOUNT : String {static}
|
||||||
|
+ USER_ID : String {static}
|
||||||
|
+ USER_NAME : String {static}
|
||||||
|
+ CachingConstants()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.caching {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
+ useCacheAsideStategy()
|
||||||
|
+ useReadAndWriteThroughStrategy()
|
||||||
|
+ useReadThroughAndWriteAroundStrategy()
|
||||||
|
+ useReadThroughAndWriteBehindStrategy()
|
||||||
|
}
|
||||||
|
class AppManager {
|
||||||
|
- cachingPolicy : CachingPolicy {static}
|
||||||
|
- AppManager()
|
||||||
|
+ find(userId : String) : UserAccount {static}
|
||||||
|
- findAside(userId : String) : UserAccount {static}
|
||||||
|
+ initCacheCapacity(capacity : int) {static}
|
||||||
|
+ initCachingPolicy(policy : CachingPolicy) {static}
|
||||||
|
+ initDb(useMongoDb : boolean) {static}
|
||||||
|
+ printCacheContent() : String {static}
|
||||||
|
+ save(userAccount : UserAccount) {static}
|
||||||
|
- saveAside(userAccount : UserAccount) {static}
|
||||||
|
}
|
||||||
|
class CacheStore {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- cache : LruCache {static}
|
||||||
|
- CacheStore()
|
||||||
|
+ clearCache() {static}
|
||||||
|
+ flushCache() {static}
|
||||||
|
+ get(userId : String) : UserAccount {static}
|
||||||
|
+ initCapacity(capacity : int) {static}
|
||||||
|
+ invalidate(userId : String) {static}
|
||||||
|
+ print() : String {static}
|
||||||
|
+ readThrough(userId : String) : UserAccount {static}
|
||||||
|
+ readThroughWithWriteBackPolicy(userId : String) : UserAccount {static}
|
||||||
|
+ set(userId : String, userAccount : UserAccount) {static}
|
||||||
|
+ writeAround(userAccount : UserAccount) {static}
|
||||||
|
+ writeBehind(userAccount : UserAccount) {static}
|
||||||
|
+ writeThrough(userAccount : UserAccount) {static}
|
||||||
|
}
|
||||||
|
enum CachingPolicy {
|
||||||
|
+ AROUND {static}
|
||||||
|
+ ASIDE {static}
|
||||||
|
+ BEHIND {static}
|
||||||
|
+ THROUGH {static}
|
||||||
|
- policy : String
|
||||||
|
+ getPolicy() : String
|
||||||
|
+ valueOf(name : String) : CachingPolicy {static}
|
||||||
|
+ values() : CachingPolicy[] {static}
|
||||||
|
}
|
||||||
|
class DbManager {
|
||||||
|
- db : MongoDatabase {static}
|
||||||
|
- mongoClient : MongoClient {static}
|
||||||
|
- useMongoDB : boolean {static}
|
||||||
|
- virtualDB : Map<String, UserAccount> {static}
|
||||||
|
- DbManager()
|
||||||
|
+ connect() {static}
|
||||||
|
+ createVirtualDb() {static}
|
||||||
|
+ readFromDb(userId : String) : UserAccount {static}
|
||||||
|
+ updateDb(userAccount : UserAccount) {static}
|
||||||
|
+ upsertDb(userAccount : UserAccount) {static}
|
||||||
|
+ writeToDb(userAccount : UserAccount) {static}
|
||||||
|
}
|
||||||
|
class LruCache {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
~ cache : Map<String, Node>
|
||||||
|
~ capacity : int
|
||||||
|
~ end : Node
|
||||||
|
~ head : Node
|
||||||
|
+ LruCache(capacity : int)
|
||||||
|
+ clear()
|
||||||
|
+ contains(userId : String) : boolean
|
||||||
|
+ get(userId : String) : UserAccount
|
||||||
|
+ getCacheDataInListForm() : List<UserAccount>
|
||||||
|
+ getLruData() : UserAccount
|
||||||
|
+ invalidate(userId : String)
|
||||||
|
+ isFull() : boolean
|
||||||
|
+ remove(node : Node)
|
||||||
|
+ set(userId : String, userAccount : UserAccount)
|
||||||
|
+ setCapacity(newCapacity : int)
|
||||||
|
+ setHead(node : Node)
|
||||||
|
}
|
||||||
|
~class Node {
|
||||||
|
~ next : Node
|
||||||
|
~ previous : Node
|
||||||
|
~ userAccount : UserAccount
|
||||||
|
~ userId : String
|
||||||
|
+ Node(this$0 : String, userId : UserAccount)
|
||||||
|
}
|
||||||
|
class UserAccount {
|
||||||
|
- additionalInfo : String
|
||||||
|
- userId : String
|
||||||
|
- userName : String
|
||||||
|
+ UserAccount(userId : String, userName : String, additionalInfo : String)
|
||||||
|
+ getAdditionalInfo() : String
|
||||||
|
+ getUserId() : String
|
||||||
|
+ getUserName() : String
|
||||||
|
+ setAdditionalInfo(additionalInfo : String)
|
||||||
|
+ setUserId(userId : String)
|
||||||
|
+ setUserName(userName : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Node --+ LruCache
|
||||||
|
LruCache --> "-head" Node
|
||||||
|
Node --> "-previous" Node
|
||||||
|
AppManager --> "-cachingPolicy" CachingPolicy
|
||||||
|
Node --> "-userAccount" UserAccount
|
||||||
|
CacheStore --> "-cache" LruCache
|
||||||
|
@enduml
|
28
callback/etc/callback.urm.puml
Normal file
28
callback/etc/callback.urm.puml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.callback {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface Callback {
|
||||||
|
+ call() {abstract}
|
||||||
|
}
|
||||||
|
class LambdasApp {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- LambdasApp()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class SimpleTask {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ SimpleTask()
|
||||||
|
+ execute()
|
||||||
|
}
|
||||||
|
abstract class Task {
|
||||||
|
+ Task()
|
||||||
|
+ execute() {abstract}
|
||||||
|
~ executeWith(callback : Callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SimpleTask --|> Task
|
||||||
|
@enduml
|
61
chain/etc/chain.urm.puml
Normal file
61
chain/etc/chain.urm.puml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.chain {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class OrcCommander {
|
||||||
|
+ OrcCommander(handler : RequestHandler)
|
||||||
|
+ handleRequest(req : Request)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class OrcKing {
|
||||||
|
- chain : RequestHandler
|
||||||
|
+ OrcKing()
|
||||||
|
- buildChain()
|
||||||
|
+ makeRequest(req : Request)
|
||||||
|
}
|
||||||
|
class OrcOfficer {
|
||||||
|
+ OrcOfficer(handler : RequestHandler)
|
||||||
|
+ handleRequest(req : Request)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class OrcSoldier {
|
||||||
|
+ OrcSoldier(handler : RequestHandler)
|
||||||
|
+ handleRequest(req : Request)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Request {
|
||||||
|
- handled : boolean
|
||||||
|
- requestDescription : String
|
||||||
|
- requestType : RequestType
|
||||||
|
+ Request(requestType : RequestType, requestDescription : String)
|
||||||
|
+ getRequestDescription() : String
|
||||||
|
+ getRequestType() : RequestType
|
||||||
|
+ isHandled() : boolean
|
||||||
|
+ markHandled()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
abstract class RequestHandler {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- next : RequestHandler
|
||||||
|
+ RequestHandler(next : RequestHandler)
|
||||||
|
+ handleRequest(req : Request)
|
||||||
|
# printHandling(req : Request)
|
||||||
|
+ toString() : String {abstract}
|
||||||
|
}
|
||||||
|
enum RequestType {
|
||||||
|
+ COLLECT_TAX {static}
|
||||||
|
+ DEFEND_CASTLE {static}
|
||||||
|
+ TORTURE_PRISONER {static}
|
||||||
|
+ valueOf(name : String) : RequestType {static}
|
||||||
|
+ values() : RequestType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OrcKing --> "-chain" RequestHandler
|
||||||
|
RequestHandler --> "-next" RequestHandler
|
||||||
|
Request --> "-requestType" RequestType
|
||||||
|
OrcCommander --|> RequestHandler
|
||||||
|
OrcOfficer --|> RequestHandler
|
||||||
|
OrcSoldier --|> RequestHandler
|
||||||
|
@enduml
|
44
circuit-breaker/etc/circuit-breaker.urm.puml
Normal file
44
circuit-breaker/etc/circuit-breaker.urm.puml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.circuitbreaker {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class CircuitBreaker {
|
||||||
|
~ failureCount : int
|
||||||
|
- failureThreshold : int
|
||||||
|
- futureTime : long
|
||||||
|
~ lastFailureTime : long
|
||||||
|
- retryTimePeriod : long
|
||||||
|
- state : State
|
||||||
|
- timeout : long
|
||||||
|
~ CircuitBreaker(timeout : long, failureThreshold : int, retryTimePeriod : long)
|
||||||
|
+ call(serviceToCall : String, serverStartTime : long) : String
|
||||||
|
+ getState() : String
|
||||||
|
- recordFailure()
|
||||||
|
- reset()
|
||||||
|
# setState()
|
||||||
|
+ setStateForBypass(state : State)
|
||||||
|
}
|
||||||
|
class DelayedService {
|
||||||
|
- delay : int
|
||||||
|
+ DelayedService()
|
||||||
|
+ DelayedService(delay : int)
|
||||||
|
+ response(serverStartTime : long) : String
|
||||||
|
}
|
||||||
|
class MonitoringService {
|
||||||
|
+ MonitoringService()
|
||||||
|
+ localResourceResponse() : String
|
||||||
|
+ remoteResourceResponse(circuitBreaker : CircuitBreaker, serverStartTime : long) : String
|
||||||
|
}
|
||||||
|
enum State {
|
||||||
|
+ CLOSED {static}
|
||||||
|
+ HALF_OPEN {static}
|
||||||
|
+ OPEN {static}
|
||||||
|
+ valueOf(name : String) : State {static}
|
||||||
|
+ values() : State[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CircuitBreaker --> "-state" State
|
||||||
|
@enduml
|
52
collection-pipeline/etc/collection-pipeline.urm.puml
Normal file
52
collection-pipeline/etc/collection-pipeline.urm.puml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.collectionpipeline {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Car {
|
||||||
|
- category : Category
|
||||||
|
- make : String
|
||||||
|
- model : String
|
||||||
|
- year : int
|
||||||
|
+ Car(make : String, model : String, yearOfMake : int, category : Category)
|
||||||
|
+ equals(obj : Object) : boolean
|
||||||
|
+ getCategory() : Category
|
||||||
|
+ getMake() : String
|
||||||
|
+ getModel() : String
|
||||||
|
+ getYear() : int
|
||||||
|
+ hashCode() : int
|
||||||
|
}
|
||||||
|
class CarFactory {
|
||||||
|
- CarFactory()
|
||||||
|
+ createCars() : List<Car> {static}
|
||||||
|
}
|
||||||
|
enum Category {
|
||||||
|
+ CONVERTIBLE {static}
|
||||||
|
+ JEEP {static}
|
||||||
|
+ SEDAN {static}
|
||||||
|
+ valueOf(name : String) : Category {static}
|
||||||
|
+ values() : Category[] {static}
|
||||||
|
}
|
||||||
|
class FunctionalProgramming {
|
||||||
|
- FunctionalProgramming()
|
||||||
|
+ getGroupingOfCarsByCategory(cars : List<Car>) : Map<Category, List<Car>> {static}
|
||||||
|
+ getModelsAfter2000(cars : List<Car>) : List<String> {static}
|
||||||
|
+ getSedanCarsOwnedSortedByDate(persons : List<Person>) : List<Car> {static}
|
||||||
|
}
|
||||||
|
class ImperativeProgramming {
|
||||||
|
- ImperativeProgramming()
|
||||||
|
+ getGroupingOfCarsByCategory(cars : List<Car>) : Map<Category, List<Car>> {static}
|
||||||
|
+ getModelsAfter2000(cars : List<Car>) : List<String> {static}
|
||||||
|
+ getSedanCarsOwnedSortedByDate(persons : List<Person>) : List<Car> {static}
|
||||||
|
}
|
||||||
|
class Person {
|
||||||
|
- cars : List<Car>
|
||||||
|
+ Person(cars : List<Car>)
|
||||||
|
+ getCars() : List<Car>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Person --> "-cars" Car
|
||||||
|
Car --> "-category" Category
|
||||||
|
@enduml
|
26
combinator/etc/combinator.urm.puml
Normal file
26
combinator/etc/combinator.urm.puml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.combinator {
|
||||||
|
class CombinatorApp {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ CombinatorApp()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- text() : String {static}
|
||||||
|
}
|
||||||
|
interface Finder {
|
||||||
|
+ and(andFinder : Finder) : Finder
|
||||||
|
+ contains(word : String) : Finder {static}
|
||||||
|
+ find(String) : List<String> {abstract}
|
||||||
|
+ not(notFinder : Finder) : Finder
|
||||||
|
+ or(orFinder : Finder) : Finder
|
||||||
|
}
|
||||||
|
class Finders {
|
||||||
|
- Finders()
|
||||||
|
+ advancedFinder(query : String, orQuery : String, notQuery : String) : Finder {static}
|
||||||
|
+ expandedFinder(queries : String[]) : Finder {static}
|
||||||
|
+ filteredFinder(query : String, excludeQueries : String[]) : Finder {static}
|
||||||
|
- identMult() : Finder {static}
|
||||||
|
- identSum() : Finder {static}
|
||||||
|
+ specializedFinder(queries : String[]) : Finder {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
83
command/etc/command.urm.puml
Normal file
83
command/etc/command.urm.puml
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.command {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
abstract class Command {
|
||||||
|
+ Command()
|
||||||
|
+ execute(Target) {abstract}
|
||||||
|
+ redo() {abstract}
|
||||||
|
+ toString() : String {abstract}
|
||||||
|
+ undo() {abstract}
|
||||||
|
}
|
||||||
|
class Goblin {
|
||||||
|
+ Goblin()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class InvisibilitySpell {
|
||||||
|
- target : Target
|
||||||
|
+ InvisibilitySpell()
|
||||||
|
+ execute(target : Target)
|
||||||
|
+ redo()
|
||||||
|
+ toString() : String
|
||||||
|
+ undo()
|
||||||
|
}
|
||||||
|
class ShrinkSpell {
|
||||||
|
- oldSize : Size
|
||||||
|
- target : Target
|
||||||
|
+ ShrinkSpell()
|
||||||
|
+ execute(target : Target)
|
||||||
|
+ redo()
|
||||||
|
+ toString() : String
|
||||||
|
+ undo()
|
||||||
|
}
|
||||||
|
enum Size {
|
||||||
|
+ NORMAL {static}
|
||||||
|
+ SMALL {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Size {static}
|
||||||
|
+ values() : Size[] {static}
|
||||||
|
}
|
||||||
|
abstract class Target {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- size : Size
|
||||||
|
- visibility : Visibility
|
||||||
|
+ Target()
|
||||||
|
+ getSize() : Size
|
||||||
|
+ getVisibility() : Visibility
|
||||||
|
+ printStatus()
|
||||||
|
+ setSize(size : Size)
|
||||||
|
+ setVisibility(visibility : Visibility)
|
||||||
|
+ toString() : String {abstract}
|
||||||
|
}
|
||||||
|
enum Visibility {
|
||||||
|
+ INVISIBLE {static}
|
||||||
|
+ VISIBLE {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Visibility {static}
|
||||||
|
+ values() : Visibility[] {static}
|
||||||
|
}
|
||||||
|
class Wizard {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- redoStack : Deque<Command>
|
||||||
|
- undoStack : Deque<Command>
|
||||||
|
+ Wizard()
|
||||||
|
+ castSpell(command : Command, target : Target)
|
||||||
|
+ redoLastSpell()
|
||||||
|
+ toString() : String
|
||||||
|
+ undoLastSpell()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Target --> "-size" Size
|
||||||
|
Wizard --> "-undoStack" Command
|
||||||
|
ShrinkSpell --> "-oldSize" Size
|
||||||
|
InvisibilitySpell --> "-target" Target
|
||||||
|
ShrinkSpell --> "-target" Target
|
||||||
|
Target --> "-visibility" Visibility
|
||||||
|
Goblin --|> Target
|
||||||
|
InvisibilitySpell --|> Command
|
||||||
|
ShrinkSpell --|> Command
|
||||||
|
@enduml
|
329
commander/etc/commander.urm.puml
Normal file
329
commander/etc/commander.urm.puml
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.commander.queue {
|
||||||
|
class Queue<T> {
|
||||||
|
- front : Queue.Node<T>
|
||||||
|
- rear : Queue.Node<T>
|
||||||
|
- size : int
|
||||||
|
~ Queue<T>()
|
||||||
|
~ dequeue() : T
|
||||||
|
~ enqueue(obj : T)
|
||||||
|
~ isEmpty() : boolean
|
||||||
|
~ peek() : T
|
||||||
|
}
|
||||||
|
~class Node<V> {
|
||||||
|
~ next : Queue.Node<V>
|
||||||
|
~ value : V
|
||||||
|
~ Node<V>(obj : V, b : Queue.Node<V>)
|
||||||
|
}
|
||||||
|
class QueueDatabase {
|
||||||
|
- data : Queue<QueueTask>
|
||||||
|
+ exceptionsList : List<Exception>
|
||||||
|
+ QueueDatabase(exc : Exception[])
|
||||||
|
+ add(t : QueueTask) : QueueTask
|
||||||
|
+ dequeue() : QueueTask
|
||||||
|
+ get(taskId : String) : QueueTask
|
||||||
|
+ peek() : QueueTask
|
||||||
|
}
|
||||||
|
class QueueTask {
|
||||||
|
+ firstAttemptTime : long
|
||||||
|
+ messageType : int
|
||||||
|
+ order : Order
|
||||||
|
+ taskType : TaskType
|
||||||
|
+ QueueTask(o : Order, t : TaskType, messageType : int)
|
||||||
|
+ getType() : String
|
||||||
|
}
|
||||||
|
enum TaskType {
|
||||||
|
+ EmployeeDb {static}
|
||||||
|
+ Messaging {static}
|
||||||
|
+ Payment {static}
|
||||||
|
+ valueOf(name : String) : TaskType {static}
|
||||||
|
+ values() : TaskType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.commander.messagingservice {
|
||||||
|
class MessagingDatabase {
|
||||||
|
- data : Hashtable<String, MessageRequest>
|
||||||
|
+ MessagingDatabase()
|
||||||
|
+ add(r : MessageRequest) : MessageRequest
|
||||||
|
+ get(requestId : String) : MessageRequest
|
||||||
|
}
|
||||||
|
class MessagingService {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ MessagingService(db : MessagingDatabase, exc : Exception[])
|
||||||
|
+ receiveRequest(parameters : Object[]) : String
|
||||||
|
~ sendMessage(m : MessageToSend) : String
|
||||||
|
# updateDb(parameters : Object[]) : String
|
||||||
|
}
|
||||||
|
~class MessageRequest {
|
||||||
|
~ msg : MessageToSend
|
||||||
|
~ reqId : String
|
||||||
|
~ MessageRequest(this$0 : String, reqId : MessageToSend)
|
||||||
|
}
|
||||||
|
~enum MessageToSend {
|
||||||
|
+ PaymentFail {static}
|
||||||
|
+ PaymentSuccessful {static}
|
||||||
|
+ PaymentTrying {static}
|
||||||
|
+ valueOf(name : String) : MessageToSend {static}
|
||||||
|
+ values() : MessageToSend[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.commander {
|
||||||
|
class AppEmployeeDbFailCases {
|
||||||
|
- employeeTime : long
|
||||||
|
- messageTime : long
|
||||||
|
- numOfRetries : int
|
||||||
|
- paymentTime : long
|
||||||
|
- queueTaskTime : long
|
||||||
|
- queueTime : long
|
||||||
|
- retryDuration : long
|
||||||
|
+ AppEmployeeDbFailCases()
|
||||||
|
~ employeeDatabaseUnavailableCase()
|
||||||
|
~ employeeDbSuccessCase()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class AppMessagingFailCases {
|
||||||
|
- employeeTime : long
|
||||||
|
- messageTime : long
|
||||||
|
- numOfRetries : int
|
||||||
|
- paymentTime : long
|
||||||
|
- queueTaskTime : long
|
||||||
|
- queueTime : long
|
||||||
|
- retryDuration : long
|
||||||
|
+ AppMessagingFailCases()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
~ messagingDatabaseUnavailableCasePaymentError()
|
||||||
|
~ messagingDatabaseUnavailableCasePaymentFailure()
|
||||||
|
~ messagingDatabaseUnavailableCasePaymentSuccess()
|
||||||
|
~ messagingSuccessCase()
|
||||||
|
}
|
||||||
|
class AppPaymentFailCases {
|
||||||
|
- employeeTime : long
|
||||||
|
- messageTime : long
|
||||||
|
- numOfRetries : int
|
||||||
|
- paymentTime : long
|
||||||
|
- queueTaskTime : long
|
||||||
|
- queueTime : long
|
||||||
|
- retryDuration : long
|
||||||
|
+ AppPaymentFailCases()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
~ paymentDatabaseUnavailableCase()
|
||||||
|
~ paymentNotPossibleCase()
|
||||||
|
~ paymentSuccessCase()
|
||||||
|
}
|
||||||
|
class AppQueueFailCases {
|
||||||
|
- employeeTime : long
|
||||||
|
- messageTime : long
|
||||||
|
- numOfRetries : int
|
||||||
|
- paymentTime : long
|
||||||
|
- queueTaskTime : long
|
||||||
|
- queueTime : long
|
||||||
|
- retryDuration : long
|
||||||
|
+ AppQueueFailCases()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
~ queueEmployeeDbTaskDatabaseUnavailableCase()
|
||||||
|
~ queueMessageTaskDatabaseUnavailableCase()
|
||||||
|
~ queuePaymentTaskDatabaseUnavailableCase()
|
||||||
|
~ queueSuccessCase()
|
||||||
|
}
|
||||||
|
class AppShippingFailCases {
|
||||||
|
- employeeTime : long
|
||||||
|
- messageTime : long
|
||||||
|
- numOfRetries : int
|
||||||
|
- paymentTime : long
|
||||||
|
- queueTaskTime : long
|
||||||
|
- queueTime : long
|
||||||
|
- retryDuration : long
|
||||||
|
+ AppShippingFailCases()
|
||||||
|
~ itemUnavailableCase()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
~ shippingDatabaseUnavailableCase()
|
||||||
|
~ shippingNotPossibleCase()
|
||||||
|
~ shippingSuccessCase()
|
||||||
|
}
|
||||||
|
class Commander {
|
||||||
|
- LOG : Logger {static}
|
||||||
|
- employeeDb : EmployeeHandle
|
||||||
|
- employeeTime : long
|
||||||
|
- finalSiteMsgShown : boolean
|
||||||
|
- messageTime : long
|
||||||
|
- messagingService : MessagingService
|
||||||
|
- numOfRetries : int
|
||||||
|
- paymentService : PaymentService
|
||||||
|
- paymentTime : long
|
||||||
|
- queue : QueueDatabase
|
||||||
|
- queueItems : int
|
||||||
|
- queueTaskTime : long
|
||||||
|
- queueTime : long
|
||||||
|
- retryDuration : long
|
||||||
|
- shippingService : ShippingService
|
||||||
|
~ Commander(empDb : EmployeeHandle, paymentService : PaymentService, shippingService : ShippingService, messagingService : MessagingService, qdb : QueueDatabase, numOfRetries : int, retryDuration : long, queueTime : long, queueTaskTime : long, paymentTime : long, messageTime : long, employeeTime : long)
|
||||||
|
- doTasksInQueue()
|
||||||
|
- employeeHandleIssue(order : Order)
|
||||||
|
~ placeOrder(order : Order)
|
||||||
|
- sendPaymentFailureMessage(order : Order)
|
||||||
|
- sendPaymentPossibleErrorMsg(order : Order)
|
||||||
|
- sendPaymentRequest(order : Order)
|
||||||
|
- sendShippingRequest(order : Order)
|
||||||
|
- sendSuccessMessage(order : Order)
|
||||||
|
- tryDequeue()
|
||||||
|
- tryDoingTasksInQueue()
|
||||||
|
- updateQueue(qt : QueueTask)
|
||||||
|
}
|
||||||
|
abstract class Database<T> {
|
||||||
|
+ Database<T>()
|
||||||
|
+ add(T) : T {abstract}
|
||||||
|
+ get(String) : T {abstract}
|
||||||
|
}
|
||||||
|
class Order {
|
||||||
|
- ALL_CHARS : String {static}
|
||||||
|
- RANDOM : Random {static}
|
||||||
|
- USED_IDS : Hashtable<String, Boolean> {static}
|
||||||
|
~ addedToEmployeeHandle : boolean
|
||||||
|
~ createdTime : long
|
||||||
|
+ id : String
|
||||||
|
~ item : String
|
||||||
|
~ messageSent : MessageSent
|
||||||
|
~ paid : PaymentStatus
|
||||||
|
~ price : float
|
||||||
|
~ user : User
|
||||||
|
~ Order(user : User, item : String, price : float)
|
||||||
|
- createUniqueId() : String
|
||||||
|
}
|
||||||
|
~enum MessageSent {
|
||||||
|
+ NoneSent {static}
|
||||||
|
+ PaymentFail {static}
|
||||||
|
+ PaymentSuccessful {static}
|
||||||
|
+ PaymentTrying {static}
|
||||||
|
+ valueOf(name : String) : MessageSent {static}
|
||||||
|
+ values() : MessageSent[] {static}
|
||||||
|
}
|
||||||
|
~enum PaymentStatus {
|
||||||
|
+ Done {static}
|
||||||
|
+ NotDone {static}
|
||||||
|
+ Trying {static}
|
||||||
|
+ valueOf(name : String) : PaymentStatus {static}
|
||||||
|
+ values() : PaymentStatus[] {static}
|
||||||
|
}
|
||||||
|
class Retry<T> {
|
||||||
|
- RANDOM : Random {static}
|
||||||
|
- attempts : AtomicInteger
|
||||||
|
- errors : List<Exception>
|
||||||
|
- handleError : Retry.HandleErrorIssue<T>
|
||||||
|
- maxAttempts : int
|
||||||
|
- maxDelay : long
|
||||||
|
- op : Operation
|
||||||
|
- test : Predicate<Exception>
|
||||||
|
~ Retry<T>(op : Operation, handleError : Retry.HandleErrorIssue<T>, maxAttempts : int, maxDelay : long, ignoreTests : Predicate<Exception>[])
|
||||||
|
+ perform(list : List<Exception>, obj : T)
|
||||||
|
}
|
||||||
|
interface HandleErrorIssue<T> {
|
||||||
|
+ handleIssue(T, Exception) {abstract}
|
||||||
|
}
|
||||||
|
interface Operation {
|
||||||
|
+ operation(List<Exception>) {abstract}
|
||||||
|
}
|
||||||
|
abstract class Service {
|
||||||
|
- ALL_CHARS : String {static}
|
||||||
|
- RANDOM : Random {static}
|
||||||
|
- USED_IDS : Hashtable<String, Boolean> {static}
|
||||||
|
# database : Database<T>
|
||||||
|
+ exceptionsList : ArrayList<Exception>
|
||||||
|
# Service(db : Database<T>, exc : Exception[])
|
||||||
|
# generateId() : String
|
||||||
|
+ receiveRequest(Object[]) : String {abstract}
|
||||||
|
# updateDb(Object[]) : String {abstract}
|
||||||
|
}
|
||||||
|
class User {
|
||||||
|
~ address : String
|
||||||
|
~ name : String
|
||||||
|
~ User(name : String, address : String)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.commander.shippingservice {
|
||||||
|
class ShippingDatabase {
|
||||||
|
- data : Hashtable<String, ShippingRequest>
|
||||||
|
+ ShippingDatabase()
|
||||||
|
+ add(r : ShippingRequest) : ShippingRequest
|
||||||
|
+ get(trasnactionId : String) : ShippingRequest
|
||||||
|
}
|
||||||
|
class ShippingService {
|
||||||
|
+ ShippingService(db : ShippingDatabase, exc : Exception[])
|
||||||
|
+ receiveRequest(parameters : Object[]) : String
|
||||||
|
# updateDb(parameters : Object[]) : String
|
||||||
|
}
|
||||||
|
~class ShippingRequest {
|
||||||
|
~ address : String
|
||||||
|
~ item : String
|
||||||
|
~ transactionId : String
|
||||||
|
~ ShippingRequest(transactionId : String, item : String, address : String)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.commander.paymentservice {
|
||||||
|
class PaymentDatabase {
|
||||||
|
- data : Hashtable<String, PaymentRequest>
|
||||||
|
+ PaymentDatabase()
|
||||||
|
+ add(r : PaymentRequest) : PaymentRequest
|
||||||
|
+ get(requestId : String) : PaymentRequest
|
||||||
|
}
|
||||||
|
class PaymentService {
|
||||||
|
+ PaymentService(db : PaymentDatabase, exc : Exception[])
|
||||||
|
+ receiveRequest(parameters : Object[]) : String
|
||||||
|
# updateDb(parameters : Object[]) : String
|
||||||
|
}
|
||||||
|
~class PaymentRequest {
|
||||||
|
~ paid : boolean
|
||||||
|
~ payment : float
|
||||||
|
~ transactionId : String
|
||||||
|
~ PaymentRequest(this$0 : String, transactionId : float)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.commander.employeehandle {
|
||||||
|
class EmployeeDatabase {
|
||||||
|
- data : Hashtable<String, Order>
|
||||||
|
+ EmployeeDatabase()
|
||||||
|
+ add(o : Order) : Order
|
||||||
|
+ get(orderId : String) : Order
|
||||||
|
}
|
||||||
|
class EmployeeHandle {
|
||||||
|
+ EmployeeHandle(db : EmployeeDatabase, exc : Exception[])
|
||||||
|
+ receiveRequest(parameters : Object[]) : String
|
||||||
|
# updateDb(parameters : Object[]) : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Order --> "-messageSent" MessageSent
|
||||||
|
MessageSent ..+ Order
|
||||||
|
MessageToSend ..+ MessagingService
|
||||||
|
Retry --> "-op" Operation
|
||||||
|
Operation ..+ Retry
|
||||||
|
Service --> "-database" Database
|
||||||
|
Node --> "-next" Node
|
||||||
|
PaymentRequest --+ PaymentService
|
||||||
|
Commander --> "-messagingService" MessagingService
|
||||||
|
ShippingRequest ..+ ShippingService
|
||||||
|
Commander --> "-shippingService" ShippingService
|
||||||
|
Commander --> "-paymentService" PaymentService
|
||||||
|
MessageRequest --+ MessagingService
|
||||||
|
Commander --> "-employeeDb" EmployeeHandle
|
||||||
|
HandleErrorIssue ..+ Retry
|
||||||
|
Retry --> "-handleError" HandleErrorIssue
|
||||||
|
QueueTask --> "-taskType" TaskType
|
||||||
|
TaskType ..+ QueueTask
|
||||||
|
Order --> "-user" User
|
||||||
|
MessageRequest --> "-msg" MessageToSend
|
||||||
|
QueueTask --> "-order" Order
|
||||||
|
Commander --> "-queue" QueueDatabase
|
||||||
|
QueueDatabase --> "-data" Queue
|
||||||
|
Queue --> "-front" Node
|
||||||
|
Node ..+ Queue
|
||||||
|
Order --> "-paid" PaymentStatus
|
||||||
|
PaymentStatus ..+ Order
|
||||||
|
EmployeeDatabase --|> Database
|
||||||
|
EmployeeHandle --|> Service
|
||||||
|
MessagingDatabase --|> Database
|
||||||
|
MessagingService --|> Service
|
||||||
|
PaymentDatabase --|> Database
|
||||||
|
PaymentService --|> Service
|
||||||
|
QueueDatabase --|> Database
|
||||||
|
ShippingDatabase --|> Database
|
||||||
|
ShippingService --|> Service
|
||||||
|
@enduml
|
41
composite/etc/composite.urm.puml
Normal file
41
composite/etc/composite.urm.puml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.composite {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Letter {
|
||||||
|
- character : char
|
||||||
|
+ Letter(c : char)
|
||||||
|
# printThisBefore()
|
||||||
|
}
|
||||||
|
abstract class LetterComposite {
|
||||||
|
- children : List<LetterComposite>
|
||||||
|
+ LetterComposite()
|
||||||
|
+ add(letter : LetterComposite)
|
||||||
|
+ count() : int
|
||||||
|
+ print()
|
||||||
|
# printThisAfter()
|
||||||
|
# printThisBefore()
|
||||||
|
}
|
||||||
|
class Messenger {
|
||||||
|
+ Messenger()
|
||||||
|
~ messageFromElves() : LetterComposite
|
||||||
|
~ messageFromOrcs() : LetterComposite
|
||||||
|
}
|
||||||
|
class Sentence {
|
||||||
|
+ Sentence(words : List<Word>)
|
||||||
|
# printThisAfter()
|
||||||
|
}
|
||||||
|
class Word {
|
||||||
|
+ Word(letters : List<Letter>)
|
||||||
|
+ Word(letters : char[])
|
||||||
|
# printThisBefore()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LetterComposite --> "-children" LetterComposite
|
||||||
|
Letter --|> LetterComposite
|
||||||
|
Sentence --|> LetterComposite
|
||||||
|
Word --|> LetterComposite
|
||||||
|
@enduml
|
50
converter/etc/converter.urm.puml
Normal file
50
converter/etc/converter.urm.puml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.converter {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Converter<T, U> {
|
||||||
|
- fromDto : Function<T, U>
|
||||||
|
- fromEntity : Function<U, T>
|
||||||
|
+ Converter<T, U>(fromDto : Function<T, U>, fromEntity : Function<U, T>)
|
||||||
|
+ convertFromDto(dto : T) : U
|
||||||
|
+ convertFromEntity(entity : U) : T
|
||||||
|
+ createFromDtos(dtos : Collection<T>) : List<U>
|
||||||
|
+ createFromEntities(entities : Collection<U>) : List<T>
|
||||||
|
}
|
||||||
|
class User {
|
||||||
|
- firstName : String
|
||||||
|
- isActive : boolean
|
||||||
|
- lastName : String
|
||||||
|
- userId : String
|
||||||
|
+ User(firstName : String, lastName : String, isActive : boolean, userId : String)
|
||||||
|
+ equals(o : Object) : boolean
|
||||||
|
+ getFirstName() : String
|
||||||
|
+ getLastName() : String
|
||||||
|
+ getUserId() : String
|
||||||
|
+ hashCode() : int
|
||||||
|
+ isActive() : boolean
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class UserConverter {
|
||||||
|
+ UserConverter()
|
||||||
|
}
|
||||||
|
class UserDto {
|
||||||
|
- email : String
|
||||||
|
- firstName : String
|
||||||
|
- isActive : boolean
|
||||||
|
- lastName : String
|
||||||
|
+ UserDto(firstName : String, lastName : String, isActive : boolean, email : String)
|
||||||
|
+ equals(o : Object) : boolean
|
||||||
|
+ getEmail() : String
|
||||||
|
+ getFirstName() : String
|
||||||
|
+ getLastName() : String
|
||||||
|
+ hashCode() : int
|
||||||
|
+ isActive() : boolean
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UserConverter --|> Converter
|
||||||
|
@enduml
|
134
cqrs/etc/cqrs.urm.puml
Normal file
134
cqrs/etc/cqrs.urm.puml
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.cqrs.util {
|
||||||
|
class HibernateUtil {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- SESSIONFACTORY : SessionFactory {static}
|
||||||
|
+ HibernateUtil()
|
||||||
|
- buildSessionFactory() : SessionFactory {static}
|
||||||
|
+ getSessionFactory() : SessionFactory {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.cqrs.app {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.cqrs.dto {
|
||||||
|
class Author {
|
||||||
|
- email : String
|
||||||
|
- name : String
|
||||||
|
- username : String
|
||||||
|
+ Author()
|
||||||
|
+ Author(name : String, email : String, username : String)
|
||||||
|
+ equals(obj : Object) : boolean
|
||||||
|
+ getEmail() : String
|
||||||
|
+ getName() : String
|
||||||
|
+ getUsername() : String
|
||||||
|
+ hashCode() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Book {
|
||||||
|
- price : double
|
||||||
|
- title : String
|
||||||
|
+ Book()
|
||||||
|
+ Book(title : String, price : double)
|
||||||
|
+ equals(obj : Object) : boolean
|
||||||
|
+ getPrice() : double
|
||||||
|
+ getTitle() : String
|
||||||
|
+ hashCode() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.cqrs.commandes {
|
||||||
|
class CommandServiceImpl {
|
||||||
|
- sessionFactory : SessionFactory
|
||||||
|
+ CommandServiceImpl()
|
||||||
|
+ authorCreated(username : String, name : String, email : String)
|
||||||
|
+ authorEmailUpdated(username : String, email : String)
|
||||||
|
+ authorNameUpdated(username : String, name : String)
|
||||||
|
+ authorUsernameUpdated(oldUsername : String, newUsername : String)
|
||||||
|
+ bookAddedToAuthor(title : String, price : double, username : String)
|
||||||
|
+ bookPriceUpdated(title : String, price : double)
|
||||||
|
+ bookTitleUpdated(oldTitle : String, newTitle : String)
|
||||||
|
- getAuthorByUsername(username : String) : Author
|
||||||
|
- getBookByTitle(title : String) : Book
|
||||||
|
}
|
||||||
|
interface ICommandService {
|
||||||
|
+ authorCreated(String, String, String) {abstract}
|
||||||
|
+ authorEmailUpdated(String, String) {abstract}
|
||||||
|
+ authorNameUpdated(String, String) {abstract}
|
||||||
|
+ authorUsernameUpdated(String, String) {abstract}
|
||||||
|
+ bookAddedToAuthor(String, double, String) {abstract}
|
||||||
|
+ bookPriceUpdated(String, double) {abstract}
|
||||||
|
+ bookTitleUpdated(String, String) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.cqrs.queries {
|
||||||
|
interface IQueryService {
|
||||||
|
+ getAuthorBooks(String) : List<Book> {abstract}
|
||||||
|
+ getAuthorBooksCount(String) : BigInteger {abstract}
|
||||||
|
+ getAuthorByUsername(String) : Author {abstract}
|
||||||
|
+ getAuthorsCount() : BigInteger {abstract}
|
||||||
|
+ getBook(String) : Book {abstract}
|
||||||
|
}
|
||||||
|
class QueryServiceImpl {
|
||||||
|
- sessionFactory : SessionFactory
|
||||||
|
+ QueryServiceImpl()
|
||||||
|
+ getAuthorBooks(username : String) : List<Book>
|
||||||
|
+ getAuthorBooksCount(username : String) : BigInteger
|
||||||
|
+ getAuthorByUsername(username : String) : Author
|
||||||
|
+ getAuthorsCount() : BigInteger
|
||||||
|
+ getBook(title : String) : Book
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.cqrs.constants {
|
||||||
|
class AppConstants {
|
||||||
|
+ E_EVANS : String {static}
|
||||||
|
+ J_BLOCH : String {static}
|
||||||
|
+ M_FOWLER : String {static}
|
||||||
|
+ USER_NAME : String {static}
|
||||||
|
+ AppConstants()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.cqrs.domain.model {
|
||||||
|
class Author {
|
||||||
|
- email : String
|
||||||
|
- id : long
|
||||||
|
- name : String
|
||||||
|
- username : String
|
||||||
|
# Author()
|
||||||
|
+ Author(username : String, name : String, email : String)
|
||||||
|
+ getEmail() : String
|
||||||
|
+ getId() : long
|
||||||
|
+ getName() : String
|
||||||
|
+ getUsername() : String
|
||||||
|
+ setEmail(email : String)
|
||||||
|
+ setId(id : long)
|
||||||
|
+ setName(name : String)
|
||||||
|
+ setUsername(username : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Book {
|
||||||
|
- author : Author
|
||||||
|
- id : long
|
||||||
|
- price : double
|
||||||
|
- title : String
|
||||||
|
# Book()
|
||||||
|
+ Book(title : String, price : double, author : Author)
|
||||||
|
+ getAuthor() : Author
|
||||||
|
+ getId() : long
|
||||||
|
+ getPrice() : double
|
||||||
|
+ getTitle() : String
|
||||||
|
+ setAuthor(author : Author)
|
||||||
|
+ setId(id : long)
|
||||||
|
+ setPrice(price : double)
|
||||||
|
+ setTitle(title : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Book --> "-author" Author
|
||||||
|
CommandServiceImpl ..|> ICommandService
|
||||||
|
QueryServiceImpl ..|> IQueryService
|
||||||
|
@enduml
|
68
dao/etc/dao.urm.puml
Normal file
68
dao/etc/dao.urm.puml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.dao {
|
||||||
|
class App {
|
||||||
|
- ALL_CUSTOMERS : String {static}
|
||||||
|
- 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}
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
interface CustomerDao {
|
||||||
|
+ add(Customer) : boolean {abstract}
|
||||||
|
+ delete(Customer) : boolean {abstract}
|
||||||
|
+ getAll() : Stream<Customer> {abstract}
|
||||||
|
+ getById(int) : Optional<Customer> {abstract}
|
||||||
|
+ update(Customer) : boolean {abstract}
|
||||||
|
}
|
||||||
|
class CustomerSchemaSql {
|
||||||
|
+ CREATE_SCHEMA_SQL : String {static}
|
||||||
|
+ DELETE_SCHEMA_SQL : String {static}
|
||||||
|
- CustomerSchemaSql()
|
||||||
|
}
|
||||||
|
class DbCustomerDao {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- 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, statement : PreparedStatement, resultSet : ResultSet)
|
||||||
|
+ 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DbCustomerDao ..|> CustomerDao
|
||||||
|
InMemoryCustomerDao ..|> CustomerDao
|
||||||
|
@enduml
|
82
data-bus/etc/data-bus.urm.puml
Normal file
82
data-bus/etc/data-bus.urm.puml
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.databus {
|
||||||
|
class AbstractDataType {
|
||||||
|
- dataBus : DataBus
|
||||||
|
+ AbstractDataType()
|
||||||
|
+ getDataBus() : DataBus
|
||||||
|
+ setDataBus(dataBus : DataBus)
|
||||||
|
}
|
||||||
|
~class App {
|
||||||
|
~ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class DataBus {
|
||||||
|
- INSTANCE : DataBus {static}
|
||||||
|
- listeners : Set<Member>
|
||||||
|
+ DataBus()
|
||||||
|
+ getInstance() : DataBus {static}
|
||||||
|
+ publish(event : DataType)
|
||||||
|
+ subscribe(member : Member)
|
||||||
|
+ unsubscribe(member : Member)
|
||||||
|
}
|
||||||
|
interface DataType {
|
||||||
|
+ getDataBus() : DataBus {abstract}
|
||||||
|
+ setDataBus(DataBus) {abstract}
|
||||||
|
}
|
||||||
|
interface Member {
|
||||||
|
+ accept(DataType) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.databus.data {
|
||||||
|
class MessageData {
|
||||||
|
- message : String
|
||||||
|
+ MessageData(message : String)
|
||||||
|
+ getMessage() : String
|
||||||
|
+ of(message : String) : DataType {static}
|
||||||
|
}
|
||||||
|
class StartingData {
|
||||||
|
- when : LocalDateTime
|
||||||
|
+ StartingData(when : LocalDateTime)
|
||||||
|
+ getWhen() : LocalDateTime
|
||||||
|
+ of(when : LocalDateTime) : DataType {static}
|
||||||
|
}
|
||||||
|
class StoppingData {
|
||||||
|
- when : LocalDateTime
|
||||||
|
+ StoppingData(when : LocalDateTime)
|
||||||
|
+ getWhen() : LocalDateTime
|
||||||
|
+ of(when : LocalDateTime) : DataType {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.databus.members {
|
||||||
|
class MessageCollectorMember {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- messages : List<String>
|
||||||
|
- name : String
|
||||||
|
+ MessageCollectorMember(name : String)
|
||||||
|
+ accept(data : DataType)
|
||||||
|
+ getMessages() : List<String>
|
||||||
|
- handleEvent(data : MessageData)
|
||||||
|
}
|
||||||
|
class StatusMember {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- id : int
|
||||||
|
- started : LocalDateTime
|
||||||
|
- stopped : LocalDateTime
|
||||||
|
+ StatusMember(id : int)
|
||||||
|
+ accept(data : DataType)
|
||||||
|
+ getStarted() : LocalDateTime
|
||||||
|
+ getStopped() : LocalDateTime
|
||||||
|
- handleEvent(data : StartingData)
|
||||||
|
- handleEvent(data : StoppingData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractDataType --> "-dataBus" DataBus
|
||||||
|
DataBus --> "-INSTANCE" DataBus
|
||||||
|
DataBus --> "-listeners" Member
|
||||||
|
AbstractDataType ..|> DataType
|
||||||
|
MessageData --|> AbstractDataType
|
||||||
|
StartingData --|> AbstractDataType
|
||||||
|
StoppingData --|> AbstractDataType
|
||||||
|
MessageCollectorMember ..|> Member
|
||||||
|
StatusMember ..|> Member
|
||||||
|
@enduml
|
80
data-locality/etc/data-locality.urm.puml
Normal file
80
data-locality/etc/data-locality.urm.puml
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.data.locality.game.component.manager {
|
||||||
|
class AiComponentManager {
|
||||||
|
- AI_COMPONENTS : Component[] {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- MAX_ENTITIES : int {static}
|
||||||
|
- numEntities : int
|
||||||
|
+ AiComponentManager(numEntities : int)
|
||||||
|
+ start()
|
||||||
|
+ update()
|
||||||
|
}
|
||||||
|
class PhysicsComponentManager {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- MAX_ENTITIES : int {static}
|
||||||
|
- PHYSICS_COMPONENTS : Component[] {static}
|
||||||
|
- numEntities : int
|
||||||
|
+ PhysicsComponentManager(numEntities : int)
|
||||||
|
+ start()
|
||||||
|
+ update()
|
||||||
|
}
|
||||||
|
class RenderComponentManager {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- MAX_ENTITIES : int {static}
|
||||||
|
- RENDER_COMPONENTS : Component[] {static}
|
||||||
|
- numEntities : int
|
||||||
|
+ RenderComponentManager(numEntities : int)
|
||||||
|
+ render()
|
||||||
|
+ start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.data.locality {
|
||||||
|
class Application {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- NUM_ENTITIES : int {static}
|
||||||
|
+ Application()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.data.locality.game {
|
||||||
|
class GameEntity {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- aiComponentManager : AiComponentManager
|
||||||
|
- physicsComponentManager : PhysicsComponentManager
|
||||||
|
- renderComponentManager : RenderComponentManager
|
||||||
|
+ GameEntity(numEntities : int)
|
||||||
|
+ start()
|
||||||
|
+ update()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.data.locality.game.component {
|
||||||
|
class AiComponent {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ AiComponent()
|
||||||
|
+ render()
|
||||||
|
+ update()
|
||||||
|
}
|
||||||
|
interface Component {
|
||||||
|
+ render() {abstract}
|
||||||
|
+ update() {abstract}
|
||||||
|
}
|
||||||
|
class PhysicsComponent {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ PhysicsComponent()
|
||||||
|
+ render()
|
||||||
|
+ update()
|
||||||
|
}
|
||||||
|
class RenderComponent {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ RenderComponent()
|
||||||
|
+ render()
|
||||||
|
+ update()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameEntity --> "-physicsComponentManager" PhysicsComponentManager
|
||||||
|
GameEntity --> "-aiComponentManager" AiComponentManager
|
||||||
|
GameEntity --> "-renderComponentManager" RenderComponentManager
|
||||||
|
AiComponent ..|> Component
|
||||||
|
PhysicsComponent ..|> Component
|
||||||
|
RenderComponent ..|> Component
|
||||||
|
@enduml
|
43
data-mapper/etc/data-mapper.urm.puml
Normal file
43
data-mapper/etc/data-mapper.urm.puml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.datamapper {
|
||||||
|
class App {
|
||||||
|
- STUDENT_STRING : String {static}
|
||||||
|
- log : Logger {static}
|
||||||
|
- App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Student {
|
||||||
|
- grade : char
|
||||||
|
- name : String
|
||||||
|
- serialVersionUID : long {static}
|
||||||
|
- studentId : int
|
||||||
|
+ Student(studentId : int, name : String, grade : char)
|
||||||
|
+ equals(inputObject : Object) : boolean
|
||||||
|
+ getGrade() : char
|
||||||
|
+ getName() : String
|
||||||
|
+ getStudentId() : int
|
||||||
|
+ hashCode() : int
|
||||||
|
+ setGrade(grade : char)
|
||||||
|
+ setName(name : String)
|
||||||
|
+ setStudentId(studentId : int)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface StudentDataMapper {
|
||||||
|
+ delete(Student) {abstract}
|
||||||
|
+ find(int) : Optional<Student> {abstract}
|
||||||
|
+ insert(Student) {abstract}
|
||||||
|
+ update(Student) {abstract}
|
||||||
|
}
|
||||||
|
class StudentDataMapperImpl {
|
||||||
|
- students : List<Student>
|
||||||
|
+ StudentDataMapperImpl()
|
||||||
|
+ delete(studentToBeDeleted : Student)
|
||||||
|
+ find(studentId : int) : Optional<Student>
|
||||||
|
+ getStudents() : List<Student>
|
||||||
|
+ insert(studentToBeInserted : Student)
|
||||||
|
+ update(studentToBeUpdated : Student)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StudentDataMapperImpl --> "-students" Student
|
||||||
|
StudentDataMapperImpl ..|> StudentDataMapper
|
||||||
|
@enduml
|
27
data-transfer-object/etc/data-transfer-object.urm.puml
Normal file
27
data-transfer-object/etc/data-transfer-object.urm.puml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.datatransfer {
|
||||||
|
class CustomerClientApp {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ CustomerClientApp()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- printCustomerDetails(allCustomers : List<CustomerDto>) {static}
|
||||||
|
}
|
||||||
|
class CustomerDto {
|
||||||
|
- firstName : String
|
||||||
|
- id : String
|
||||||
|
- lastName : String
|
||||||
|
+ CustomerDto(id : String, firstName : String, lastName : String)
|
||||||
|
+ getFirstName() : String
|
||||||
|
+ getId() : String
|
||||||
|
+ getLastName() : String
|
||||||
|
}
|
||||||
|
class CustomerResource {
|
||||||
|
- customers : List<CustomerDto>
|
||||||
|
+ CustomerResource(customers : List<CustomerDto>)
|
||||||
|
+ delete(customerId : String)
|
||||||
|
+ getAllCustomers() : List<CustomerDto>
|
||||||
|
+ save(customer : CustomerDto)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CustomerResource --> "-customers" CustomerDto
|
||||||
|
@enduml
|
32
decorator/etc/decorator.urm.puml
Normal file
32
decorator/etc/decorator.urm.puml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.decorator {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class ClubbedTroll {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- decorated : Troll
|
||||||
|
+ ClubbedTroll(decorated : Troll)
|
||||||
|
+ attack()
|
||||||
|
+ fleeBattle()
|
||||||
|
+ getAttackPower() : int
|
||||||
|
}
|
||||||
|
class SimpleTroll {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ SimpleTroll()
|
||||||
|
+ attack()
|
||||||
|
+ fleeBattle()
|
||||||
|
+ getAttackPower() : int
|
||||||
|
}
|
||||||
|
interface Troll {
|
||||||
|
+ attack() {abstract}
|
||||||
|
+ fleeBattle() {abstract}
|
||||||
|
+ getAttackPower() : int {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ClubbedTroll --> "-decorated" Troll
|
||||||
|
ClubbedTroll ..|> Troll
|
||||||
|
SimpleTroll ..|> Troll
|
||||||
|
@enduml
|
39
delegation/etc/delegation.urm.puml
Normal file
39
delegation/etc/delegation.urm.puml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.delegation.simple.printers {
|
||||||
|
class CanonPrinter {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ CanonPrinter()
|
||||||
|
+ print(message : String)
|
||||||
|
}
|
||||||
|
class EpsonPrinter {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ EpsonPrinter()
|
||||||
|
+ print(message : String)
|
||||||
|
}
|
||||||
|
class HpPrinter {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ HpPrinter()
|
||||||
|
+ print(message : String)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.delegation.simple {
|
||||||
|
class App {
|
||||||
|
- MESSAGE_TO_PRINT : String {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface Printer {
|
||||||
|
+ print(String) {abstract}
|
||||||
|
}
|
||||||
|
class PrinterController {
|
||||||
|
- printer : Printer
|
||||||
|
+ PrinterController(printer : Printer)
|
||||||
|
+ print(message : String)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PrinterController --> "-printer" Printer
|
||||||
|
PrinterController ..|> Printer
|
||||||
|
CanonPrinter ..|> Printer
|
||||||
|
EpsonPrinter ..|> Printer
|
||||||
|
HpPrinter ..|> Printer
|
||||||
|
@enduml
|
57
dependency-injection/etc/dependency-injection.urm.puml
Normal file
57
dependency-injection/etc/dependency-injection.urm.puml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.dependency.injection {
|
||||||
|
class AdvancedSorceress {
|
||||||
|
- tobacco : Tobacco
|
||||||
|
+ AdvancedSorceress()
|
||||||
|
+ setTobacco(tobacco : Tobacco)
|
||||||
|
+ smoke()
|
||||||
|
}
|
||||||
|
class AdvancedWizard {
|
||||||
|
- tobacco : Tobacco
|
||||||
|
+ AdvancedWizard(tobacco : Tobacco)
|
||||||
|
+ smoke()
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class GuiceWizard {
|
||||||
|
- tobacco : Tobacco
|
||||||
|
+ GuiceWizard(tobacco : Tobacco)
|
||||||
|
+ smoke()
|
||||||
|
}
|
||||||
|
class OldTobyTobacco {
|
||||||
|
+ OldTobyTobacco()
|
||||||
|
}
|
||||||
|
class RivendellTobacco {
|
||||||
|
+ RivendellTobacco()
|
||||||
|
}
|
||||||
|
class SecondBreakfastTobacco {
|
||||||
|
+ SecondBreakfastTobacco()
|
||||||
|
}
|
||||||
|
class SimpleWizard {
|
||||||
|
- tobacco : OldTobyTobacco
|
||||||
|
+ SimpleWizard()
|
||||||
|
+ smoke()
|
||||||
|
}
|
||||||
|
abstract class Tobacco {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Tobacco()
|
||||||
|
+ smoke(wizard : Wizard)
|
||||||
|
}
|
||||||
|
interface Wizard {
|
||||||
|
+ smoke() {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AdvancedSorceress --> "-tobacco" Tobacco
|
||||||
|
SimpleWizard --> "-tobacco" OldTobyTobacco
|
||||||
|
AdvancedWizard --> "-tobacco" Tobacco
|
||||||
|
GuiceWizard --> "-tobacco" Tobacco
|
||||||
|
AdvancedSorceress ..|> Wizard
|
||||||
|
AdvancedWizard ..|> Wizard
|
||||||
|
GuiceWizard ..|> Wizard
|
||||||
|
OldTobyTobacco --|> Tobacco
|
||||||
|
RivendellTobacco --|> Tobacco
|
||||||
|
SecondBreakfastTobacco --|> Tobacco
|
||||||
|
SimpleWizard ..|> Wizard
|
||||||
|
@enduml
|
25
dirty-flag/etc/dirty-flag.urm.puml
Normal file
25
dirty-flag/etc/dirty-flag.urm.puml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.dirtyflag {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
+ run()
|
||||||
|
}
|
||||||
|
class DataFetcher {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- filename : String
|
||||||
|
- lastFetched : long
|
||||||
|
+ DataFetcher()
|
||||||
|
+ fetch() : List<String>
|
||||||
|
- isDirty(fileLastModified : long) : boolean
|
||||||
|
}
|
||||||
|
class World {
|
||||||
|
- countries : List<String>
|
||||||
|
- df : DataFetcher
|
||||||
|
+ World()
|
||||||
|
+ fetch() : List<String>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
World --> "-df" DataFetcher
|
||||||
|
@enduml
|
45
double-buffer/etc/double-buffer.urm.puml
Normal file
45
double-buffer/etc/double-buffer.urm.puml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.doublebuffer {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- printBlackPixelCoordinate(buffer : Buffer) {static}
|
||||||
|
}
|
||||||
|
interface Buffer {
|
||||||
|
+ clear(int, int) {abstract}
|
||||||
|
+ clearAll() {abstract}
|
||||||
|
+ draw(int, int) {abstract}
|
||||||
|
+ getPixels() : Pixel[] {abstract}
|
||||||
|
}
|
||||||
|
class FrameBuffer {
|
||||||
|
+ HEIGHT : int {static}
|
||||||
|
+ WIDTH : int {static}
|
||||||
|
- pixels : Pixel[]
|
||||||
|
+ FrameBuffer()
|
||||||
|
+ clear(x : int, y : int)
|
||||||
|
+ clearAll()
|
||||||
|
+ draw(x : int, y : int)
|
||||||
|
- getIndex(x : int, y : int) : int
|
||||||
|
+ getPixels() : Pixel[]
|
||||||
|
}
|
||||||
|
enum Pixel {
|
||||||
|
+ BLACK {static}
|
||||||
|
+ WHITE {static}
|
||||||
|
- color : int
|
||||||
|
+ valueOf(name : String) : Pixel {static}
|
||||||
|
+ values() : Pixel[] {static}
|
||||||
|
}
|
||||||
|
class Scene {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- current : int
|
||||||
|
- frameBuffers : Buffer[]
|
||||||
|
- next : int
|
||||||
|
+ Scene()
|
||||||
|
+ draw(coordinateList : List<Pair<Integer, Integer>>)
|
||||||
|
+ getBuffer() : Buffer
|
||||||
|
- swap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FrameBuffer ..|> Buffer
|
||||||
|
@enduml
|
22
double-checked-locking/etc/double-checked-locking.urm.puml
Normal file
22
double-checked-locking/etc/double-checked-locking.urm.puml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.doublechecked.locking {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Inventory {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- inventorySize : int
|
||||||
|
- items : List<Item>
|
||||||
|
- lock : Lock
|
||||||
|
+ Inventory(inventorySize : int)
|
||||||
|
+ addItem(item : Item) : boolean
|
||||||
|
+ getItems() : List<Item>
|
||||||
|
}
|
||||||
|
class Item {
|
||||||
|
+ Item()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Inventory --> "-items" Item
|
||||||
|
@enduml
|
74
double-dispatch/etc/double-dispatch.urm.puml
Normal file
74
double-dispatch/etc/double-dispatch.urm.puml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.doubledispatch.constants {
|
||||||
|
class AppConstants {
|
||||||
|
+ HITS : String {static}
|
||||||
|
+ AppConstants()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.doubledispatch {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class FlamingAsteroid {
|
||||||
|
+ FlamingAsteroid(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(gameObject : GameObject)
|
||||||
|
}
|
||||||
|
abstract class GameObject {
|
||||||
|
- damaged : boolean
|
||||||
|
- onFire : boolean
|
||||||
|
+ GameObject(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(GameObject) {abstract}
|
||||||
|
+ collisionResolve(FlamingAsteroid) {abstract}
|
||||||
|
+ collisionResolve(Meteoroid) {abstract}
|
||||||
|
+ collisionResolve(SpaceStationIss) {abstract}
|
||||||
|
+ collisionResolve(SpaceStationMir) {abstract}
|
||||||
|
+ isDamaged() : boolean
|
||||||
|
+ isOnFire() : boolean
|
||||||
|
+ setDamaged(damaged : boolean)
|
||||||
|
+ setOnFire(onFire : boolean)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Meteoroid {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Meteoroid(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(gameObject : GameObject)
|
||||||
|
+ collisionResolve(asteroid : FlamingAsteroid)
|
||||||
|
+ collisionResolve(iss : SpaceStationIss)
|
||||||
|
+ collisionResolve(meteoroid : Meteoroid)
|
||||||
|
+ collisionResolve(mir : SpaceStationMir)
|
||||||
|
}
|
||||||
|
class Rectangle {
|
||||||
|
- bottom : int
|
||||||
|
- left : int
|
||||||
|
- right : int
|
||||||
|
- top : int
|
||||||
|
+ Rectangle(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ getBottom() : int
|
||||||
|
+ getLeft() : int
|
||||||
|
+ getRight() : int
|
||||||
|
+ getTop() : int
|
||||||
|
~ intersectsWith(r : Rectangle) : boolean
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class SpaceStationIss {
|
||||||
|
+ SpaceStationIss(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(gameObject : GameObject)
|
||||||
|
}
|
||||||
|
class SpaceStationMir {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ SpaceStationMir(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(gameObject : GameObject)
|
||||||
|
+ collisionResolve(asteroid : FlamingAsteroid)
|
||||||
|
+ collisionResolve(iss : SpaceStationIss)
|
||||||
|
+ collisionResolve(meteoroid : Meteoroid)
|
||||||
|
+ collisionResolve(mir : SpaceStationMir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FlamingAsteroid --|> Meteoroid
|
||||||
|
GameObject --|> Rectangle
|
||||||
|
Meteoroid --|> GameObject
|
||||||
|
SpaceStationIss --|> SpaceStationMir
|
||||||
|
SpaceStationMir --|> GameObject
|
||||||
|
@enduml
|
14
eip-aggregator/etc/eip-aggregator.urm.puml
Normal file
14
eip-aggregator/etc/eip-aggregator.urm.puml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.eip.aggregator {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eip.aggregator.routes {
|
||||||
|
class MessageAggregationStrategy {
|
||||||
|
+ MessageAggregationStrategy()
|
||||||
|
+ aggregate(oldExchange : Exchange, newExchange : Exchange) : Exchange
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
9
eip-message-channel/etc/eip-message-channel.urm.puml
Normal file
9
eip-message-channel/etc/eip-message-channel.urm.puml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.eip.message.channel {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
9
eip-publish-subscribe/etc/eip-publish-subscribe.urm.puml
Normal file
9
eip-publish-subscribe/etc/eip-publish-subscribe.urm.puml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.eip.publish.subscribe {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
8
eip-splitter/etc/eip-splitter.urm.puml
Normal file
8
eip-splitter/etc/eip-splitter.urm.puml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.eip.splitter {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
8
eip-wire-tap/etc/eip-wire-tap.urm.puml
Normal file
8
eip-wire-tap/etc/eip-wire-tap.urm.puml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.eip.wiretap {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
2
etc/java-design-patterns.urm.puml
Normal file
2
etc/java-design-patterns.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
74
event-aggregator/etc/event-aggregator.urm.puml
Normal file
74
event-aggregator/etc/event-aggregator.urm.puml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.event.aggregator {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
enum Event {
|
||||||
|
+ STARK_SIGHTED {static}
|
||||||
|
+ TRAITOR_DETECTED {static}
|
||||||
|
+ WARSHIPS_APPROACHING {static}
|
||||||
|
- description : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Event {static}
|
||||||
|
+ values() : Event[] {static}
|
||||||
|
}
|
||||||
|
abstract class EventEmitter {
|
||||||
|
- observers : List<EventObserver>
|
||||||
|
+ EventEmitter()
|
||||||
|
+ EventEmitter(obs : EventObserver)
|
||||||
|
# notifyObservers(e : Event)
|
||||||
|
+ registerObserver(obs : EventObserver)
|
||||||
|
+ timePasses(Weekday) {abstract}
|
||||||
|
}
|
||||||
|
interface EventObserver {
|
||||||
|
+ onEvent(Event) {abstract}
|
||||||
|
}
|
||||||
|
class KingJoffrey {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ KingJoffrey()
|
||||||
|
+ onEvent(e : Event)
|
||||||
|
}
|
||||||
|
class KingsHand {
|
||||||
|
+ KingsHand()
|
||||||
|
+ KingsHand(obs : EventObserver)
|
||||||
|
+ onEvent(e : Event)
|
||||||
|
+ timePasses(day : Weekday)
|
||||||
|
}
|
||||||
|
class LordBaelish {
|
||||||
|
+ LordBaelish()
|
||||||
|
+ LordBaelish(obs : EventObserver)
|
||||||
|
+ timePasses(day : Weekday)
|
||||||
|
}
|
||||||
|
class LordVarys {
|
||||||
|
+ LordVarys()
|
||||||
|
+ LordVarys(obs : EventObserver)
|
||||||
|
+ timePasses(day : Weekday)
|
||||||
|
}
|
||||||
|
class Scout {
|
||||||
|
+ Scout()
|
||||||
|
+ Scout(obs : EventObserver)
|
||||||
|
+ timePasses(day : Weekday)
|
||||||
|
}
|
||||||
|
enum Weekday {
|
||||||
|
+ FRIDAY {static}
|
||||||
|
+ MONDAY {static}
|
||||||
|
+ SATURDAY {static}
|
||||||
|
+ SUNDAY {static}
|
||||||
|
+ THURSDAY {static}
|
||||||
|
+ TUESDAY {static}
|
||||||
|
+ WEDNESDAY {static}
|
||||||
|
- description : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Weekday {static}
|
||||||
|
+ values() : Weekday[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EventEmitter --> "-observers" EventObserver
|
||||||
|
KingJoffrey ..|> EventObserver
|
||||||
|
KingsHand ..|> EventObserver
|
||||||
|
KingsHand --|> EventEmitter
|
||||||
|
LordBaelish --|> EventEmitter
|
||||||
|
LordVarys --|> EventEmitter
|
||||||
|
Scout --|> EventEmitter
|
||||||
|
@enduml
|
70
event-asynchronous/etc/event-asynchronous.urm.puml
Normal file
70
event-asynchronous/etc/event-asynchronous.urm.puml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.event.asynchronous {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ PROP_FILE_NAME : String {static}
|
||||||
|
~ interactiveMode : boolean
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- processOption1(eventManager : EventManager, s : Scanner)
|
||||||
|
- processOption2(eventManager : EventManager, s : Scanner)
|
||||||
|
- processOption3(eventManager : EventManager, s : Scanner)
|
||||||
|
+ quickRun()
|
||||||
|
+ run()
|
||||||
|
+ runInteractiveMode()
|
||||||
|
+ setUp()
|
||||||
|
}
|
||||||
|
class Event {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- eventId : int
|
||||||
|
- eventListener : ThreadCompleteListener
|
||||||
|
- eventTime : int
|
||||||
|
- isComplete : boolean
|
||||||
|
- isSynchronous : boolean
|
||||||
|
- thread : Thread
|
||||||
|
+ Event(eventId : int, eventTime : int, isSynchronous : boolean)
|
||||||
|
+ addListener(listener : ThreadCompleteListener)
|
||||||
|
- completed()
|
||||||
|
+ isSynchronous() : boolean
|
||||||
|
+ removeListener(listener : ThreadCompleteListener)
|
||||||
|
+ run()
|
||||||
|
+ start()
|
||||||
|
+ status()
|
||||||
|
+ stop()
|
||||||
|
}
|
||||||
|
class EventManager {
|
||||||
|
- DOES_NOT_EXIST : String {static}
|
||||||
|
+ MAX_EVENT_TIME : int {static}
|
||||||
|
+ MAX_ID : int {static}
|
||||||
|
+ MAX_RUNNING_EVENTS : int {static}
|
||||||
|
+ MIN_ID : int {static}
|
||||||
|
- currentlyRunningSyncEvent : int
|
||||||
|
- eventPool : Map<Integer, Event>
|
||||||
|
- rand : Random
|
||||||
|
+ EventManager()
|
||||||
|
+ cancel(eventId : int)
|
||||||
|
+ completedEventHandler(eventId : int)
|
||||||
|
+ create(eventTime : int) : int
|
||||||
|
+ createAsync(eventTime : int) : int
|
||||||
|
- createEvent(eventTime : int, isSynchronous : boolean) : int
|
||||||
|
- generateId() : int
|
||||||
|
+ getEventPool() : Map<Integer, Event>
|
||||||
|
+ numOfCurrentlyRunningSyncEvent() : int
|
||||||
|
+ shutdown()
|
||||||
|
+ start(eventId : int)
|
||||||
|
+ status(eventId : int)
|
||||||
|
+ statusOfAllEvents()
|
||||||
|
}
|
||||||
|
interface IEvent {
|
||||||
|
+ start() {abstract}
|
||||||
|
+ status() {abstract}
|
||||||
|
+ stop() {abstract}
|
||||||
|
}
|
||||||
|
interface ThreadCompleteListener {
|
||||||
|
+ completedEventHandler(int) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event --> "-eventListener" ThreadCompleteListener
|
||||||
|
Event ..|> IEvent
|
||||||
|
EventManager ..|> ThreadCompleteListener
|
||||||
|
@enduml
|
@ -0,0 +1,64 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.eda.handler {
|
||||||
|
class UserCreatedEventHandler {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ UserCreatedEventHandler()
|
||||||
|
+ onEvent(event : UserCreatedEvent)
|
||||||
|
}
|
||||||
|
class UserUpdatedEventHandler {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ UserUpdatedEventHandler()
|
||||||
|
+ onEvent(event : UserUpdatedEvent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eda.event {
|
||||||
|
abstract class AbstractEvent {
|
||||||
|
+ AbstractEvent()
|
||||||
|
+ getType() : Class<? extends Event>
|
||||||
|
}
|
||||||
|
class UserCreatedEvent {
|
||||||
|
- user : User
|
||||||
|
+ UserCreatedEvent(user : User)
|
||||||
|
+ getUser() : User
|
||||||
|
}
|
||||||
|
class UserUpdatedEvent {
|
||||||
|
- user : User
|
||||||
|
+ UserUpdatedEvent(user : User)
|
||||||
|
+ getUser() : User
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eda.framework {
|
||||||
|
interface Event {
|
||||||
|
+ getType() : Class<? extends Event> {abstract}
|
||||||
|
}
|
||||||
|
class EventDispatcher {
|
||||||
|
- handlers : Map<Class<? extends Event>, Handler<? extends Event>>
|
||||||
|
+ EventDispatcher()
|
||||||
|
+ dispatch(event : E extends Event)
|
||||||
|
+ registerHandler(eventType : Class<E extends Event>, handler : Handler<E extends Event>)
|
||||||
|
}
|
||||||
|
interface Handler<E extends Event> {
|
||||||
|
+ onEvent(E extends Event) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eda.model {
|
||||||
|
class User {
|
||||||
|
- username : String
|
||||||
|
+ User(username : String)
|
||||||
|
+ getUsername() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eda {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UserCreatedEvent --> "-user" User
|
||||||
|
UserUpdatedEvent --> "-user" User
|
||||||
|
AbstractEvent ..|> Event
|
||||||
|
UserCreatedEvent --|> AbstractEvent
|
||||||
|
UserUpdatedEvent --|> AbstractEvent
|
||||||
|
UserCreatedEventHandler ..|> Handler
|
||||||
|
UserUpdatedEventHandler ..|> Handler
|
||||||
|
@enduml
|
38
event-queue/etc/event-queue.urm.puml
Normal file
38
event-queue/etc/event-queue.urm.puml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.event.queue {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Audio {
|
||||||
|
- INSTANCE : Audio {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- MAX_PENDING : int {static}
|
||||||
|
- headIndex : int
|
||||||
|
- pendingAudio : PlayMessage[]
|
||||||
|
- tailIndex : int
|
||||||
|
- updateThread : Thread
|
||||||
|
~ Audio()
|
||||||
|
+ getAudioStream(filePath : String) : AudioInputStream
|
||||||
|
+ getInstance() : Audio {static}
|
||||||
|
+ getPendingAudio() : PlayMessage[]
|
||||||
|
+ init()
|
||||||
|
+ isServiceRunning() : boolean
|
||||||
|
+ playSound(stream : AudioInputStream, volume : float)
|
||||||
|
- startThread()
|
||||||
|
+ stopService()
|
||||||
|
- update()
|
||||||
|
}
|
||||||
|
class PlayMessage {
|
||||||
|
- stream : AudioInputStream
|
||||||
|
- volume : float
|
||||||
|
+ PlayMessage(stream : AudioInputStream, volume : float)
|
||||||
|
+ getStream() : AudioInputStream
|
||||||
|
+ getVolume() : float
|
||||||
|
- setStream(stream : AudioInputStream)
|
||||||
|
+ setVolume(volume : float)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Audio --> "-INSTANCE" Audio
|
||||||
|
@enduml
|
107
event-sourcing/etc/event-sourcing.urm.puml
Normal file
107
event-sourcing/etc/event-sourcing.urm.puml
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.event.sourcing.processor {
|
||||||
|
class DomainEventProcessor {
|
||||||
|
- processorJournal : JsonFileJournal
|
||||||
|
+ DomainEventProcessor()
|
||||||
|
+ process(domainEvent : DomainEvent)
|
||||||
|
+ recover()
|
||||||
|
+ reset()
|
||||||
|
}
|
||||||
|
class JsonFileJournal {
|
||||||
|
- events : List<String>
|
||||||
|
- file : File
|
||||||
|
- index : int
|
||||||
|
+ JsonFileJournal()
|
||||||
|
+ readNext() : DomainEvent
|
||||||
|
+ reset()
|
||||||
|
+ write(domainEvent : DomainEvent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.event.sourcing.event {
|
||||||
|
class AccountCreateEvent {
|
||||||
|
- accountNo : int
|
||||||
|
- owner : String
|
||||||
|
+ AccountCreateEvent(sequenceId : long, createdTime : long, accountNo : int, owner : String)
|
||||||
|
+ getAccountNo() : int
|
||||||
|
+ getOwner() : String
|
||||||
|
+ process()
|
||||||
|
}
|
||||||
|
abstract class DomainEvent {
|
||||||
|
- createdTime : long
|
||||||
|
- eventClassName : String
|
||||||
|
- realTime : boolean
|
||||||
|
- sequenceId : long
|
||||||
|
+ DomainEvent(sequenceId : long, createdTime : long, eventClassName : String)
|
||||||
|
+ getCreatedTime() : long
|
||||||
|
+ getEventClassName() : String
|
||||||
|
+ getSequenceId() : long
|
||||||
|
+ isRealTime() : boolean
|
||||||
|
+ process() {abstract}
|
||||||
|
+ setRealTime(realTime : boolean)
|
||||||
|
}
|
||||||
|
class MoneyDepositEvent {
|
||||||
|
- accountNo : int
|
||||||
|
- money : BigDecimal
|
||||||
|
+ MoneyDepositEvent(sequenceId : long, createdTime : long, accountNo : int, money : BigDecimal)
|
||||||
|
+ getAccountNo() : int
|
||||||
|
+ getMoney() : BigDecimal
|
||||||
|
+ process()
|
||||||
|
}
|
||||||
|
class MoneyTransferEvent {
|
||||||
|
- accountNoFrom : int
|
||||||
|
- accountNoTo : int
|
||||||
|
- money : BigDecimal
|
||||||
|
+ MoneyTransferEvent(sequenceId : long, createdTime : long, money : BigDecimal, accountNoFrom : int, accountNoTo : int)
|
||||||
|
+ getAccountNoFrom() : int
|
||||||
|
+ getAccountNoTo() : int
|
||||||
|
+ getMoney() : BigDecimal
|
||||||
|
+ process()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.event.sourcing.app {
|
||||||
|
class App {
|
||||||
|
+ ACCOUNT_OF_DAENERYS : int {static}
|
||||||
|
+ ACCOUNT_OF_JON : int {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.event.sourcing.state {
|
||||||
|
class AccountAggregate {
|
||||||
|
- accounts : Map<Integer, Account> {static}
|
||||||
|
- AccountAggregate()
|
||||||
|
+ getAccount(accountNo : int) : Account {static}
|
||||||
|
+ putAccount(account : Account) {static}
|
||||||
|
+ resetState() {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.event.sourcing.domain {
|
||||||
|
class Account {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- MSG : String {static}
|
||||||
|
- accountNo : int
|
||||||
|
- money : BigDecimal
|
||||||
|
- owner : String
|
||||||
|
+ Account(accountNo : int, owner : String)
|
||||||
|
+ copy() : Account
|
||||||
|
- depositMoney(money : BigDecimal)
|
||||||
|
+ getAccountNo() : int
|
||||||
|
+ getMoney() : BigDecimal
|
||||||
|
+ getOwner() : String
|
||||||
|
- handleDeposit(money : BigDecimal, realTime : boolean)
|
||||||
|
+ handleEvent(accountCreateEvent : AccountCreateEvent)
|
||||||
|
+ handleEvent(moneyDepositEvent : MoneyDepositEvent)
|
||||||
|
+ handleTransferFromEvent(moneyTransferEvent : MoneyTransferEvent)
|
||||||
|
+ handleTransferToEvent(moneyTransferEvent : MoneyTransferEvent)
|
||||||
|
- handleWithdrawal(money : BigDecimal, realTime : boolean)
|
||||||
|
+ setMoney(money : BigDecimal)
|
||||||
|
+ toString() : String
|
||||||
|
- withdrawMoney(money : BigDecimal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DomainEventProcessor --> "-processorJournal" JsonFileJournal
|
||||||
|
AccountCreateEvent --|> DomainEvent
|
||||||
|
MoneyDepositEvent --|> DomainEvent
|
||||||
|
MoneyTransferEvent --|> DomainEvent
|
||||||
|
@enduml
|
14
execute-around/etc/execute-around.urm.puml
Normal file
14
execute-around/etc/execute-around.urm.puml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.execute.around {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface FileWriterAction {
|
||||||
|
+ writeFile(FileWriter) {abstract}
|
||||||
|
}
|
||||||
|
class SimpleFileWriter {
|
||||||
|
+ SimpleFileWriter(filename : String, action : FileWriterAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
2
extension-objects/etc/extension-objects.urm.puml
Normal file
2
extension-objects/etc/extension-objects.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
60
facade/etc/facade.urm.puml
Normal file
60
facade/etc/facade.urm.puml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.facade {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class DwarvenCartOperator {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ DwarvenCartOperator()
|
||||||
|
+ name() : String
|
||||||
|
+ work()
|
||||||
|
}
|
||||||
|
class DwarvenGoldDigger {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ DwarvenGoldDigger()
|
||||||
|
+ name() : String
|
||||||
|
+ work()
|
||||||
|
}
|
||||||
|
class DwarvenGoldmineFacade {
|
||||||
|
- workers : List<DwarvenMineWorker>
|
||||||
|
+ DwarvenGoldmineFacade()
|
||||||
|
+ digOutGold()
|
||||||
|
+ endDay()
|
||||||
|
- makeActions(workers : Collection<DwarvenMineWorker>, actions : Action[]) {static}
|
||||||
|
+ startNewDay()
|
||||||
|
}
|
||||||
|
abstract class DwarvenMineWorker {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ DwarvenMineWorker()
|
||||||
|
- action(action : Action)
|
||||||
|
+ action(actions : Action[])
|
||||||
|
+ goHome()
|
||||||
|
+ goToMine()
|
||||||
|
+ goToSleep()
|
||||||
|
+ name() : String {abstract}
|
||||||
|
+ wakeUp()
|
||||||
|
+ work() {abstract}
|
||||||
|
}
|
||||||
|
~enum Action {
|
||||||
|
+ GO_HOME {static}
|
||||||
|
+ GO_TO_MINE {static}
|
||||||
|
+ GO_TO_SLEEP {static}
|
||||||
|
+ WAKE_UP {static}
|
||||||
|
+ WORK {static}
|
||||||
|
+ valueOf(name : String) : Action {static}
|
||||||
|
+ values() : Action[] {static}
|
||||||
|
}
|
||||||
|
class DwarvenTunnelDigger {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ DwarvenTunnelDigger()
|
||||||
|
+ name() : String
|
||||||
|
+ work()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DwarvenGoldmineFacade --> "-workers" DwarvenMineWorker
|
||||||
|
Action ..+ DwarvenMineWorker
|
||||||
|
DwarvenCartOperator --|> DwarvenMineWorker
|
||||||
|
DwarvenGoldDigger --|> DwarvenMineWorker
|
||||||
|
DwarvenTunnelDigger --|> DwarvenMineWorker
|
||||||
|
@enduml
|
46
factory-kit/etc/factory-kit.urm.puml
Normal file
46
factory-kit/etc/factory-kit.urm.puml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.factorykit {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Axe {
|
||||||
|
+ Axe()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Bow {
|
||||||
|
+ Bow()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface Builder {
|
||||||
|
+ add(WeaponType, Supplier<Weapon>) {abstract}
|
||||||
|
}
|
||||||
|
class Spear {
|
||||||
|
+ Spear()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Sword {
|
||||||
|
+ Sword()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface Weapon {
|
||||||
|
}
|
||||||
|
interface WeaponFactory {
|
||||||
|
+ create(WeaponType) : Weapon {abstract}
|
||||||
|
+ factory(consumer : Consumer<Builder>) : WeaponFactory {static}
|
||||||
|
}
|
||||||
|
enum WeaponType {
|
||||||
|
+ AXE {static}
|
||||||
|
+ BOW {static}
|
||||||
|
+ SPEAR {static}
|
||||||
|
+ SWORD {static}
|
||||||
|
+ valueOf(name : String) : WeaponType {static}
|
||||||
|
+ values() : WeaponType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Axe ..|> Weapon
|
||||||
|
Bow ..|> Weapon
|
||||||
|
Spear ..|> Weapon
|
||||||
|
Sword ..|> Weapon
|
||||||
|
@enduml
|
56
factory-method/etc/factory-method.urm.puml
Normal file
56
factory-method/etc/factory-method.urm.puml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.factory.method {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- blacksmith : Blacksmith
|
||||||
|
+ App(blacksmith : Blacksmith)
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- manufactureWeapons()
|
||||||
|
}
|
||||||
|
interface Blacksmith {
|
||||||
|
+ manufactureWeapon(WeaponType) : Weapon {abstract}
|
||||||
|
}
|
||||||
|
class ElfBlacksmith {
|
||||||
|
- ELFARSENAL : Map<WeaponType, ElfWeapon> {static}
|
||||||
|
+ ElfBlacksmith()
|
||||||
|
+ manufactureWeapon(weaponType : WeaponType) : Weapon
|
||||||
|
}
|
||||||
|
class ElfWeapon {
|
||||||
|
- weaponType : WeaponType
|
||||||
|
+ ElfWeapon(weaponType : WeaponType)
|
||||||
|
+ getWeaponType() : WeaponType
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class OrcBlacksmith {
|
||||||
|
- ORCARSENAL : Map<WeaponType, OrcWeapon> {static}
|
||||||
|
+ OrcBlacksmith()
|
||||||
|
+ manufactureWeapon(weaponType : WeaponType) : Weapon
|
||||||
|
}
|
||||||
|
class OrcWeapon {
|
||||||
|
- weaponType : WeaponType
|
||||||
|
+ OrcWeapon(weaponType : WeaponType)
|
||||||
|
+ getWeaponType() : WeaponType
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface Weapon {
|
||||||
|
+ getWeaponType() : WeaponType {abstract}
|
||||||
|
}
|
||||||
|
enum WeaponType {
|
||||||
|
+ AXE {static}
|
||||||
|
+ SHORT_SWORD {static}
|
||||||
|
+ SPEAR {static}
|
||||||
|
+ UNDEFINED {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : WeaponType {static}
|
||||||
|
+ values() : WeaponType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ElfWeapon --> "-weaponType" WeaponType
|
||||||
|
OrcWeapon --> "-weaponType" WeaponType
|
||||||
|
App --> "-blacksmith" Blacksmith
|
||||||
|
ElfBlacksmith ..|> Blacksmith
|
||||||
|
ElfWeapon ..|> Weapon
|
||||||
|
OrcBlacksmith ..|> Blacksmith
|
||||||
|
OrcWeapon ..|> Weapon
|
||||||
|
@enduml
|
48
feature-toggle/etc/feature-toggle.urm.puml
Normal file
48
feature-toggle/etc/feature-toggle.urm.puml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.featuretoggle.pattern {
|
||||||
|
interface Service {
|
||||||
|
+ getWelcomeMessage(User) : String {abstract}
|
||||||
|
+ isEnhanced() : boolean {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.featuretoggle.user {
|
||||||
|
class User {
|
||||||
|
- name : String
|
||||||
|
+ User(name : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class UserGroup {
|
||||||
|
- freeGroup : List<User> {static}
|
||||||
|
- paidGroup : List<User> {static}
|
||||||
|
+ UserGroup()
|
||||||
|
+ addUserToFreeGroup(user : User) {static}
|
||||||
|
+ addUserToPaidGroup(user : User) {static}
|
||||||
|
+ isPaid(user : User) : boolean {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.featuretoggle.pattern.tieredversion {
|
||||||
|
class TieredFeatureToggleVersion {
|
||||||
|
+ TieredFeatureToggleVersion()
|
||||||
|
+ getWelcomeMessage(user : User) : String
|
||||||
|
+ isEnhanced() : boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.featuretoggle.pattern.propertiesversion {
|
||||||
|
class PropertiesFeatureToggleVersion {
|
||||||
|
- isEnhanced : boolean
|
||||||
|
+ PropertiesFeatureToggleVersion(properties : Properties)
|
||||||
|
+ getWelcomeMessage(user : User) : String
|
||||||
|
+ isEnhanced() : boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.featuretoggle {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UserGroup --> "-freeGroup" User
|
||||||
|
PropertiesFeatureToggleVersion ..|> Service
|
||||||
|
TieredFeatureToggleVersion ..|> Service
|
||||||
|
@enduml
|
72
fluentinterface/etc/fluentinterface.urm.puml
Normal file
72
fluentinterface/etc/fluentinterface.urm.puml
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.fluentinterface.fluentiterable.simple {
|
||||||
|
class SimpleFluentIterable<E> {
|
||||||
|
- iterable : Iterable<E>
|
||||||
|
# SimpleFluentIterable<E>(iterable : Iterable<E>)
|
||||||
|
+ asList() : List<E>
|
||||||
|
+ filter(predicate : Predicate<? super E>) : FluentIterable<E>
|
||||||
|
+ first() : Optional<E>
|
||||||
|
+ first(count : int) : FluentIterable<E>
|
||||||
|
+ forEach(action : Consumer<? super E>)
|
||||||
|
+ from(iterable : Iterable<E>) : FluentIterable<E> {static}
|
||||||
|
+ fromCopyOf(iterable : Iterable<E>) : FluentIterable<E> {static}
|
||||||
|
+ getRemainingElementsCount() : int
|
||||||
|
+ iterator() : Iterator<E>
|
||||||
|
+ last() : Optional<E>
|
||||||
|
+ last(count : int) : FluentIterable<E>
|
||||||
|
+ map(function : Function<? super E, T>) : FluentIterable<T>
|
||||||
|
+ spliterator() : Spliterator<E>
|
||||||
|
+ toList(iterator : Iterator<E>) : List<E> {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.fluentinterface.app {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- negatives() : Predicate<? super Integer> {static}
|
||||||
|
- positives() : Predicate<? super Integer> {static}
|
||||||
|
- prettyPrint(delimiter : String, prefix : String, iterable : Iterable<E>) {static}
|
||||||
|
- prettyPrint(prefix : String, iterable : Iterable<E>) {static}
|
||||||
|
- transformToString() : Function<Integer, String> {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.fluentinterface.fluentiterable.lazy {
|
||||||
|
abstract class DecoratingIterator<E> {
|
||||||
|
# fromIterator : Iterator<E>
|
||||||
|
- next : E
|
||||||
|
+ DecoratingIterator<E>(fromIterator : Iterator<E>)
|
||||||
|
+ computeNext() : E {abstract}
|
||||||
|
+ hasNext() : boolean
|
||||||
|
+ next() : E
|
||||||
|
}
|
||||||
|
class LazyFluentIterable<E> {
|
||||||
|
- iterable : Iterable<E>
|
||||||
|
# LazyFluentIterable<E>()
|
||||||
|
# LazyFluentIterable<E>(iterable : Iterable<E>)
|
||||||
|
+ asList() : List<E>
|
||||||
|
+ filter(predicate : Predicate<? super E>) : FluentIterable<E>
|
||||||
|
+ first() : Optional<E>
|
||||||
|
+ first(count : int) : FluentIterable<E>
|
||||||
|
+ from(iterable : Iterable<E>) : FluentIterable<E> {static}
|
||||||
|
+ iterator() : Iterator<E>
|
||||||
|
+ last() : Optional<E>
|
||||||
|
+ last(count : int) : FluentIterable<E>
|
||||||
|
+ map(function : Function<? super E, T>) : FluentIterable<T>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.fluentinterface.fluentiterable {
|
||||||
|
interface FluentIterable<E> {
|
||||||
|
+ asList() : List<E> {abstract}
|
||||||
|
+ copyToList(iterable : Iterable<E>) : List<E> {static}
|
||||||
|
+ filter(Predicate<? super E>) : FluentIterable<E> {abstract}
|
||||||
|
+ first() : Optional<E> {abstract}
|
||||||
|
+ first(int) : FluentIterable<E> {abstract}
|
||||||
|
+ last() : Optional<E> {abstract}
|
||||||
|
+ last(int) : FluentIterable<E> {abstract}
|
||||||
|
+ map(Function<? super E, T>) : FluentIterable<T> {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LazyFluentIterable ..|> FluentIterable
|
||||||
|
SimpleFluentIterable ..|> FluentIterable
|
||||||
|
@enduml
|
117
flux/etc/flux.urm.puml
Normal file
117
flux/etc/flux.urm.puml
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.flux.view {
|
||||||
|
class ContentView {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- content : Content
|
||||||
|
+ ContentView()
|
||||||
|
+ render()
|
||||||
|
+ storeChanged(store : Store)
|
||||||
|
}
|
||||||
|
class MenuView {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- selected : MenuItem
|
||||||
|
+ MenuView()
|
||||||
|
+ itemClicked(item : MenuItem)
|
||||||
|
+ render()
|
||||||
|
+ storeChanged(store : Store)
|
||||||
|
}
|
||||||
|
interface View {
|
||||||
|
+ render() {abstract}
|
||||||
|
+ storeChanged(Store) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.flux.action {
|
||||||
|
abstract class Action {
|
||||||
|
- type : ActionType
|
||||||
|
+ Action(type : ActionType)
|
||||||
|
+ getType() : ActionType
|
||||||
|
}
|
||||||
|
enum ActionType {
|
||||||
|
+ CONTENT_CHANGED {static}
|
||||||
|
+ MENU_ITEM_SELECTED {static}
|
||||||
|
+ valueOf(name : String) : ActionType {static}
|
||||||
|
+ values() : ActionType[] {static}
|
||||||
|
}
|
||||||
|
enum Content {
|
||||||
|
+ COMPANY {static}
|
||||||
|
+ PRODUCTS {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Content {static}
|
||||||
|
+ values() : Content[] {static}
|
||||||
|
}
|
||||||
|
class ContentAction {
|
||||||
|
- content : Content
|
||||||
|
+ ContentAction(content : Content)
|
||||||
|
+ getContent() : Content
|
||||||
|
}
|
||||||
|
class MenuAction {
|
||||||
|
- menuItem : MenuItem
|
||||||
|
+ MenuAction(menuItem : MenuItem)
|
||||||
|
+ getMenuItem() : MenuItem
|
||||||
|
}
|
||||||
|
enum MenuItem {
|
||||||
|
+ COMPANY {static}
|
||||||
|
+ HOME {static}
|
||||||
|
+ PRODUCTS {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : MenuItem {static}
|
||||||
|
+ values() : MenuItem[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.flux.app {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.flux.store {
|
||||||
|
class ContentStore {
|
||||||
|
- content : Content
|
||||||
|
+ ContentStore()
|
||||||
|
+ getContent() : Content
|
||||||
|
+ onAction(action : Action)
|
||||||
|
}
|
||||||
|
class MenuStore {
|
||||||
|
- selected : MenuItem
|
||||||
|
+ MenuStore()
|
||||||
|
+ getSelected() : MenuItem
|
||||||
|
+ onAction(action : Action)
|
||||||
|
}
|
||||||
|
abstract class Store {
|
||||||
|
- views : List<View>
|
||||||
|
+ Store()
|
||||||
|
# notifyChange()
|
||||||
|
+ onAction(Action) {abstract}
|
||||||
|
+ registerView(view : View)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.flux.dispatcher {
|
||||||
|
class Dispatcher {
|
||||||
|
- instance : Dispatcher {static}
|
||||||
|
- stores : List<Store>
|
||||||
|
- Dispatcher()
|
||||||
|
- dispatchAction(action : Action)
|
||||||
|
+ getInstance() : Dispatcher {static}
|
||||||
|
+ menuItemSelected(menuItem : MenuItem)
|
||||||
|
+ registerStore(store : Store)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MenuAction --> "-menuItem" MenuItem
|
||||||
|
Action --> "-type" ActionType
|
||||||
|
MenuStore --> "-selected" MenuItem
|
||||||
|
Dispatcher --> "-instance" Dispatcher
|
||||||
|
ContentView --> "-content" Content
|
||||||
|
Dispatcher --> "-stores" Store
|
||||||
|
MenuView --> "-selected" MenuItem
|
||||||
|
Store --> "-views" View
|
||||||
|
ContentStore --> "-content" Content
|
||||||
|
ContentAction --> "-content" Content
|
||||||
|
ContentAction --|> Action
|
||||||
|
MenuAction --|> Action
|
||||||
|
ContentStore --|> Store
|
||||||
|
MenuStore --|> Store
|
||||||
|
ContentView ..|> View
|
||||||
|
MenuView ..|> View
|
||||||
|
@enduml
|
65
flyweight/etc/flyweight.urm.puml
Normal file
65
flyweight/etc/flyweight.urm.puml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.flyweight {
|
||||||
|
class AlchemistShop {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- bottomShelf : List<Potion>
|
||||||
|
- topShelf : List<Potion>
|
||||||
|
+ AlchemistShop()
|
||||||
|
+ enumerate()
|
||||||
|
+ getBottomShelf() : List<Potion>
|
||||||
|
+ getTopShelf() : List<Potion>
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class HealingPotion {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ HealingPotion()
|
||||||
|
+ drink()
|
||||||
|
}
|
||||||
|
class HolyWaterPotion {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ HolyWaterPotion()
|
||||||
|
+ drink()
|
||||||
|
}
|
||||||
|
class InvisibilityPotion {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ InvisibilityPotion()
|
||||||
|
+ drink()
|
||||||
|
}
|
||||||
|
class PoisonPotion {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ PoisonPotion()
|
||||||
|
+ drink()
|
||||||
|
}
|
||||||
|
interface Potion {
|
||||||
|
+ drink() {abstract}
|
||||||
|
}
|
||||||
|
class PotionFactory {
|
||||||
|
- potions : Map<PotionType, Potion>
|
||||||
|
+ PotionFactory()
|
||||||
|
~ createPotion(type : PotionType) : Potion
|
||||||
|
}
|
||||||
|
enum PotionType {
|
||||||
|
+ HEALING {static}
|
||||||
|
+ HOLY_WATER {static}
|
||||||
|
+ INVISIBILITY {static}
|
||||||
|
+ POISON {static}
|
||||||
|
+ STRENGTH {static}
|
||||||
|
+ valueOf(name : String) : PotionType {static}
|
||||||
|
+ values() : PotionType[] {static}
|
||||||
|
}
|
||||||
|
class StrengthPotion {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ StrengthPotion()
|
||||||
|
+ drink()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AlchemistShop --> "-topShelf" Potion
|
||||||
|
HealingPotion ..|> Potion
|
||||||
|
HolyWaterPotion ..|> Potion
|
||||||
|
InvisibilityPotion ..|> Potion
|
||||||
|
PoisonPotion ..|> Potion
|
||||||
|
StrengthPotion ..|> Potion
|
||||||
|
@enduml
|
53
front-controller/etc/front-controller.urm.puml
Normal file
53
front-controller/etc/front-controller.urm.puml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.front.controller {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class ArcherCommand {
|
||||||
|
+ ArcherCommand()
|
||||||
|
+ process()
|
||||||
|
}
|
||||||
|
class ArcherView {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ ArcherView()
|
||||||
|
+ display()
|
||||||
|
}
|
||||||
|
class CatapultCommand {
|
||||||
|
+ CatapultCommand()
|
||||||
|
+ process()
|
||||||
|
}
|
||||||
|
class CatapultView {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ CatapultView()
|
||||||
|
+ display()
|
||||||
|
}
|
||||||
|
interface Command {
|
||||||
|
+ process() {abstract}
|
||||||
|
}
|
||||||
|
class ErrorView {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ ErrorView()
|
||||||
|
+ display()
|
||||||
|
}
|
||||||
|
class FrontController {
|
||||||
|
+ FrontController()
|
||||||
|
- getCommand(request : String) : Command
|
||||||
|
- getCommandClass(request : String) : Class<?> {static}
|
||||||
|
+ handleRequest(request : String)
|
||||||
|
}
|
||||||
|
class UnknownCommand {
|
||||||
|
+ UnknownCommand()
|
||||||
|
+ process()
|
||||||
|
}
|
||||||
|
interface View {
|
||||||
|
+ display() {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArcherCommand ..|> Command
|
||||||
|
ArcherView ..|> View
|
||||||
|
CatapultCommand ..|> Command
|
||||||
|
CatapultView ..|> View
|
||||||
|
ErrorView ..|> View
|
||||||
|
UnknownCommand ..|> Command
|
||||||
|
@enduml
|
63
game-loop/etc/game-loop.urm.puml
Normal file
63
game-loop/etc/game-loop.urm.puml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.gameloop {
|
||||||
|
class App {
|
||||||
|
- GAME_LOOP_DURATION_TIME : int {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Bullet {
|
||||||
|
- position : float
|
||||||
|
+ Bullet()
|
||||||
|
+ getPosition() : float
|
||||||
|
+ setPosition(position : float)
|
||||||
|
}
|
||||||
|
class FixedStepGameLoop {
|
||||||
|
- MS_PER_FRAME : long {static}
|
||||||
|
+ FixedStepGameLoop()
|
||||||
|
# processGameLoop()
|
||||||
|
# update()
|
||||||
|
}
|
||||||
|
class FrameBasedGameLoop {
|
||||||
|
+ FrameBasedGameLoop()
|
||||||
|
# processGameLoop()
|
||||||
|
# update()
|
||||||
|
}
|
||||||
|
class GameController {
|
||||||
|
# bullet : Bullet
|
||||||
|
+ GameController()
|
||||||
|
+ getBulletPosition() : float
|
||||||
|
+ moveBullet(offset : float)
|
||||||
|
}
|
||||||
|
abstract class GameLoop {
|
||||||
|
# controller : GameController
|
||||||
|
- gameThread : Thread
|
||||||
|
# logger : Logger
|
||||||
|
# status : GameStatus
|
||||||
|
+ GameLoop()
|
||||||
|
+ isGameRunning() : boolean
|
||||||
|
# processGameLoop() {abstract}
|
||||||
|
# processInput()
|
||||||
|
# render()
|
||||||
|
+ run()
|
||||||
|
+ stop()
|
||||||
|
}
|
||||||
|
enum GameStatus {
|
||||||
|
+ RUNNING {static}
|
||||||
|
+ STOPPED {static}
|
||||||
|
+ valueOf(name : String) : GameStatus {static}
|
||||||
|
+ values() : GameStatus[] {static}
|
||||||
|
}
|
||||||
|
class VariableStepGameLoop {
|
||||||
|
+ VariableStepGameLoop()
|
||||||
|
# processGameLoop()
|
||||||
|
# update(elapsedTime : Long)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameLoop --> "-status" GameStatus
|
||||||
|
GameController --> "-bullet" Bullet
|
||||||
|
GameLoop --> "-controller" GameController
|
||||||
|
FixedStepGameLoop --|> GameLoop
|
||||||
|
FrameBasedGameLoop --|> GameLoop
|
||||||
|
VariableStepGameLoop --|> GameLoop
|
||||||
|
@enduml
|
15
guarded-suspension/etc/guarded-suspension.urm.puml
Normal file
15
guarded-suspension/etc/guarded-suspension.urm.puml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.guarded.suspension {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class GuardedQueue {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- sourceList : Queue<Integer>
|
||||||
|
+ GuardedQueue()
|
||||||
|
+ get() : Integer
|
||||||
|
+ put(e : Integer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
33
half-sync-half-async/etc/half-sync-half-async.urm.puml
Normal file
33
half-sync-half-async/etc/half-sync-half-async.urm.puml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.halfsynchalfasync {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
- ap(i : long) : long {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
~class ArithmeticSumTask {
|
||||||
|
- numberOfElements : long
|
||||||
|
+ ArithmeticSumTask(numberOfElements : long)
|
||||||
|
+ call() : Long
|
||||||
|
+ onError(throwable : Throwable)
|
||||||
|
+ onPostCall(result : Long)
|
||||||
|
+ onPreCall()
|
||||||
|
}
|
||||||
|
interface AsyncTask<O> {
|
||||||
|
+ call() : O {abstract}
|
||||||
|
+ onError(Throwable) {abstract}
|
||||||
|
+ onPostCall(O) {abstract}
|
||||||
|
+ onPreCall() {abstract}
|
||||||
|
}
|
||||||
|
class AsynchronousService {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- service : ExecutorService
|
||||||
|
+ AsynchronousService(workQueue : BlockingQueue<Runnable>)
|
||||||
|
+ close()
|
||||||
|
+ execute(task : AsyncTask<T>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArithmeticSumTask ..+ App
|
||||||
|
ArithmeticSumTask ..|> AsyncTask
|
||||||
|
@enduml
|
305
hexagonal/etc/hexagonal.urm.puml
Normal file
305
hexagonal/etc/hexagonal.urm.puml
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.hexagonal.sampledata {
|
||||||
|
class SampleData {
|
||||||
|
- PLAYERS : List<PlayerDetails> {static}
|
||||||
|
- RANDOM : Random {static}
|
||||||
|
+ SampleData()
|
||||||
|
- getRandomPlayerDetails() : PlayerDetails {static}
|
||||||
|
+ submitTickets(lotteryService : LotteryService, numTickets : int) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.hexagonal.service {
|
||||||
|
class ConsoleLottery {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ ConsoleLottery()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- printMainMenu() {static}
|
||||||
|
- readString(scanner : Scanner) : String {static}
|
||||||
|
}
|
||||||
|
interface LotteryConsoleService {
|
||||||
|
+ addFundsToLotteryAccount(WireTransfers, Scanner) {abstract}
|
||||||
|
+ checkTicket(LotteryService, Scanner) {abstract}
|
||||||
|
+ queryLotteryAccountFunds(WireTransfers, Scanner) {abstract}
|
||||||
|
+ submitTicket(LotteryService, Scanner) {abstract}
|
||||||
|
}
|
||||||
|
class LotteryConsoleServiceImpl {
|
||||||
|
- logger : Logger
|
||||||
|
+ LotteryConsoleServiceImpl(logger : Logger)
|
||||||
|
+ addFundsToLotteryAccount(bank : WireTransfers, scanner : Scanner)
|
||||||
|
+ checkTicket(service : LotteryService, scanner : Scanner)
|
||||||
|
+ queryLotteryAccountFunds(bank : WireTransfers, scanner : Scanner)
|
||||||
|
- readString(scanner : Scanner) : String
|
||||||
|
+ submitTicket(service : LotteryService, scanner : Scanner)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.hexagonal.mongo {
|
||||||
|
class MongoConnectionPropertiesLoader {
|
||||||
|
- DEFAULT_HOST : String {static}
|
||||||
|
- DEFAULT_PORT : int {static}
|
||||||
|
+ MongoConnectionPropertiesLoader()
|
||||||
|
+ load() {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.hexagonal.domain {
|
||||||
|
class LotteryAdministration {
|
||||||
|
- notifications : LotteryEventLog
|
||||||
|
- repository : LotteryTicketRepository
|
||||||
|
- wireTransfers : WireTransfers
|
||||||
|
+ LotteryAdministration(repository : LotteryTicketRepository, notifications : LotteryEventLog, wireTransfers : WireTransfers)
|
||||||
|
+ getAllSubmittedTickets() : Map<LotteryTicketId, LotteryTicket>
|
||||||
|
+ performLottery() : LotteryNumbers
|
||||||
|
+ resetLottery()
|
||||||
|
}
|
||||||
|
class LotteryConstants {
|
||||||
|
+ PLAYER_MAX_BALANCE : int {static}
|
||||||
|
+ PRIZE_AMOUNT : int {static}
|
||||||
|
+ SERVICE_BANK_ACCOUNT : String {static}
|
||||||
|
+ SERVICE_BANK_ACCOUNT_BALANCE : int {static}
|
||||||
|
+ TICKET_PRIZE : int {static}
|
||||||
|
- LotteryConstants()
|
||||||
|
}
|
||||||
|
class LotteryNumbers {
|
||||||
|
+ MAX_NUMBER : int {static}
|
||||||
|
+ MIN_NUMBER : int {static}
|
||||||
|
+ NUM_NUMBERS : int {static}
|
||||||
|
- numbers : Set<Integer>
|
||||||
|
- LotteryNumbers()
|
||||||
|
- LotteryNumbers(givenNumbers : Set<Integer>)
|
||||||
|
+ create(givenNumbers : Set<Integer>) : LotteryNumbers {static}
|
||||||
|
+ createRandom() : LotteryNumbers {static}
|
||||||
|
+ equals(obj : Object) : boolean
|
||||||
|
- generateRandomNumbers()
|
||||||
|
+ getNumbers() : Set<Integer>
|
||||||
|
+ getNumbersAsString() : String
|
||||||
|
+ hashCode() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
-class RandomNumberGenerator {
|
||||||
|
- randomIterator : OfInt
|
||||||
|
+ RandomNumberGenerator(min : int, max : int)
|
||||||
|
+ nextInt() : int
|
||||||
|
}
|
||||||
|
class LotteryService {
|
||||||
|
- notifications : LotteryEventLog
|
||||||
|
- repository : LotteryTicketRepository
|
||||||
|
- wireTransfers : WireTransfers
|
||||||
|
+ LotteryService(repository : LotteryTicketRepository, notifications : LotteryEventLog, wireTransfers : WireTransfers)
|
||||||
|
+ checkTicketForPrize(id : LotteryTicketId, winningNumbers : LotteryNumbers) : LotteryTicketCheckResult
|
||||||
|
+ submitTicket(ticket : LotteryTicket) : Optional<LotteryTicketId>
|
||||||
|
}
|
||||||
|
class LotteryTicket {
|
||||||
|
- id : LotteryTicketId
|
||||||
|
- lotteryNumbers : LotteryNumbers
|
||||||
|
- playerDetails : PlayerDetails
|
||||||
|
+ LotteryTicket(id : LotteryTicketId, details : PlayerDetails, numbers : LotteryNumbers)
|
||||||
|
+ equals(obj : Object) : boolean
|
||||||
|
+ getId() : LotteryTicketId
|
||||||
|
+ getNumbers() : LotteryNumbers
|
||||||
|
+ getPlayerDetails() : PlayerDetails
|
||||||
|
+ hashCode() : int
|
||||||
|
+ setId(id : LotteryTicketId)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class LotteryTicketCheckResult {
|
||||||
|
- checkResult : CheckResult
|
||||||
|
- prizeAmount : int
|
||||||
|
+ LotteryTicketCheckResult(result : CheckResult)
|
||||||
|
+ LotteryTicketCheckResult(result : CheckResult, amount : int)
|
||||||
|
+ equals(obj : Object) : boolean
|
||||||
|
+ getPrizeAmount() : int
|
||||||
|
+ getResult() : CheckResult
|
||||||
|
+ hashCode() : int
|
||||||
|
}
|
||||||
|
enum CheckResult {
|
||||||
|
+ NO_PRIZE {static}
|
||||||
|
+ TICKET_NOT_SUBMITTED {static}
|
||||||
|
+ WIN_PRIZE {static}
|
||||||
|
+ valueOf(name : String) : CheckResult {static}
|
||||||
|
+ values() : CheckResult[] {static}
|
||||||
|
}
|
||||||
|
class LotteryTicketId {
|
||||||
|
- id : int
|
||||||
|
- numAllocated : AtomicInteger {static}
|
||||||
|
+ LotteryTicketId()
|
||||||
|
+ LotteryTicketId(id : int)
|
||||||
|
+ equals(o : Object) : boolean
|
||||||
|
+ getId() : int
|
||||||
|
+ hashCode() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class LotteryUtils {
|
||||||
|
- LotteryUtils()
|
||||||
|
+ checkTicketForPrize(repository : LotteryTicketRepository, id : LotteryTicketId, winningNumbers : LotteryNumbers) : LotteryTicketCheckResult {static}
|
||||||
|
}
|
||||||
|
class PlayerDetails {
|
||||||
|
- bankAccountNumber : String
|
||||||
|
- emailAddress : String
|
||||||
|
- phoneNumber : String
|
||||||
|
+ PlayerDetails(email : String, bankAccount : String, phone : String)
|
||||||
|
+ equals(obj : Object) : boolean
|
||||||
|
+ getBankAccount() : String
|
||||||
|
+ getEmail() : String
|
||||||
|
+ getPhoneNumber() : String
|
||||||
|
+ hashCode() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.hexagonal.banking {
|
||||||
|
class InMemoryBank {
|
||||||
|
- accounts : Map<String, Integer> {static}
|
||||||
|
+ InMemoryBank()
|
||||||
|
+ getFunds(bankAccount : String) : int
|
||||||
|
+ setFunds(bankAccount : String, amount : int)
|
||||||
|
+ transferFunds(amount : int, sourceAccount : String, destinationAccount : String) : boolean
|
||||||
|
}
|
||||||
|
class MongoBank {
|
||||||
|
- DEFAULT_ACCOUNTS_COLLECTION : String {static}
|
||||||
|
- DEFAULT_DB : String {static}
|
||||||
|
- accountsCollection : MongoCollection<Document>
|
||||||
|
- database : MongoDatabase
|
||||||
|
- mongoClient : MongoClient
|
||||||
|
+ MongoBank()
|
||||||
|
+ MongoBank(dbName : String, accountsCollectionName : String)
|
||||||
|
+ connect()
|
||||||
|
+ connect(dbName : String, accountsCollectionName : String)
|
||||||
|
+ getAccountsCollection() : MongoCollection<Document>
|
||||||
|
+ getFunds(bankAccount : String) : int
|
||||||
|
+ getMongoClient() : MongoClient
|
||||||
|
+ getMongoDatabase() : MongoDatabase
|
||||||
|
+ setFunds(bankAccount : String, amount : int)
|
||||||
|
+ transferFunds(amount : int, sourceAccount : String, destinationAccount : String) : boolean
|
||||||
|
}
|
||||||
|
interface WireTransfers {
|
||||||
|
+ getFunds(String) : int {abstract}
|
||||||
|
+ setFunds(String, int) {abstract}
|
||||||
|
+ transferFunds(int, String, String) : boolean {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.hexagonal.database {
|
||||||
|
class InMemoryTicketRepository {
|
||||||
|
- tickets : Map<LotteryTicketId, LotteryTicket> {static}
|
||||||
|
+ InMemoryTicketRepository()
|
||||||
|
+ deleteAll()
|
||||||
|
+ findAll() : Map<LotteryTicketId, LotteryTicket>
|
||||||
|
+ findById(id : LotteryTicketId) : Optional<LotteryTicket>
|
||||||
|
+ save(ticket : LotteryTicket) : Optional<LotteryTicketId>
|
||||||
|
}
|
||||||
|
interface LotteryTicketRepository {
|
||||||
|
+ deleteAll() {abstract}
|
||||||
|
+ findAll() : Map<LotteryTicketId, LotteryTicket> {abstract}
|
||||||
|
+ findById(LotteryTicketId) : Optional<LotteryTicket> {abstract}
|
||||||
|
+ save(LotteryTicket) : Optional<LotteryTicketId> {abstract}
|
||||||
|
}
|
||||||
|
class MongoTicketRepository {
|
||||||
|
- DEFAULT_COUNTERS_COLLECTION : String {static}
|
||||||
|
- DEFAULT_DB : String {static}
|
||||||
|
- DEFAULT_TICKETS_COLLECTION : String {static}
|
||||||
|
- countersCollection : MongoCollection<Document>
|
||||||
|
- database : MongoDatabase
|
||||||
|
- mongoClient : MongoClient
|
||||||
|
- ticketsCollection : MongoCollection<Document>
|
||||||
|
+ MongoTicketRepository()
|
||||||
|
+ MongoTicketRepository(dbName : String, ticketsCollectionName : String, countersCollectionName : String)
|
||||||
|
+ connect()
|
||||||
|
+ connect(dbName : String, ticketsCollectionName : String, countersCollectionName : String)
|
||||||
|
+ deleteAll()
|
||||||
|
- docToTicket(doc : Document) : LotteryTicket
|
||||||
|
+ findAll() : Map<LotteryTicketId, LotteryTicket>
|
||||||
|
+ findById(id : LotteryTicketId) : Optional<LotteryTicket>
|
||||||
|
+ getCountersCollection() : MongoCollection<Document>
|
||||||
|
+ getNextId() : int
|
||||||
|
+ getTicketsCollection() : MongoCollection<Document>
|
||||||
|
- initCounters()
|
||||||
|
+ save(ticket : LotteryTicket) : Optional<LotteryTicketId>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.hexagonal {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.hexagonal.administration {
|
||||||
|
class ConsoleAdministration {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ ConsoleAdministration()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- printMainMenu() {static}
|
||||||
|
- readString(scanner : Scanner) : String {static}
|
||||||
|
}
|
||||||
|
interface ConsoleAdministrationSrv {
|
||||||
|
+ getAllSubmittedTickets() {abstract}
|
||||||
|
+ performLottery() {abstract}
|
||||||
|
+ resetLottery() {abstract}
|
||||||
|
}
|
||||||
|
class ConsoleAdministrationSrvImpl {
|
||||||
|
- administration : LotteryAdministration
|
||||||
|
- logger : Logger
|
||||||
|
+ ConsoleAdministrationSrvImpl(administration : LotteryAdministration, logger : Logger)
|
||||||
|
+ getAllSubmittedTickets()
|
||||||
|
+ performLottery()
|
||||||
|
+ resetLottery()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.hexagonal.eventlog {
|
||||||
|
interface LotteryEventLog {
|
||||||
|
+ prizeError(PlayerDetails, int) {abstract}
|
||||||
|
+ ticketDidNotWin(PlayerDetails) {abstract}
|
||||||
|
+ ticketSubmitError(PlayerDetails) {abstract}
|
||||||
|
+ ticketSubmitted(PlayerDetails) {abstract}
|
||||||
|
+ ticketWon(PlayerDetails, int) {abstract}
|
||||||
|
}
|
||||||
|
class MongoEventLog {
|
||||||
|
- DEFAULT_DB : String {static}
|
||||||
|
- DEFAULT_EVENTS_COLLECTION : String {static}
|
||||||
|
- database : MongoDatabase
|
||||||
|
- eventsCollection : MongoCollection<Document>
|
||||||
|
- mongoClient : MongoClient
|
||||||
|
- stdOutEventLog : StdOutEventLog
|
||||||
|
+ MongoEventLog()
|
||||||
|
+ MongoEventLog(dbName : String, eventsCollectionName : String)
|
||||||
|
+ connect()
|
||||||
|
+ connect(dbName : String, eventsCollectionName : String)
|
||||||
|
+ getEventsCollection() : MongoCollection<Document>
|
||||||
|
+ getMongoClient() : MongoClient
|
||||||
|
+ getMongoDatabase() : MongoDatabase
|
||||||
|
+ prizeError(details : PlayerDetails, prizeAmount : int)
|
||||||
|
+ ticketDidNotWin(details : PlayerDetails)
|
||||||
|
+ ticketSubmitError(details : PlayerDetails)
|
||||||
|
+ ticketSubmitted(details : PlayerDetails)
|
||||||
|
+ ticketWon(details : PlayerDetails, prizeAmount : int)
|
||||||
|
}
|
||||||
|
class StdOutEventLog {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ StdOutEventLog()
|
||||||
|
+ prizeError(details : PlayerDetails, prizeAmount : int)
|
||||||
|
+ ticketDidNotWin(details : PlayerDetails)
|
||||||
|
+ ticketSubmitError(details : PlayerDetails)
|
||||||
|
+ ticketSubmitted(details : PlayerDetails)
|
||||||
|
+ ticketWon(details : PlayerDetails, prizeAmount : int)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LotteryTicket --> "-playerDetails" PlayerDetails
|
||||||
|
MongoEventLog --> "-stdOutEventLog" StdOutEventLog
|
||||||
|
LotteryService --> "-wireTransfers" WireTransfers
|
||||||
|
LotteryAdministration --> "-notifications" LotteryEventLog
|
||||||
|
LotteryAdministration --> "-wireTransfers" WireTransfers
|
||||||
|
LotteryTicket --> "-id" LotteryTicketId
|
||||||
|
LotteryAdministration --> "-repository" LotteryTicketRepository
|
||||||
|
LotteryService --> "-notifications" LotteryEventLog
|
||||||
|
LotteryTicket --> "-lotteryNumbers" LotteryNumbers
|
||||||
|
SampleData --> "-PLAYERS" PlayerDetails
|
||||||
|
ConsoleAdministrationSrvImpl --> "-administration" LotteryAdministration
|
||||||
|
RandomNumberGenerator ..+ LotteryNumbers
|
||||||
|
LotteryService --> "-repository" LotteryTicketRepository
|
||||||
|
CheckResult ..+ LotteryTicketCheckResult
|
||||||
|
LotteryTicketCheckResult --> "-checkResult" CheckResult
|
||||||
|
ConsoleAdministrationSrvImpl ..|> ConsoleAdministrationSrv
|
||||||
|
InMemoryBank ..|> WireTransfers
|
||||||
|
MongoBank ..|> WireTransfers
|
||||||
|
InMemoryTicketRepository ..|> LotteryTicketRepository
|
||||||
|
MongoTicketRepository ..|> LotteryTicketRepository
|
||||||
|
MongoEventLog ..|> LotteryEventLog
|
||||||
|
StdOutEventLog ..|> LotteryEventLog
|
||||||
|
LotteryConsoleServiceImpl ..|> LotteryConsoleService
|
||||||
|
@enduml
|
88
intercepting-filter/etc/intercepting-filter.urm.puml
Normal file
88
intercepting-filter/etc/intercepting-filter.urm.puml
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.intercepting.filter {
|
||||||
|
abstract class AbstractFilter {
|
||||||
|
- next : Filter
|
||||||
|
+ AbstractFilter()
|
||||||
|
+ AbstractFilter(next : Filter)
|
||||||
|
+ execute(order : Order) : String
|
||||||
|
+ getLast() : Filter
|
||||||
|
+ getNext() : Filter
|
||||||
|
+ setNext(filter : Filter)
|
||||||
|
}
|
||||||
|
class AddressFilter {
|
||||||
|
+ AddressFilter()
|
||||||
|
+ execute(order : Order) : String
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class ContactFilter {
|
||||||
|
+ ContactFilter()
|
||||||
|
+ execute(order : Order) : String
|
||||||
|
}
|
||||||
|
class DepositFilter {
|
||||||
|
+ DepositFilter()
|
||||||
|
+ execute(order : Order) : String
|
||||||
|
}
|
||||||
|
interface Filter {
|
||||||
|
+ execute(Order) : String {abstract}
|
||||||
|
+ getLast() : Filter {abstract}
|
||||||
|
+ getNext() : Filter {abstract}
|
||||||
|
+ setNext(Filter) {abstract}
|
||||||
|
}
|
||||||
|
class FilterChain {
|
||||||
|
- chain : Filter
|
||||||
|
+ FilterChain()
|
||||||
|
+ addFilter(filter : Filter)
|
||||||
|
+ execute(order : Order) : String
|
||||||
|
}
|
||||||
|
class FilterManager {
|
||||||
|
- filterChain : FilterChain
|
||||||
|
+ FilterManager()
|
||||||
|
+ addFilter(filter : Filter)
|
||||||
|
+ filterRequest(order : Order) : String
|
||||||
|
}
|
||||||
|
class NameFilter {
|
||||||
|
+ NameFilter()
|
||||||
|
+ execute(order : Order) : String
|
||||||
|
}
|
||||||
|
class Order {
|
||||||
|
- address : String
|
||||||
|
- contactNumber : String
|
||||||
|
- depositNumber : String
|
||||||
|
- name : String
|
||||||
|
- orderItem : String
|
||||||
|
+ Order()
|
||||||
|
+ Order(name : String, contactNumber : String, address : String, depositNumber : String, order : String)
|
||||||
|
+ getAddress() : String
|
||||||
|
+ getContactNumber() : String
|
||||||
|
+ getDepositNumber() : String
|
||||||
|
+ getName() : String
|
||||||
|
+ getOrderItem() : String
|
||||||
|
+ setAddress(address : String)
|
||||||
|
+ setContactNumber(contactNumber : String)
|
||||||
|
+ setDepositNumber(depositNumber : String)
|
||||||
|
+ setName(name : String)
|
||||||
|
+ setOrderItem(order : String)
|
||||||
|
}
|
||||||
|
class OrderFilter {
|
||||||
|
+ OrderFilter()
|
||||||
|
+ execute(order : Order) : String
|
||||||
|
}
|
||||||
|
~class DListener {
|
||||||
|
~ DListener()
|
||||||
|
+ actionPerformed(e : ActionEvent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractFilter --> "-next" Filter
|
||||||
|
DListener --+ Target
|
||||||
|
FilterManager --> "-filterChain" FilterChain
|
||||||
|
FilterChain --> "-chain" Filter
|
||||||
|
AbstractFilter ..|> Filter
|
||||||
|
AddressFilter --|> AbstractFilter
|
||||||
|
ContactFilter --|> AbstractFilter
|
||||||
|
DepositFilter --|> AbstractFilter
|
||||||
|
NameFilter --|> AbstractFilter
|
||||||
|
OrderFilter --|> AbstractFilter
|
||||||
|
@enduml
|
51
interpreter/etc/interpreter.urm.puml
Normal file
51
interpreter/etc/interpreter.urm.puml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.interpreter {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ getOperatorInstance(s : String, left : Expression, right : Expression) : Expression {static}
|
||||||
|
+ isOperator(s : String) : boolean {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
abstract class Expression {
|
||||||
|
+ Expression()
|
||||||
|
+ interpret() : int {abstract}
|
||||||
|
+ toString() : String {abstract}
|
||||||
|
}
|
||||||
|
class MinusExpression {
|
||||||
|
- leftExpression : Expression
|
||||||
|
- rightExpression : Expression
|
||||||
|
+ MinusExpression(leftExpression : Expression, rightExpression : Expression)
|
||||||
|
+ interpret() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class MultiplyExpression {
|
||||||
|
- leftExpression : Expression
|
||||||
|
- rightExpression : Expression
|
||||||
|
+ MultiplyExpression(leftExpression : Expression, rightExpression : Expression)
|
||||||
|
+ interpret() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class NumberExpression {
|
||||||
|
- number : int
|
||||||
|
+ NumberExpression(number : int)
|
||||||
|
+ NumberExpression(s : String)
|
||||||
|
+ interpret() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class PlusExpression {
|
||||||
|
- leftExpression : Expression
|
||||||
|
- rightExpression : Expression
|
||||||
|
+ PlusExpression(leftExpression : Expression, rightExpression : Expression)
|
||||||
|
+ interpret() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MultiplyExpression --> "-leftExpression" Expression
|
||||||
|
MinusExpression --> "-leftExpression" Expression
|
||||||
|
PlusExpression --> "-leftExpression" Expression
|
||||||
|
MinusExpression --|> Expression
|
||||||
|
MultiplyExpression --|> Expression
|
||||||
|
NumberExpression --|> Expression
|
||||||
|
PlusExpression --|> Expression
|
||||||
|
@enduml
|
85
iterator/etc/iterator.urm.puml
Normal file
85
iterator/etc/iterator.urm.puml
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.iterator {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- TREASURE_CHEST : TreasureChest {static}
|
||||||
|
+ App()
|
||||||
|
- buildIntegerBst() : TreeNode<Integer> {static}
|
||||||
|
- demonstrateBstIterator() {static}
|
||||||
|
- demonstrateTreasureChestIteratorForType(itemType : ItemType) {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface Iterator<T> {
|
||||||
|
+ hasNext() : boolean {abstract}
|
||||||
|
+ next() : T {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.iterator.bst {
|
||||||
|
class BstIterator<T extends Comparable<T>> {
|
||||||
|
- pathStack : ArrayDeque<TreeNode<T extends Comparable<T>>>
|
||||||
|
+ BstIterator<T extends Comparable<T>>(root : TreeNode<T extends Comparable<T>>)
|
||||||
|
+ hasNext() : boolean
|
||||||
|
+ next() : TreeNode<T extends Comparable<T>>
|
||||||
|
- pushPathToNextSmallest(node : TreeNode<T extends Comparable<T>>)
|
||||||
|
}
|
||||||
|
class TreeNode<T extends Comparable<T>> {
|
||||||
|
- left : TreeNode<T extends Comparable<T>>
|
||||||
|
- right : TreeNode<T extends Comparable<T>>
|
||||||
|
- val : T extends Comparable<T>
|
||||||
|
+ TreeNode<T extends Comparable<T>>(val : T extends Comparable<T>)
|
||||||
|
+ getLeft() : TreeNode<T extends Comparable<T>>
|
||||||
|
- getParentNodeOfValueToBeInserted(valToInsert : T extends Comparable<T>) : TreeNode<T extends Comparable<T>>
|
||||||
|
+ getRight() : TreeNode<T extends Comparable<T>>
|
||||||
|
+ getVal() : T extends Comparable<T>
|
||||||
|
+ insert(valToInsert : T extends Comparable<T>)
|
||||||
|
- insertNewChild(valToInsert : T extends Comparable<T>)
|
||||||
|
- isGreaterThan(val : T extends Comparable<T>) : boolean
|
||||||
|
- isLessThanOrEqualTo(val : T extends Comparable<T>) : boolean
|
||||||
|
- setLeft(left : TreeNode<T extends Comparable<T>>)
|
||||||
|
- setRight(right : TreeNode<T extends Comparable<T>>)
|
||||||
|
+ toString() : String
|
||||||
|
- traverseOneLevelDown(value : T extends Comparable<T>) : TreeNode<T extends Comparable<T>>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.iterator.list {
|
||||||
|
class Item {
|
||||||
|
- name : String
|
||||||
|
- type : ItemType
|
||||||
|
+ Item(type : ItemType, name : String)
|
||||||
|
+ getType() : ItemType
|
||||||
|
+ setType(type : ItemType)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
enum ItemType {
|
||||||
|
+ ANY {static}
|
||||||
|
+ POTION {static}
|
||||||
|
+ RING {static}
|
||||||
|
+ WEAPON {static}
|
||||||
|
+ valueOf(name : String) : ItemType {static}
|
||||||
|
+ values() : ItemType[] {static}
|
||||||
|
}
|
||||||
|
class TreasureChest {
|
||||||
|
- items : List<Item>
|
||||||
|
+ TreasureChest()
|
||||||
|
+ getItems() : List<Item>
|
||||||
|
+ iterator(itemType : ItemType) : Iterator<Item>
|
||||||
|
}
|
||||||
|
class TreasureChestItemIterator {
|
||||||
|
- chest : TreasureChest
|
||||||
|
- idx : int
|
||||||
|
- type : ItemType
|
||||||
|
+ TreasureChestItemIterator(chest : TreasureChest, type : ItemType)
|
||||||
|
- findNextIdx() : int
|
||||||
|
+ hasNext() : boolean
|
||||||
|
+ next() : Item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TreasureChestItemIterator --> "-type" ItemType
|
||||||
|
TreeNode --> "-left" TreeNode
|
||||||
|
TreasureChestItemIterator --> "-chest" TreasureChest
|
||||||
|
TreasureChest --> "-items" Item
|
||||||
|
Item --> "-type" ItemType
|
||||||
|
App --> "-TREASURE_CHEST" TreasureChest
|
||||||
|
BstIterator ..|> Iterator
|
||||||
|
TreasureChestItemIterator ..|> Iterator
|
||||||
|
@enduml
|
136
layers/etc/layers.urm.puml
Normal file
136
layers/etc/layers.urm.puml
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.layers.dto {
|
||||||
|
class CakeInfo {
|
||||||
|
+ cakeLayerInfos : List<CakeLayerInfo>
|
||||||
|
+ cakeToppingInfo : CakeToppingInfo
|
||||||
|
+ id : Optional<Long>
|
||||||
|
+ CakeInfo(cakeToppingInfo : CakeToppingInfo, cakeLayerInfos : List<CakeLayerInfo>)
|
||||||
|
+ CakeInfo(id : Long, cakeToppingInfo : CakeToppingInfo, cakeLayerInfos : List<CakeLayerInfo>)
|
||||||
|
+ calculateTotalCalories() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class CakeLayerInfo {
|
||||||
|
+ calories : int
|
||||||
|
+ id : Optional<Long>
|
||||||
|
+ name : String
|
||||||
|
+ CakeLayerInfo(id : Long, name : String, calories : int)
|
||||||
|
+ CakeLayerInfo(name : String, calories : int)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class CakeToppingInfo {
|
||||||
|
+ calories : int
|
||||||
|
+ id : Optional<Long>
|
||||||
|
+ name : String
|
||||||
|
+ CakeToppingInfo(id : Long, name : String, calories : int)
|
||||||
|
+ CakeToppingInfo(name : String, calories : int)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.layers.entity {
|
||||||
|
class Cake {
|
||||||
|
- id : Long
|
||||||
|
- layers : Set<CakeLayer>
|
||||||
|
- topping : CakeTopping
|
||||||
|
+ Cake()
|
||||||
|
+ addLayer(layer : CakeLayer)
|
||||||
|
+ getId() : Long
|
||||||
|
+ getLayers() : Set<CakeLayer>
|
||||||
|
+ getTopping() : CakeTopping
|
||||||
|
+ setId(id : Long)
|
||||||
|
+ setLayers(layers : Set<CakeLayer>)
|
||||||
|
+ setTopping(topping : CakeTopping)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class CakeLayer {
|
||||||
|
- cake : Cake
|
||||||
|
- calories : int
|
||||||
|
- id : Long
|
||||||
|
- name : String
|
||||||
|
+ CakeLayer()
|
||||||
|
+ CakeLayer(name : String, calories : int)
|
||||||
|
+ getCake() : Cake
|
||||||
|
+ getCalories() : int
|
||||||
|
+ getId() : Long
|
||||||
|
+ getName() : String
|
||||||
|
+ setCake(cake : Cake)
|
||||||
|
+ setCalories(calories : int)
|
||||||
|
+ setId(id : Long)
|
||||||
|
+ setName(name : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class CakeTopping {
|
||||||
|
- cake : Cake
|
||||||
|
- calories : int
|
||||||
|
- id : Long
|
||||||
|
- name : String
|
||||||
|
+ CakeTopping()
|
||||||
|
+ CakeTopping(name : String, calories : int)
|
||||||
|
+ getCake() : Cake
|
||||||
|
+ getCalories() : int
|
||||||
|
+ getId() : Long
|
||||||
|
+ getName() : String
|
||||||
|
+ setCake(cake : Cake)
|
||||||
|
+ setCalories(calories : int)
|
||||||
|
+ setId(id : Long)
|
||||||
|
+ setName(name : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.layers.view {
|
||||||
|
class CakeViewImpl {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- cakeBakingService : CakeBakingService
|
||||||
|
+ CakeViewImpl(cakeBakingService : CakeBakingService)
|
||||||
|
+ render()
|
||||||
|
}
|
||||||
|
interface View {
|
||||||
|
+ render() {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.layers.app {
|
||||||
|
class App {
|
||||||
|
- cakeBakingService : CakeBakingService {static}
|
||||||
|
+ App()
|
||||||
|
- initializeData(cakeBakingService : CakeBakingService) {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.layers.dao {
|
||||||
|
interface CakeDao {
|
||||||
|
}
|
||||||
|
interface CakeLayerDao {
|
||||||
|
}
|
||||||
|
interface CakeToppingDao {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.layers.service {
|
||||||
|
interface CakeBakingService {
|
||||||
|
+ bakeNewCake(CakeInfo) {abstract}
|
||||||
|
+ getAllCakes() : List<CakeInfo> {abstract}
|
||||||
|
+ getAvailableLayers() : List<CakeLayerInfo> {abstract}
|
||||||
|
+ getAvailableToppings() : List<CakeToppingInfo> {abstract}
|
||||||
|
+ saveNewLayer(CakeLayerInfo) {abstract}
|
||||||
|
+ saveNewTopping(CakeToppingInfo) {abstract}
|
||||||
|
}
|
||||||
|
class CakeBakingServiceImpl {
|
||||||
|
- context : AbstractApplicationContext
|
||||||
|
+ CakeBakingServiceImpl()
|
||||||
|
+ bakeNewCake(cakeInfo : CakeInfo)
|
||||||
|
+ getAllCakes() : List<CakeInfo>
|
||||||
|
- getAvailableLayerEntities() : List<CakeLayer>
|
||||||
|
+ getAvailableLayers() : List<CakeLayerInfo>
|
||||||
|
- getAvailableToppingEntities() : List<CakeTopping>
|
||||||
|
+ getAvailableToppings() : List<CakeToppingInfo>
|
||||||
|
+ saveNewLayer(layerInfo : CakeLayerInfo)
|
||||||
|
+ saveNewTopping(toppingInfo : CakeToppingInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CakeInfo --> "-cakeLayerInfos" CakeLayerInfo
|
||||||
|
CakeInfo --> "-cakeToppingInfo" CakeToppingInfo
|
||||||
|
CakeViewImpl --> "-cakeBakingService" CakeBakingService
|
||||||
|
App --> "-cakeBakingService" CakeBakingService
|
||||||
|
Cake --> "-topping" CakeTopping
|
||||||
|
CakeLayer --> "-cake" Cake
|
||||||
|
CakeBakingServiceImpl ..|> CakeBakingService
|
||||||
|
CakeViewImpl ..|> View
|
||||||
|
@enduml
|
40
lazy-loading/etc/lazy-loading.urm.puml
Normal file
40
lazy-loading/etc/lazy-loading.urm.puml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.lazy.loading {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Heavy {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Heavy()
|
||||||
|
}
|
||||||
|
class HolderNaive {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- heavy : Heavy
|
||||||
|
+ HolderNaive()
|
||||||
|
+ getHeavy() : Heavy
|
||||||
|
}
|
||||||
|
class HolderThreadSafe {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- heavy : Heavy
|
||||||
|
+ HolderThreadSafe()
|
||||||
|
+ getHeavy() : Heavy
|
||||||
|
}
|
||||||
|
class Java8Holder {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- heavy : Supplier<Heavy>
|
||||||
|
+ Java8Holder()
|
||||||
|
- createAndCacheHeavy() : Heavy
|
||||||
|
+ getHeavy() : Heavy
|
||||||
|
}
|
||||||
|
~class HeavyFactory {
|
||||||
|
- heavyInstance : Heavy
|
||||||
|
~ HeavyFactory()
|
||||||
|
+ get() : Heavy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HolderThreadSafe --> "-heavy" Heavy
|
||||||
|
HolderNaive --> "-heavy" Heavy
|
||||||
|
HeavyFactory --> "-heavyInstance" Heavy
|
||||||
|
@enduml
|
120
leader-election/etc/leader-election.urm.puml
Normal file
120
leader-election/etc/leader-election.urm.puml
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.leaderelection.ring {
|
||||||
|
class RingApp {
|
||||||
|
+ RingApp()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class RingInstance {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ RingInstance(messageManager : MessageManager, localId : int, leaderId : int)
|
||||||
|
# handleElectionInvokeMessage()
|
||||||
|
# handleElectionMessage(message : Message)
|
||||||
|
# handleHeartbeatInvokeMessage()
|
||||||
|
# handleHeartbeatMessage(message : Message)
|
||||||
|
# handleLeaderInvokeMessage()
|
||||||
|
# handleLeaderMessage(message : Message)
|
||||||
|
}
|
||||||
|
class RingMessageManager {
|
||||||
|
+ RingMessageManager(instanceMap : Map<Integer, Instance>)
|
||||||
|
+ sendElectionMessage(currentId : int, content : String) : boolean
|
||||||
|
+ sendHeartbeatInvokeMessage(currentId : int)
|
||||||
|
+ sendHeartbeatMessage(leaderId : int) : boolean
|
||||||
|
+ sendLeaderMessage(currentId : int, leaderId : int) : boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.leaderelection {
|
||||||
|
abstract class AbstractInstance {
|
||||||
|
# HEARTBEAT_INTERVAL : int {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
# alive : boolean
|
||||||
|
# leaderId : int
|
||||||
|
# localId : int
|
||||||
|
# messageManager : MessageManager
|
||||||
|
# messageQueue : Queue<Message>
|
||||||
|
+ AbstractInstance(messageManager : MessageManager, localId : int, leaderId : int)
|
||||||
|
# handleElectionInvokeMessage() {abstract}
|
||||||
|
# handleElectionMessage(Message) {abstract}
|
||||||
|
# handleHeartbeatInvokeMessage() {abstract}
|
||||||
|
# handleHeartbeatMessage(Message) {abstract}
|
||||||
|
# handleLeaderInvokeMessage() {abstract}
|
||||||
|
# handleLeaderMessage(Message) {abstract}
|
||||||
|
+ isAlive() : boolean
|
||||||
|
+ onMessage(message : Message)
|
||||||
|
- processMessage(message : Message)
|
||||||
|
+ run()
|
||||||
|
+ setAlive(alive : boolean)
|
||||||
|
}
|
||||||
|
abstract class AbstractMessageManager {
|
||||||
|
# instanceMap : Map<Integer, Instance>
|
||||||
|
+ AbstractMessageManager(instanceMap : Map<Integer, Instance>)
|
||||||
|
# findNextInstance(currentId : int) : Instance
|
||||||
|
}
|
||||||
|
interface Instance {
|
||||||
|
+ isAlive() : boolean {abstract}
|
||||||
|
+ onMessage(Message) {abstract}
|
||||||
|
+ setAlive(boolean) {abstract}
|
||||||
|
}
|
||||||
|
class Message {
|
||||||
|
- content : String
|
||||||
|
- type : MessageType
|
||||||
|
+ Message()
|
||||||
|
+ Message(type : MessageType, content : String)
|
||||||
|
+ equals(o : Object) : boolean
|
||||||
|
+ getContent() : String
|
||||||
|
+ getType() : MessageType
|
||||||
|
+ hashCode() : int
|
||||||
|
+ setContent(content : String)
|
||||||
|
+ setType(type : MessageType)
|
||||||
|
}
|
||||||
|
interface MessageManager {
|
||||||
|
+ sendElectionMessage(int, String) : boolean {abstract}
|
||||||
|
+ sendHeartbeatInvokeMessage(int) {abstract}
|
||||||
|
+ sendHeartbeatMessage(int) : boolean {abstract}
|
||||||
|
+ sendLeaderMessage(int, int) : boolean {abstract}
|
||||||
|
}
|
||||||
|
enum MessageType {
|
||||||
|
+ ELECTION {static}
|
||||||
|
+ ELECTION_INVOKE {static}
|
||||||
|
+ HEARTBEAT {static}
|
||||||
|
+ HEARTBEAT_INVOKE {static}
|
||||||
|
+ LEADER {static}
|
||||||
|
+ LEADER_INVOKE {static}
|
||||||
|
+ valueOf(name : String) : MessageType {static}
|
||||||
|
+ values() : MessageType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.leaderelection.bully {
|
||||||
|
class BullyApp {
|
||||||
|
+ BullyApp()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class BullyInstance {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ BullyInstance(messageManager : MessageManager, localId : int, leaderId : int)
|
||||||
|
# handleElectionInvokeMessage()
|
||||||
|
# handleElectionMessage(message : Message)
|
||||||
|
# handleHeartbeatInvokeMessage()
|
||||||
|
# handleHeartbeatMessage(message : Message)
|
||||||
|
# handleLeaderInvokeMessage()
|
||||||
|
# handleLeaderMessage(message : Message)
|
||||||
|
- isLeader() : boolean
|
||||||
|
}
|
||||||
|
class BullyMessageManager {
|
||||||
|
+ BullyMessageManager(instanceMap : Map<Integer, Instance>)
|
||||||
|
- findElectionCandidateInstanceList(currentId : int) : List<Integer>
|
||||||
|
+ sendElectionMessage(currentId : int, content : String) : boolean
|
||||||
|
+ sendHeartbeatInvokeMessage(currentId : int)
|
||||||
|
+ sendHeartbeatMessage(leaderId : int) : boolean
|
||||||
|
+ sendLeaderMessage(currentId : int, leaderId : int) : boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractInstance --> "-messageQueue" Message
|
||||||
|
Message --> "-type" MessageType
|
||||||
|
AbstractInstance --> "-messageManager" MessageManager
|
||||||
|
AbstractInstance ..|> Instance
|
||||||
|
AbstractMessageManager ..|> MessageManager
|
||||||
|
BullyInstance --|> AbstractInstance
|
||||||
|
BullyMessageManager --|> AbstractMessageManager
|
||||||
|
RingInstance --|> AbstractInstance
|
||||||
|
RingMessageManager --|> AbstractMessageManager
|
||||||
|
@enduml
|
2
marker/etc/marker.urm.puml
Normal file
2
marker/etc/marker.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
78
master-worker-pattern/etc/master-worker-pattern.urm.puml
Normal file
78
master-worker-pattern/etc/master-worker-pattern.urm.puml
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.masterworker.system.systemmaster {
|
||||||
|
class ArrayTransposeMaster {
|
||||||
|
+ ArrayTransposeMaster(numOfWorkers : int)
|
||||||
|
~ aggregateData() : ArrayResult
|
||||||
|
~ setWorkers(num : int) : ArrayList<Worker>
|
||||||
|
}
|
||||||
|
abstract class Master {
|
||||||
|
- allResultData : Hashtable<Integer, Result<T>>
|
||||||
|
- expectedNumResults : int
|
||||||
|
- finalResult : Result<T>
|
||||||
|
- numOfWorkers : int
|
||||||
|
- workers : ArrayList<Worker>
|
||||||
|
~ Master(numOfWorkers : int)
|
||||||
|
~ aggregateData() : Result<T> {abstract}
|
||||||
|
- collectResult(data : Result<T>, workerId : int)
|
||||||
|
- divideWork(input : Input<T>)
|
||||||
|
+ doWork(input : Input<T>)
|
||||||
|
~ getAllResultData() : Hashtable<Integer, Result<T>>
|
||||||
|
~ getExpectedNumResults() : int
|
||||||
|
+ getFinalResult() : Result<T>
|
||||||
|
~ getWorkers() : ArrayList<Worker>
|
||||||
|
+ receiveData(data : Result<T>, w : Worker)
|
||||||
|
~ setWorkers(int) : ArrayList<Worker> {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.masterworker.system {
|
||||||
|
class ArrayTransposeMasterWorker {
|
||||||
|
+ ArrayTransposeMasterWorker()
|
||||||
|
~ setMaster(numOfWorkers : int) : Master
|
||||||
|
}
|
||||||
|
abstract class MasterWorker {
|
||||||
|
- master : Master
|
||||||
|
+ MasterWorker(numOfWorkers : int)
|
||||||
|
+ getResult(input : Input<T>) : Result<T>
|
||||||
|
~ setMaster(int) : Master {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.masterworker {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class ArrayInput {
|
||||||
|
+ ArrayInput(data : int[][])
|
||||||
|
+ divideData(num : int) : ArrayList<Input<T>>
|
||||||
|
~ makeDivisions(data : int[][], num : int) : int[] {static}
|
||||||
|
}
|
||||||
|
class ArrayResult {
|
||||||
|
+ ArrayResult(data : int[][])
|
||||||
|
}
|
||||||
|
class ArrayUtilityMethods {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- RANDOM : Random {static}
|
||||||
|
+ ArrayUtilityMethods()
|
||||||
|
+ arraysSame(a1 : int[], a2 : int[]) : boolean {static}
|
||||||
|
+ createRandomIntMatrix(rows : int, columns : int) : int[][] {static}
|
||||||
|
+ matricesSame(m1 : int[][], m2 : int[][]) : boolean {static}
|
||||||
|
+ printMatrix(matrix : int[][]) {static}
|
||||||
|
}
|
||||||
|
abstract class Input<T> {
|
||||||
|
+ data : T
|
||||||
|
+ Input<T>(data : T)
|
||||||
|
+ divideData(int) : ArrayList<Input<T>> {abstract}
|
||||||
|
}
|
||||||
|
abstract class Result<T> {
|
||||||
|
+ data : T
|
||||||
|
+ Result<T>(data : T)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Master --> "-finalResult" Result
|
||||||
|
MasterWorker --> "-master" Master
|
||||||
|
ArrayInput --|> Input
|
||||||
|
ArrayResult --|> Result
|
||||||
|
ArrayTransposeMasterWorker --|> MasterWorker
|
||||||
|
ArrayTransposeMaster --|> Master
|
||||||
|
@enduml
|
69
mediator/etc/mediator.urm.puml
Normal file
69
mediator/etc/mediator.urm.puml
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.mediator {
|
||||||
|
enum Action {
|
||||||
|
+ ENEMY {static}
|
||||||
|
+ GOLD {static}
|
||||||
|
+ HUNT {static}
|
||||||
|
+ NONE {static}
|
||||||
|
+ TALE {static}
|
||||||
|
- description : String
|
||||||
|
- title : String
|
||||||
|
+ getDescription() : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Action {static}
|
||||||
|
+ values() : Action[] {static}
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Hobbit {
|
||||||
|
+ Hobbit()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Hunter {
|
||||||
|
+ Hunter()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface Party {
|
||||||
|
+ act(PartyMember, Action) {abstract}
|
||||||
|
+ addMember(PartyMember) {abstract}
|
||||||
|
}
|
||||||
|
class PartyImpl {
|
||||||
|
- members : List<PartyMember>
|
||||||
|
+ PartyImpl()
|
||||||
|
+ act(actor : PartyMember, action : Action)
|
||||||
|
+ addMember(member : PartyMember)
|
||||||
|
}
|
||||||
|
interface PartyMember {
|
||||||
|
+ act(Action) {abstract}
|
||||||
|
+ joinedParty(Party) {abstract}
|
||||||
|
+ partyAction(Action) {abstract}
|
||||||
|
}
|
||||||
|
abstract class PartyMemberBase {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
# party : Party
|
||||||
|
+ PartyMemberBase()
|
||||||
|
+ act(action : Action)
|
||||||
|
+ joinedParty(party : Party)
|
||||||
|
+ partyAction(action : Action)
|
||||||
|
+ toString() : String {abstract}
|
||||||
|
}
|
||||||
|
class Rogue {
|
||||||
|
+ Rogue()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Wizard {
|
||||||
|
+ Wizard()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PartyImpl --> "-members" PartyMember
|
||||||
|
PartyMemberBase --> "-party" Party
|
||||||
|
Hobbit --|> PartyMemberBase
|
||||||
|
Hunter --|> PartyMemberBase
|
||||||
|
PartyImpl ..|> Party
|
||||||
|
PartyMemberBase ..|> PartyMember
|
||||||
|
Rogue --|> PartyMemberBase
|
||||||
|
Wizard --|> PartyMemberBase
|
||||||
|
@enduml
|
49
memento/etc/memento.urm.puml
Normal file
49
memento/etc/memento.urm.puml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.memento {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Star {
|
||||||
|
- ageYears : int
|
||||||
|
- massTons : int
|
||||||
|
- type : StarType
|
||||||
|
+ Star(startType : StarType, startAge : int, startMass : int)
|
||||||
|
~ getMemento() : StarMemento
|
||||||
|
~ setMemento(memento : StarMemento)
|
||||||
|
+ timePasses()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
-class StarMementoInternal {
|
||||||
|
- ageYears : int
|
||||||
|
- massTons : int
|
||||||
|
- type : StarType
|
||||||
|
- StarMementoInternal()
|
||||||
|
+ getAgeYears() : int
|
||||||
|
+ getMassTons() : int
|
||||||
|
+ getType() : StarType
|
||||||
|
+ setAgeYears(ageYears : int)
|
||||||
|
+ setMassTons(massTons : int)
|
||||||
|
+ setType(type : StarType)
|
||||||
|
}
|
||||||
|
interface StarMemento {
|
||||||
|
}
|
||||||
|
enum StarType {
|
||||||
|
+ DEAD {static}
|
||||||
|
+ RED_GIANT {static}
|
||||||
|
+ SUN {static}
|
||||||
|
+ SUPERNOVA {static}
|
||||||
|
+ UNDEFINED {static}
|
||||||
|
+ WHITE_DWARF {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : StarType {static}
|
||||||
|
+ values() : StarType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StarMementoInternal --> "-type" StarType
|
||||||
|
Star --> "-type" StarType
|
||||||
|
StarMementoInternal ..+ Star
|
||||||
|
StarMementoInternal ..|> StarMemento
|
||||||
|
@enduml
|
70
model-view-controller/etc/model-view-controller.urm.puml
Normal file
70
model-view-controller/etc/model-view-controller.urm.puml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.model.view.controller {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
enum Fatigue {
|
||||||
|
+ ALERT {static}
|
||||||
|
+ SLEEPING {static}
|
||||||
|
+ TIRED {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Fatigue {static}
|
||||||
|
+ values() : Fatigue[] {static}
|
||||||
|
}
|
||||||
|
class GiantController {
|
||||||
|
- giant : GiantModel
|
||||||
|
- view : GiantView
|
||||||
|
+ GiantController(giant : GiantModel, view : GiantView)
|
||||||
|
+ getFatigue() : Fatigue
|
||||||
|
+ getHealth() : Health
|
||||||
|
+ getNourishment() : Nourishment
|
||||||
|
+ setFatigue(fatigue : Fatigue)
|
||||||
|
+ setHealth(health : Health)
|
||||||
|
+ setNourishment(nourishment : Nourishment)
|
||||||
|
+ updateView()
|
||||||
|
}
|
||||||
|
class GiantModel {
|
||||||
|
- fatigue : Fatigue
|
||||||
|
- health : Health
|
||||||
|
- nourishment : Nourishment
|
||||||
|
~ GiantModel(health : Health, fatigue : Fatigue, nourishment : Nourishment)
|
||||||
|
+ getFatigue() : Fatigue
|
||||||
|
+ getHealth() : Health
|
||||||
|
+ getNourishment() : Nourishment
|
||||||
|
+ setFatigue(fatigue : Fatigue)
|
||||||
|
+ setHealth(health : Health)
|
||||||
|
+ setNourishment(nourishment : Nourishment)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class GiantView {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ GiantView()
|
||||||
|
+ displayGiant(giant : GiantModel)
|
||||||
|
}
|
||||||
|
enum Health {
|
||||||
|
+ DEAD {static}
|
||||||
|
+ HEALTHY {static}
|
||||||
|
+ WOUNDED {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Health {static}
|
||||||
|
+ values() : Health[] {static}
|
||||||
|
}
|
||||||
|
enum Nourishment {
|
||||||
|
+ HUNGRY {static}
|
||||||
|
+ SATURATED {static}
|
||||||
|
+ STARVING {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Nourishment {static}
|
||||||
|
+ values() : Nourishment[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GiantModel --> "-nourishment" Nourishment
|
||||||
|
GiantController --> "-giant" GiantModel
|
||||||
|
GiantModel --> "-fatigue" Fatigue
|
||||||
|
GiantModel --> "-health" Health
|
||||||
|
GiantController --> "-view" GiantView
|
||||||
|
@enduml
|
90
model-view-presenter/etc/model-view-presenter.urm.puml
Normal file
90
model-view-presenter/etc/model-view-presenter.urm.puml
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.model.view.presenter {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class FileLoader {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- fileName : String
|
||||||
|
- loaded : boolean
|
||||||
|
- serialVersionUID : long {static}
|
||||||
|
+ FileLoader()
|
||||||
|
+ fileExists() : boolean
|
||||||
|
+ getFileName() : String
|
||||||
|
+ isLoaded() : boolean
|
||||||
|
+ loadData() : String
|
||||||
|
+ setFileName(fileName : String)
|
||||||
|
}
|
||||||
|
class FileSelectorJFrame {
|
||||||
|
- area : JTextArea
|
||||||
|
- cancel : JButton
|
||||||
|
- contents : JLabel
|
||||||
|
- fileName : String
|
||||||
|
- info : JLabel
|
||||||
|
- input : JTextField
|
||||||
|
- ok : JButton
|
||||||
|
- panel : JPanel
|
||||||
|
- presenter : FileSelectorPresenter
|
||||||
|
- serialVersionUID : long {static}
|
||||||
|
+ FileSelectorJFrame()
|
||||||
|
+ actionPerformed(e : ActionEvent)
|
||||||
|
+ close()
|
||||||
|
+ displayData(data : String)
|
||||||
|
+ getFileName() : String
|
||||||
|
+ getPresenter() : FileSelectorPresenter
|
||||||
|
+ isOpened() : boolean
|
||||||
|
+ open()
|
||||||
|
+ setFileName(name : String)
|
||||||
|
+ setPresenter(presenter : FileSelectorPresenter)
|
||||||
|
+ showMessage(message : String)
|
||||||
|
}
|
||||||
|
class FileSelectorPresenter {
|
||||||
|
- loader : FileLoader
|
||||||
|
- serialVersionUID : long {static}
|
||||||
|
- view : FileSelectorView
|
||||||
|
+ FileSelectorPresenter(view : FileSelectorView)
|
||||||
|
+ cancelled()
|
||||||
|
+ confirmed()
|
||||||
|
+ fileNameChanged()
|
||||||
|
+ setLoader(loader : FileLoader)
|
||||||
|
+ start()
|
||||||
|
}
|
||||||
|
class FileSelectorStub {
|
||||||
|
- dataDisplayed : boolean
|
||||||
|
- name : String
|
||||||
|
- numOfMessageSent : int
|
||||||
|
- opened : boolean
|
||||||
|
- presenter : FileSelectorPresenter
|
||||||
|
+ FileSelectorStub()
|
||||||
|
+ close()
|
||||||
|
+ dataDisplayed() : boolean
|
||||||
|
+ displayData(data : String)
|
||||||
|
+ getFileName() : String
|
||||||
|
+ getMessagesSent() : int
|
||||||
|
+ getPresenter() : FileSelectorPresenter
|
||||||
|
+ isOpened() : boolean
|
||||||
|
+ open()
|
||||||
|
+ setFileName(name : String)
|
||||||
|
+ setPresenter(presenter : FileSelectorPresenter)
|
||||||
|
+ showMessage(message : String)
|
||||||
|
}
|
||||||
|
interface FileSelectorView {
|
||||||
|
+ close() {abstract}
|
||||||
|
+ displayData(String) {abstract}
|
||||||
|
+ getFileName() : String {abstract}
|
||||||
|
+ getPresenter() : FileSelectorPresenter {abstract}
|
||||||
|
+ isOpened() : boolean {abstract}
|
||||||
|
+ open() {abstract}
|
||||||
|
+ setFileName(String) {abstract}
|
||||||
|
+ setPresenter(FileSelectorPresenter) {abstract}
|
||||||
|
+ showMessage(String) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FileSelectorJFrame --> "-presenter" FileSelectorPresenter
|
||||||
|
FileSelectorStub --> "-presenter" FileSelectorPresenter
|
||||||
|
FileSelectorPresenter --> "-view" FileSelectorView
|
||||||
|
FileSelectorPresenter --> "-loader" FileLoader
|
||||||
|
FileSelectorJFrame ..|> FileSelectorView
|
||||||
|
FileSelectorStub ..|> FileSelectorView
|
||||||
|
@enduml
|
43
module/etc/module.urm.puml
Normal file
43
module/etc/module.urm.puml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.module {
|
||||||
|
class App {
|
||||||
|
+ consoleLoggerModule : ConsoleLoggerModule {static}
|
||||||
|
+ fileLoggerModule : FileLoggerModule {static}
|
||||||
|
+ App()
|
||||||
|
+ execute(args : String[]) {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
+ prepare() {static}
|
||||||
|
+ unprepare() {static}
|
||||||
|
}
|
||||||
|
class ConsoleLoggerModule {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ error : PrintStream
|
||||||
|
+ output : PrintStream
|
||||||
|
- singleton : ConsoleLoggerModule {static}
|
||||||
|
- ConsoleLoggerModule()
|
||||||
|
+ getSingleton() : ConsoleLoggerModule {static}
|
||||||
|
+ prepare() : ConsoleLoggerModule
|
||||||
|
+ printErrorString(value : String)
|
||||||
|
+ printString(value : String)
|
||||||
|
+ unprepare()
|
||||||
|
}
|
||||||
|
class FileLoggerModule {
|
||||||
|
- ERROR_FILE : String {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- OUTPUT_FILE : String {static}
|
||||||
|
+ error : PrintStream
|
||||||
|
+ output : PrintStream
|
||||||
|
- singleton : FileLoggerModule {static}
|
||||||
|
- FileLoggerModule()
|
||||||
|
+ getSingleton() : FileLoggerModule {static}
|
||||||
|
+ prepare() : FileLoggerModule
|
||||||
|
+ printErrorString(value : String)
|
||||||
|
+ printString(value : String)
|
||||||
|
+ unprepare()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FileLoggerModule --> "-singleton" FileLoggerModule
|
||||||
|
App --> "-consoleLoggerModule" ConsoleLoggerModule
|
||||||
|
ConsoleLoggerModule --> "-singleton" ConsoleLoggerModule
|
||||||
|
App --> "-fileLoggerModule" FileLoggerModule
|
||||||
|
@enduml
|
36
monad/etc/monad.urm.puml
Normal file
36
monad/etc/monad.urm.puml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.monad {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
enum Sex {
|
||||||
|
+ FEMALE {static}
|
||||||
|
+ MALE {static}
|
||||||
|
+ valueOf(name : String) : Sex {static}
|
||||||
|
+ values() : Sex[] {static}
|
||||||
|
}
|
||||||
|
class User {
|
||||||
|
- age : int
|
||||||
|
- email : String
|
||||||
|
- name : String
|
||||||
|
- sex : Sex
|
||||||
|
+ User(name : String, age : int, sex : Sex, email : String)
|
||||||
|
+ getAge() : int
|
||||||
|
+ getEmail() : String
|
||||||
|
+ getName() : String
|
||||||
|
+ getSex() : Sex
|
||||||
|
}
|
||||||
|
class Validator<T> {
|
||||||
|
- exceptions : List<Throwable>
|
||||||
|
- obj : T
|
||||||
|
- Validator<T>(obj : T)
|
||||||
|
+ get() : T
|
||||||
|
+ of(t : T) : Validator<T> {static}
|
||||||
|
+ validate(projection : Function<T, U>, validation : Predicate<U>, message : String) : Validator<T>
|
||||||
|
+ validate(validation : Predicate<T>, message : String) : Validator<T>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
User --> "-sex" Sex
|
||||||
|
@enduml
|
32
monostate/etc/monostate.urm.puml
Normal file
32
monostate/etc/monostate.urm.puml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.monostate {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class LoadBalancer {
|
||||||
|
- SERVERS : List<Server> {static}
|
||||||
|
- lastServedId : int {static}
|
||||||
|
+ LoadBalancer()
|
||||||
|
+ addServer(server : Server)
|
||||||
|
+ getLastServedId() : int
|
||||||
|
+ getNoOfServers() : int
|
||||||
|
+ serverRequest(request : Request)
|
||||||
|
}
|
||||||
|
class Request {
|
||||||
|
+ value : String
|
||||||
|
+ Request(value : String)
|
||||||
|
}
|
||||||
|
class Server {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ host : String
|
||||||
|
+ id : int
|
||||||
|
+ port : int
|
||||||
|
+ Server(host : String, port : int, id : int)
|
||||||
|
+ getHost() : String
|
||||||
|
+ getPort() : int
|
||||||
|
+ serve(request : Request)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LoadBalancer --> "-SERVERS" Server
|
||||||
|
@enduml
|
43
multiton/etc/multiton.urm.puml
Normal file
43
multiton/etc/multiton.urm.puml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.multiton {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Nazgul {
|
||||||
|
- name : NazgulName
|
||||||
|
- nazguls : Map<NazgulName, Nazgul> {static}
|
||||||
|
- Nazgul(name : NazgulName)
|
||||||
|
+ getInstance(name : NazgulName) : Nazgul {static}
|
||||||
|
+ getName() : NazgulName
|
||||||
|
}
|
||||||
|
enum NazgulEnum {
|
||||||
|
+ ADUNAPHEL {static}
|
||||||
|
+ AKHORAHIL {static}
|
||||||
|
+ DWAR {static}
|
||||||
|
+ HOARMURATH {static}
|
||||||
|
+ JI_INDUR {static}
|
||||||
|
+ KHAMUL {static}
|
||||||
|
+ MURAZOR {static}
|
||||||
|
+ REN {static}
|
||||||
|
+ UVATHA {static}
|
||||||
|
+ valueOf(name : String) : NazgulEnum {static}
|
||||||
|
+ values() : NazgulEnum[] {static}
|
||||||
|
}
|
||||||
|
enum NazgulName {
|
||||||
|
+ ADUNAPHEL {static}
|
||||||
|
+ AKHORAHIL {static}
|
||||||
|
+ DWAR {static}
|
||||||
|
+ HOARMURATH {static}
|
||||||
|
+ JI_INDUR {static}
|
||||||
|
+ KHAMUL {static}
|
||||||
|
+ MURAZOR {static}
|
||||||
|
+ REN {static}
|
||||||
|
+ UVATHA {static}
|
||||||
|
+ valueOf(name : String) : NazgulName {static}
|
||||||
|
+ values() : NazgulName[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Nazgul --> "-name" NazgulName
|
||||||
|
@enduml
|
24
mute-idiom/etc/mute-idiom.urm.puml
Normal file
24
mute-idiom/etc/mute-idiom.urm.puml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.mute {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
- acquireResource() : Resource {static}
|
||||||
|
- closeResource(resource : Resource) {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- useOfLoggedMute() {static}
|
||||||
|
- useOfMute() {static}
|
||||||
|
- utilizeResource(resource : Resource) {static}
|
||||||
|
}
|
||||||
|
interface CheckedRunnable {
|
||||||
|
+ run() {abstract}
|
||||||
|
}
|
||||||
|
class Mute {
|
||||||
|
- Mute()
|
||||||
|
+ loggedMute(runnable : CheckedRunnable) {static}
|
||||||
|
+ mute(runnable : CheckedRunnable) {static}
|
||||||
|
}
|
||||||
|
interface Resource {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
27
mutex/etc/mutex.urm.puml
Normal file
27
mutex/etc/mutex.urm.puml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.mutex {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Jar {
|
||||||
|
- beans : int
|
||||||
|
- lock : Lock
|
||||||
|
+ Jar(beans : int, lock : Lock)
|
||||||
|
+ takeBean() : boolean
|
||||||
|
}
|
||||||
|
interface Lock {
|
||||||
|
+ acquire() {abstract}
|
||||||
|
+ release() {abstract}
|
||||||
|
}
|
||||||
|
class Mutex {
|
||||||
|
- owner : Object
|
||||||
|
+ Mutex()
|
||||||
|
+ acquire()
|
||||||
|
+ getOwner() : Object
|
||||||
|
+ release()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Jar --> "-lock" Lock
|
||||||
|
Mutex ..|> Lock
|
||||||
|
@enduml
|
2
naked-objects/dom/etc/naked-objects-dom.urm.puml
Normal file
2
naked-objects/dom/etc/naked-objects-dom.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
2
naked-objects/etc/naked-objects.urm.puml
Normal file
2
naked-objects/etc/naked-objects.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
2
naked-objects/fixture/etc/naked-objects-fixture.urm.puml
Normal file
2
naked-objects/fixture/etc/naked-objects-fixture.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
2
naked-objects/webapp/etc/naked-objects-webapp.urm.puml
Normal file
2
naked-objects/webapp/etc/naked-objects-webapp.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
41
null-object/etc/null-object.urm.puml
Normal file
41
null-object/etc/null-object.urm.puml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.nullobject {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface Node {
|
||||||
|
+ getLeft() : Node {abstract}
|
||||||
|
+ getName() : String {abstract}
|
||||||
|
+ getRight() : Node {abstract}
|
||||||
|
+ getTreeSize() : int {abstract}
|
||||||
|
+ walk() {abstract}
|
||||||
|
}
|
||||||
|
class NodeImpl {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- left : Node
|
||||||
|
- name : String
|
||||||
|
- right : Node
|
||||||
|
+ NodeImpl(name : String, left : Node, right : Node)
|
||||||
|
+ getLeft() : Node
|
||||||
|
+ getName() : String
|
||||||
|
+ getRight() : Node
|
||||||
|
+ getTreeSize() : int
|
||||||
|
+ walk()
|
||||||
|
}
|
||||||
|
class NullNode {
|
||||||
|
- instance : NullNode {static}
|
||||||
|
- NullNode()
|
||||||
|
+ getInstance() : NullNode {static}
|
||||||
|
+ getLeft() : Node
|
||||||
|
+ getName() : String
|
||||||
|
+ getRight() : Node
|
||||||
|
+ getTreeSize() : int
|
||||||
|
+ walk()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NullNode --> "-instance" NullNode
|
||||||
|
NodeImpl --> "-left" Node
|
||||||
|
NodeImpl ..|> Node
|
||||||
|
NullNode ..|> Node
|
||||||
|
@enduml
|
45
object-mother/etc/object-mother.urm.puml
Normal file
45
object-mother/etc/object-mother.urm.puml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.objectmother {
|
||||||
|
class King {
|
||||||
|
~ isDrunk : boolean
|
||||||
|
~ isHappy : boolean
|
||||||
|
+ King()
|
||||||
|
+ flirt(queen : Queen)
|
||||||
|
+ isHappy() : boolean
|
||||||
|
+ makeDrunk()
|
||||||
|
+ makeHappy()
|
||||||
|
+ makeSober()
|
||||||
|
+ makeUnhappy()
|
||||||
|
}
|
||||||
|
class Queen {
|
||||||
|
- isDrunk : boolean
|
||||||
|
- isFlirty : boolean
|
||||||
|
- isHappy : boolean
|
||||||
|
+ Queen()
|
||||||
|
+ getFlirted(king : King) : boolean
|
||||||
|
+ isFlirty() : boolean
|
||||||
|
+ makeDrunk()
|
||||||
|
+ makeHappy()
|
||||||
|
+ makeSober()
|
||||||
|
+ makeUnhappy()
|
||||||
|
+ setFlirtiness(flirtiness : boolean)
|
||||||
|
}
|
||||||
|
interface Royalty {
|
||||||
|
+ makeDrunk() {abstract}
|
||||||
|
+ makeHappy() {abstract}
|
||||||
|
+ makeSober() {abstract}
|
||||||
|
+ makeUnhappy() {abstract}
|
||||||
|
}
|
||||||
|
class RoyaltyObjectMother {
|
||||||
|
+ RoyaltyObjectMother()
|
||||||
|
+ createDrunkKing() : King {static}
|
||||||
|
+ createFlirtyQueen() : Queen {static}
|
||||||
|
+ createHappyDrunkKing() : King {static}
|
||||||
|
+ createHappyKing() : King {static}
|
||||||
|
+ createNotFlirtyQueen() : Queen {static}
|
||||||
|
+ createSoberUnhappyKing() : King {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
King ..|> Royalty
|
||||||
|
Queen ..|> Royalty
|
||||||
|
@enduml
|
30
object-pool/etc/object-pool.urm.puml
Normal file
30
object-pool/etc/object-pool.urm.puml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.object.pool {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
abstract class ObjectPool<T> {
|
||||||
|
- available : Set<T>
|
||||||
|
- inUse : Set<T>
|
||||||
|
+ ObjectPool<T>()
|
||||||
|
+ checkIn(instance : T)
|
||||||
|
+ checkOut() : T
|
||||||
|
# create() : T {abstract}
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Oliphaunt {
|
||||||
|
- counter : AtomicInteger {static}
|
||||||
|
- id : int
|
||||||
|
+ Oliphaunt()
|
||||||
|
+ getId() : int
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class OliphauntPool {
|
||||||
|
+ OliphauntPool()
|
||||||
|
# create() : Oliphaunt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OliphauntPool --|> ObjectPool
|
||||||
|
@enduml
|
80
observer/etc/observer.urm.puml
Normal file
80
observer/etc/observer.urm.puml
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.observer {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Hobbits {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Hobbits()
|
||||||
|
+ update(currentWeather : WeatherType)
|
||||||
|
}
|
||||||
|
class Orcs {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Orcs()
|
||||||
|
+ update(currentWeather : WeatherType)
|
||||||
|
}
|
||||||
|
class Weather {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- currentWeather : WeatherType
|
||||||
|
- observers : List<WeatherObserver>
|
||||||
|
+ Weather()
|
||||||
|
+ addObserver(obs : WeatherObserver)
|
||||||
|
- notifyObservers()
|
||||||
|
+ removeObserver(obs : WeatherObserver)
|
||||||
|
+ timePasses()
|
||||||
|
}
|
||||||
|
interface WeatherObserver {
|
||||||
|
+ update(WeatherType) {abstract}
|
||||||
|
}
|
||||||
|
enum WeatherType {
|
||||||
|
+ COLD {static}
|
||||||
|
+ RAINY {static}
|
||||||
|
+ SUNNY {static}
|
||||||
|
+ WINDY {static}
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : WeatherType {static}
|
||||||
|
+ values() : WeatherType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.observer.generic {
|
||||||
|
class GHobbits {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ GHobbits()
|
||||||
|
+ update(weather : GWeather, weatherType : WeatherType)
|
||||||
|
}
|
||||||
|
class GOrcs {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ GOrcs()
|
||||||
|
+ update(weather : GWeather, weatherType : WeatherType)
|
||||||
|
}
|
||||||
|
class GWeather {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- currentWeather : WeatherType
|
||||||
|
+ GWeather()
|
||||||
|
+ timePasses()
|
||||||
|
}
|
||||||
|
abstract class Observable<S extends Observable, O extends Observer<S, O, A>, A> {
|
||||||
|
# observers : List<O extends Observer<S, O, A>>
|
||||||
|
+ Observable<S extends Observable, O extends Observer<S, O, A>, A>()
|
||||||
|
+ addObserver(observer : O extends Observer<S, O, A>)
|
||||||
|
+ notifyObservers(argument : A)
|
||||||
|
+ removeObserver(observer : O extends Observer<S, O, A>)
|
||||||
|
}
|
||||||
|
interface Observer<S extends Observable<S, O, A>, O extends Observer, A> {
|
||||||
|
+ update(S extends Observable<S, O, A>, A) {abstract}
|
||||||
|
}
|
||||||
|
interface Race {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Weather --> "-currentWeather" WeatherType
|
||||||
|
GWeather --> "-currentWeather" WeatherType
|
||||||
|
Weather --> "-observers" WeatherObserver
|
||||||
|
Hobbits ..|> WeatherObserver
|
||||||
|
Orcs ..|> WeatherObserver
|
||||||
|
GHobbits ..|> Race
|
||||||
|
GOrcs ..|> Race
|
||||||
|
GWeather --|> Observable
|
||||||
|
Race --|> Observer
|
||||||
|
@enduml
|
2
page-object/etc/page-object.urm.puml
Normal file
2
page-object/etc/page-object.urm.puml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@startuml
|
||||||
|
@enduml
|
@ -0,0 +1,9 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.pageobject {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
51
page-object/test-automation/etc/test-automation.urm.puml
Normal file
51
page-object/test-automation/etc/test-automation.urm.puml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.pageobject {
|
||||||
|
class AlbumListPage {
|
||||||
|
- ALBUM_LIST_HTML_FILE : String {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- PAGE_URL : String {static}
|
||||||
|
- page : HtmlPage
|
||||||
|
+ AlbumListPage(webClient : WebClient)
|
||||||
|
+ isAt() : boolean
|
||||||
|
+ navigateToPage() : AlbumListPage
|
||||||
|
+ selectAlbum(albumTitle : String) : AlbumPage
|
||||||
|
}
|
||||||
|
class AlbumPage {
|
||||||
|
- ALBUM_PAGE_HTML_FILE : String {static}
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- PAGE_URL : String {static}
|
||||||
|
- page : HtmlPage
|
||||||
|
+ AlbumPage(webClient : WebClient)
|
||||||
|
+ cancelChanges() : AlbumListPage
|
||||||
|
+ changeAlbumRating(albumRating : String) : AlbumPage
|
||||||
|
+ changeAlbumTitle(albumTitle : String) : AlbumPage
|
||||||
|
+ changeAlbumYear(year : int) : AlbumPage
|
||||||
|
+ changeArtist(artist : String) : AlbumPage
|
||||||
|
+ changeNumberOfSongs(numberOfSongs : int) : AlbumPage
|
||||||
|
+ isAt() : boolean
|
||||||
|
+ navigateToPage() : AlbumPage
|
||||||
|
+ saveChanges() : AlbumPage
|
||||||
|
}
|
||||||
|
class LoginPage {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- LOGIN_PAGE_HTML_FILE : String {static}
|
||||||
|
- PAGE_URL : String {static}
|
||||||
|
- page : HtmlPage
|
||||||
|
+ LoginPage(webClient : WebClient)
|
||||||
|
+ enterPassword(password : String) : LoginPage
|
||||||
|
+ enterUsername(username : String) : LoginPage
|
||||||
|
+ isAt() : boolean
|
||||||
|
+ login() : AlbumListPage
|
||||||
|
+ navigateToPage() : LoginPage
|
||||||
|
}
|
||||||
|
abstract class Page {
|
||||||
|
+ AUT_PATH : String {static}
|
||||||
|
# webClient : WebClient
|
||||||
|
+ Page(webClient : WebClient)
|
||||||
|
+ isAt() : boolean {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AlbumListPage --|> Page
|
||||||
|
AlbumPage --|> Page
|
||||||
|
LoginPage --|> Page
|
||||||
|
@enduml
|
31
partial-response/etc/partial-response.urm.puml
Normal file
31
partial-response/etc/partial-response.urm.puml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.partialresponse {
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class FieldJsonMapper {
|
||||||
|
+ FieldJsonMapper()
|
||||||
|
- getString(video : Video, declaredField : Field) : String
|
||||||
|
+ toJson(video : Video, fields : String[]) : String
|
||||||
|
}
|
||||||
|
class Video {
|
||||||
|
- description : String
|
||||||
|
- director : String
|
||||||
|
- id : Integer
|
||||||
|
- language : String
|
||||||
|
- length : Integer
|
||||||
|
- title : String
|
||||||
|
+ Video(id : Integer, title : String, len : Integer, desc : String, director : String, lang : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class VideoResource {
|
||||||
|
- fieldJsonMapper : FieldJsonMapper
|
||||||
|
- videos : Map<Integer, Video>
|
||||||
|
+ VideoResource(fieldJsonMapper : FieldJsonMapper, videos : Map<Integer, Video>)
|
||||||
|
+ getDetails(id : Integer, fields : String[]) : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VideoResource --> "-fieldJsonMapper" FieldJsonMapper
|
||||||
|
@enduml
|
36
pipeline/etc/pipeline.urm.puml
Normal file
36
pipeline/etc/pipeline.urm.puml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.pipeline {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
~class ConvertToCharArrayHandler {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
~ ConvertToCharArrayHandler()
|
||||||
|
+ process(input : String) : char[]
|
||||||
|
}
|
||||||
|
~interface Handler<I, O> {
|
||||||
|
+ process(I) : O {abstract}
|
||||||
|
}
|
||||||
|
~class Pipeline<I, O> {
|
||||||
|
- currentHandler : Handler<I, O>
|
||||||
|
~ Pipeline<I, O>(currentHandler : Handler<I, O>)
|
||||||
|
~ addHandler(newHandler : Handler<O, K>) : Pipeline<I, K>
|
||||||
|
~ execute(input : I) : O
|
||||||
|
}
|
||||||
|
~class RemoveAlphabetsHandler {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
~ RemoveAlphabetsHandler()
|
||||||
|
+ process(input : String) : String
|
||||||
|
}
|
||||||
|
~class RemoveDigitsHandler {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
~ RemoveDigitsHandler()
|
||||||
|
+ process(input : String) : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Pipeline --> "-currentHandler" Handler
|
||||||
|
ConvertToCharArrayHandler ..|> Handler
|
||||||
|
RemoveAlphabetsHandler ..|> Handler
|
||||||
|
RemoveDigitsHandler ..|> Handler
|
||||||
|
@enduml
|
71
poison-pill/etc/poison-pill.urm.puml
Normal file
71
poison-pill/etc/poison-pill.urm.puml
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.poison.pill {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Consumer {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- name : String
|
||||||
|
- queue : MqSubscribePoint
|
||||||
|
+ Consumer(name : String, queue : MqSubscribePoint)
|
||||||
|
+ consume()
|
||||||
|
}
|
||||||
|
interface Message {
|
||||||
|
+ POISON_PILL : Message {static}
|
||||||
|
+ addHeader(Headers, String) {abstract}
|
||||||
|
+ getBody() : String {abstract}
|
||||||
|
+ getHeader(Headers) : String {abstract}
|
||||||
|
+ getHeaders() : Map<Headers, String> {abstract}
|
||||||
|
+ setBody(String) {abstract}
|
||||||
|
}
|
||||||
|
enum Headers {
|
||||||
|
+ DATE {static}
|
||||||
|
+ SENDER {static}
|
||||||
|
+ valueOf(name : String) : Headers {static}
|
||||||
|
+ values() : Headers[] {static}
|
||||||
|
}
|
||||||
|
interface MessageQueue {
|
||||||
|
}
|
||||||
|
interface MqPublishPoint {
|
||||||
|
+ put(Message) {abstract}
|
||||||
|
}
|
||||||
|
interface MqSubscribePoint {
|
||||||
|
+ take() : Message {abstract}
|
||||||
|
}
|
||||||
|
class Producer {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
- isStopped : boolean
|
||||||
|
- name : String
|
||||||
|
- queue : MqPublishPoint
|
||||||
|
+ Producer(name : String, queue : MqPublishPoint)
|
||||||
|
+ send(body : String)
|
||||||
|
+ stop()
|
||||||
|
}
|
||||||
|
class SimpleMessage {
|
||||||
|
- body : String
|
||||||
|
- headers : Map<Headers, String>
|
||||||
|
+ SimpleMessage()
|
||||||
|
+ addHeader(header : Headers, value : String)
|
||||||
|
+ getBody() : String
|
||||||
|
+ getHeader(header : Headers) : String
|
||||||
|
+ getHeaders() : Map<Headers, String>
|
||||||
|
+ setBody(body : String)
|
||||||
|
}
|
||||||
|
class SimpleMessageQueue {
|
||||||
|
- queue : BlockingQueue<Message>
|
||||||
|
+ SimpleMessageQueue(bound : int)
|
||||||
|
+ put(msg : Message)
|
||||||
|
+ take() : Message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SimpleMessageQueue --> "-queue" Message
|
||||||
|
Headers ..+ Message
|
||||||
|
Consumer --> "-queue" MqSubscribePoint
|
||||||
|
Producer --> "-queue" MqPublishPoint
|
||||||
|
Message --> "-POISON_PILL" Message
|
||||||
|
MessageQueue --|> MqPublishPoint
|
||||||
|
MessageQueue --|> MqSubscribePoint
|
||||||
|
SimpleMessage ..|> Message
|
||||||
|
SimpleMessageQueue ..|> MessageQueue
|
||||||
|
@enduml
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user