Work on #190: Add first batch of automagically generated puml files

This commit is contained in:
NooBxGockeL 2016-08-30 13:29:12 +02:00
parent e73867f9a1
commit 36fe249960
86 changed files with 4700 additions and 0 deletions

View File

@ -0,0 +1,59 @@
@startuml
package com.iluwatar.abstractdocument.domain {
class Part {
+ Part(properties : Map<String, Object>)
}
class Car {
+ Car(properties : Map<String, Object>)
}
interface HasModel {
+ PROPERTY : String {static}
+ getModel() : Optional<String>
}
interface HasParts {
+ PROPERTY : String {static}
+ getParts() : Stream<Part>
}
interface HasType {
+ PROPERTY : String {static}
+ getType() : Optional<String>
}
interface HasPrice {
+ PROPERTY : String {static}
+ getPrice() : Optional<Number>
}
}
package com.iluwatar.abstractdocument {
interface Document {
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
+ get(String) : Object {abstract}
+ put(String, Object) {abstract}
}
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 {
+ App()
+ main(args : String[]) {static}
}
}
AbstractDocument --+ Map
Part ..|> HasType
Part ..|> HasModel
Part ..|> HasPrice
Part --|> AbstractDocument
Car ..|> HasModel
Car ..|> HasPrice
Car ..|> HasParts
Car --|> AbstractDocument
HasModel --|> Document
HasParts --|> Document
AbstractDocument ..|> Document
HasType --|> Document
HasPrice --|> Document
@enduml

View File

@ -0,0 +1,88 @@
@startuml
package com.iluwatar.abstractfactory {
interface Castle {
+ getDescription() : String {abstract}
}
class OrcKingdomFactory {
+ OrcKingdomFactory()
+ createArmy() : Army
+ createCastle() : Castle
+ createKing() : King
}
class ElfKing {
~ DESCRIPTION : String {static}
+ ElfKing()
+ getDescription() : String
}
interface King {
+ getDescription() : String {abstract}
}
class App {
- 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 OrcKing {
~ DESCRIPTION : String {static}
+ OrcKing()
+ getDescription() : String
}
class ElfKingdomFactory {
+ ElfKingdomFactory()
+ createArmy() : Army
+ createCastle() : Castle
+ createKing() : King
}
interface Army {
+ getDescription() : String {abstract}
}
class OrcArmy {
~ DESCRIPTION : String {static}
+ OrcArmy()
+ getDescription() : String
}
interface KingdomFactory {
+ createArmy() : Army {abstract}
+ createCastle() : Castle {abstract}
+ createKing() : King {abstract}
}
class ElfArmy {
~ DESCRIPTION : String {static}
+ ElfArmy()
+ getDescription() : String
}
class ElfCastle {
~ DESCRIPTION : String {static}
+ ElfCastle()
+ getDescription() : String
}
class OrcCastle {
~ DESCRIPTION : String {static}
+ OrcCastle()
+ getDescription() : String
}
}
App --> "-castle" Castle
App --> "-king" King
App --> "-army" Army
OrcKingdomFactory ..|> KingdomFactory
ElfKing ..|> King
OrcKing ..|> King
ElfKingdomFactory ..|> KingdomFactory
OrcArmy ..|> Army
ElfArmy ..|> Army
ElfCastle ..|> Castle
OrcCastle ..|> Castle
@enduml

View File

@ -0,0 +1,35 @@
@startuml
package com.iluwatar.adapter {
class App {
+ App()
+ main(args : String[]) {static}
}
interface BattleShip {
+ fire() {abstract}
+ move() {abstract}
}
class Captain {
- battleship : BattleShip
+ Captain()
+ Captain(battleship : BattleShip)
+ fire()
+ move()
+ setBattleship(battleship : BattleShip)
}
class BattleFishingBoat {
- boat : FishingBoat
+ BattleFishingBoat()
+ fire()
+ move()
}
class FishingBoat {
+ FishingBoat()
+ fish()
+ sail()
}
}
BattleFishingBoat --> "-boat" FishingBoat
Captain --> "-battleship" BattleShip
Captain ..|> BattleShip
BattleFishingBoat ..|> BattleShip
@enduml

View File

@ -0,0 +1,41 @@
@startuml
package com.iluwatar.aggregator.microservices {
class Aggregator {
- informationClient : ProductInformationClient
- inventoryClient : ProductInventoryClient
+ Aggregator()
+ getProduct() : Product
}
class ProductInformationClientImpl {
+ ProductInformationClientImpl()
+ getProductTitle() : String
}
interface ProductInformationClient {
+ getProductTitle() : String {abstract}
}
class Product {
- productInventories : int
- title : String
+ Product()
+ getProductInventories() : int
+ getTitle() : String
+ setProductInventories(productInventories : int)
+ setTitle(title : String)
}
class ProductInventoryClientImpl {
+ ProductInventoryClientImpl()
+ getProductInventories() : int
}
class App {
+ App()
+ main(args : String[]) {static}
}
interface ProductInventoryClient {
+ getProductInventories() : int {abstract}
}
}
Aggregator --> "-inventoryClient" ProductInventoryClient
Aggregator --> "-informationClient" ProductInformationClient
ProductInformationClientImpl ..|> ProductInformationClient
ProductInventoryClientImpl ..|> ProductInventoryClient
@enduml

View File

@ -0,0 +1,12 @@
@startuml
package com.iluwatar.information.microservice {
class InformationApplication {
+ InformationApplication()
+ main(args : String[]) {static}
}
class InformationController {
+ InformationController()
+ getProductTitle() : String
}
}
@enduml

View File

@ -0,0 +1,12 @@
@startuml
package com.iluwatar.inventory.microservice {
class InventoryApplication {
+ InventoryApplication()
+ main(args : String[]) {static}
}
class InventoryController {
+ InventoryController()
+ getProductInventories() : int
}
}
@enduml

View File

@ -0,0 +1,48 @@
@startuml
package com.iluwatar.api.gateway {
interface ImageClient {
+ getImagePath() : String {abstract}
}
class MobileProduct {
- price : String
+ MobileProduct()
+ getPrice() : String
+ setPrice(price : String)
}
class ApiGateway {
- imageClient : ImageClient
- priceClient : PriceClient
+ ApiGateway()
+ getProductDesktop() : DesktopProduct
+ getProductMobile() : MobileProduct
}
class DesktopProduct {
- imagePath : String
- price : String
+ DesktopProduct()
+ getImagePath() : String
+ getPrice() : String
+ setImagePath(imagePath : String)
+ setPrice(price : String)
}
interface PriceClient {
+ getPrice() : String {abstract}
}
class PriceClientImpl {
+ PriceClientImpl()
+ getPrice() : String
}
class ImageClientImpl {
+ ImageClientImpl()
+ getImagePath() : String
}
class App {
+ App()
+ main(args : String[]) {static}
}
}
ApiGateway --> "-imageClient" ImageClient
ApiGateway --> "-priceClient" PriceClient
PriceClientImpl ..|> PriceClient
ImageClientImpl ..|> ImageClient
@enduml

View File

@ -0,0 +1,12 @@
@startuml
package com.iluwatar.image.microservice {
class ImageApplication {
+ ImageApplication()
+ main(args : String[]) {static}
}
class ImageController {
+ ImageController()
+ getImagePath() : String
}
}
@enduml

View File

@ -0,0 +1,12 @@
@startuml
package com.iluwatar.price.microservice {
class PriceApplication {
+ PriceApplication()
+ main(args : String[]) {static}
}
class PriceController {
+ PriceController()
+ getPrice() : String
}
}
@enduml

View File

@ -0,0 +1,50 @@
@startuml
package com.iluwatar.async.method.invocation {
interface AsyncCallback<T> {
+ onComplete(T, Optional<Exception>) {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 App {
+ App()
- callback(name : String) : AsyncCallback<T> {static}
- lazyval(value : T, delayMillis : long) : Callable<T> {static}
- log(msg : String) {static}
+ main(args : String[]) {static}
}
-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)
}
interface AsyncExecutor {
+ endProcess(AsyncResult<T>) : T {abstract}
+ startProcess(Callable<T>) : AsyncResult<T> {abstract}
+ startProcess(Callable<T>, AsyncCallback<T>) : AsyncResult<T> {abstract}
}
}
CompletableResult ..+ ThreadAsyncExecutor
ThreadAsyncExecutor ..|> AsyncExecutor
CompletableResult ..|> AsyncResult
@enduml

View File

@ -0,0 +1,89 @@
@startuml
package com.iluwatar.bridge {
class FlyingMagicWeapon {
+ FlyingMagicWeapon(imp : FlyingMagicWeaponImpl)
+ fly()
+ getImp() : FlyingMagicWeaponImpl
+ swing()
+ unwield()
+ wield()
}
abstract class MagicWeapon {
# imp : MagicWeaponImpl
+ MagicWeapon(imp : MagicWeaponImpl)
+ getImp() : MagicWeaponImpl
+ swing() {abstract}
+ unwield() {abstract}
+ wield() {abstract}
}
abstract class SoulEatingMagicWeaponImpl {
+ SoulEatingMagicWeaponImpl()
+ eatSoulImp() {abstract}
}
class BlindingMagicWeapon {
+ BlindingMagicWeapon(imp : BlindingMagicWeaponImpl)
+ blind()
+ getImp() : BlindingMagicWeaponImpl
+ swing()
+ unwield()
+ wield()
}
class Stormbringer {
+ Stormbringer()
+ eatSoulImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
abstract class BlindingMagicWeaponImpl {
+ BlindingMagicWeaponImpl()
+ blindImp() {abstract}
}
class SoulEatingMagicWeapon {
+ SoulEatingMagicWeapon(imp : SoulEatingMagicWeaponImpl)
+ eatSoul()
+ getImp() : SoulEatingMagicWeaponImpl
+ swing()
+ unwield()
+ wield()
}
abstract class MagicWeaponImpl {
+ MagicWeaponImpl()
+ swingImp() {abstract}
+ unwieldImp() {abstract}
+ wieldImp() {abstract}
}
class Excalibur {
+ Excalibur()
+ blindImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
abstract class FlyingMagicWeaponImpl {
+ FlyingMagicWeaponImpl()
+ flyImp() {abstract}
}
class Mjollnir {
+ Mjollnir()
+ flyImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
class App {
+ App()
+ main(args : String[]) {static}
}
}
MagicWeapon --> "-imp" MagicWeaponImpl
FlyingMagicWeapon --|> MagicWeapon
SoulEatingMagicWeaponImpl --|> MagicWeaponImpl
BlindingMagicWeapon --|> MagicWeapon
Stormbringer --|> SoulEatingMagicWeaponImpl
BlindingMagicWeaponImpl --|> MagicWeaponImpl
SoulEatingMagicWeapon --|> MagicWeapon
Excalibur --|> BlindingMagicWeaponImpl
FlyingMagicWeaponImpl --|> MagicWeaponImpl
Mjollnir --|> FlyingMagicWeaponImpl
@enduml

View File

@ -0,0 +1,100 @@
@startuml
package com.iluwatar.builder {
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 App {
+ App()
+ main(args : String[]) {static}
}
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 Armor {
+ CHAIN_MAIL {static}
+ CLOTHES {static}
+ LEATHER {static}
+ PLATE_MAIL {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Armor {static}
+ values() : Armor[] {static}
}
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}
}
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}
}
enum HairColor {
+ BLACK {static}
+ BLOND {static}
+ BROWN {static}
+ RED {static}
+ WHITE {static}
+ toString() : String
+ valueOf(name : String) : HairColor {static}
+ values() : HairColor[] {static}
}
}
Builder ..+ Hero
Hero --> "-profession" Profession
Hero --> "-armor" Armor
App --+ Hero
Builder --> "-weapon" Weapon
Builder --> "-hairColor" HairColor
Builder --> "-hairType" HairType
Hero --> "-hairColor" HairColor
Builder --> "-profession" Profession
Hero --> "-weapon" Weapon
Hero --> "-hairType" HairType
Builder --> "-armor" Armor
@enduml

View File

@ -0,0 +1,55 @@
@startuml
package com.iluwatar.business.delegate {
class BusinessLookup {
- ejbService : EjbService
- jmsService : JmsService
+ BusinessLookup()
+ getBusinessService(serviceType : ServiceType) : BusinessService
+ setEjbService(ejbService : EjbService)
+ setJmsService(jmsService : JmsService)
}
class Client {
- businessDelegate : BusinessDelegate
+ Client(businessDelegate : BusinessDelegate)
+ doTask()
}
class EjbService {
+ EjbService()
+ doProcessing()
}
class BusinessDelegate {
- businessService : BusinessService
- lookupService : BusinessLookup
- serviceType : ServiceType
+ BusinessDelegate()
+ doTask()
+ setLookupService(businessLookup : BusinessLookup)
+ setServiceType(serviceType : ServiceType)
}
interface BusinessService {
+ doProcessing() {abstract}
}
class JmsService {
+ JmsService()
+ doProcessing()
}
class App {
+ App()
+ main(args : String[]) {static}
}
enum ServiceType {
+ EJB {static}
+ JMS {static}
+ valueOf(name : String) : ServiceType {static}
+ values() : ServiceType[] {static}
}
}
BusinessDelegate --> "-serviceType" ServiceType
BusinessLookup --> "-ejbService" EjbService
Client --> "-businessDelegate" BusinessDelegate
BusinessDelegate --> "-businessService" BusinessService
BusinessDelegate --> "-lookupService" BusinessLookup
BusinessLookup --> "-jmsService" JmsService
EjbService ..|> BusinessService
JmsService ..|> BusinessService
@enduml

View File

@ -0,0 +1,100 @@
@startuml
package com.iluwatar.caching {
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
}
class CacheStore {
~ cache : LruCache {static}
- CacheStore()
+ clearCache() {static}
+ flushCache() {static}
+ initCapacity(capacity : int) {static}
+ print() : String {static}
+ readThrough(userId : String) : UserAccount {static}
+ readThroughWithWriteBackPolicy(userId : String) : UserAccount {static}
+ writeAround(userAccount : UserAccount) {static}
+ writeBehind(userAccount : UserAccount) {static}
+ writeThrough(userAccount : UserAccount) {static}
}
class AppManager {
- cachingPolicy : CachingPolicy {static}
- AppManager()
+ find(userId : String) : UserAccount {static}
+ initCacheCapacity(capacity : int) {static}
+ initCachingPolicy(policy : CachingPolicy) {static}
+ initDb(useMongoDb : boolean) {static}
+ printCacheContent() : String {static}
+ save(userAccount : UserAccount) {static}
}
~class Node {
~ next : Node
~ previous : Node
~ userAccount : UserAccount
~ userId : String
+ Node(this$0 : LruCache, userId : String, userAccount : UserAccount)
}
class LruCache {
~ 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 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 App {
+ App()
+ main(args : String[]) {static}
+ useReadAndWriteThroughStrategy()
+ useReadThroughAndWriteAroundStrategy()
+ useReadThroughAndWriteBehindStrategy()
}
enum CachingPolicy {
+ AROUND {static}
+ BEHIND {static}
+ THROUGH {static}
- policy : String
+ getPolicy() : String
+ valueOf(name : String) : CachingPolicy {static}
+ values() : CachingPolicy[] {static}
}
}
Node --+ LruCache
LruCache --> "-head" Node
Node --> "-previous" Node
AppManager --> "-cachingPolicy" CachingPolicy
Node --> "-userAccount" UserAccount
CacheStore --> "-cache" LruCache
@enduml

View File

@ -0,0 +1,25 @@
@startuml
package com.iluwatar.callback {
class LambdasApp {
+ LambdasApp()
+ main(args : String[]) {static}
}
class SimpleTask {
+ SimpleTask()
+ execute()
}
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class Task {
+ Task()
+ execute() {abstract}
+ executeWith(callback : Callback)
}
interface Callback {
+ call() {abstract}
}
}
SimpleTask --|> Task
@enduml

60
chain/etc/chain.urm.puml Normal file
View File

@ -0,0 +1,60 @@
@startuml
package com.iluwatar.chain {
class OrcCommander {
+ OrcCommander(handler : RequestHandler)
+ handleRequest(req : Request)
+ toString() : String
}
class App {
+ App()
+ main(args : String[]) {static}
}
class Request {
- handled : boolean
- requestDescription : String
- requestType : RequestType
+ Request(requestType : RequestType, requestDescription : String)
+ getRequestDescription() : String
+ getRequestType() : RequestType
+ isHandled() : boolean
+ markHandled()
+ toString() : String
}
class OrcOfficer {
+ OrcOfficer(handler : RequestHandler)
+ handleRequest(req : Request)
+ toString() : String
}
class OrcKing {
~ chain : RequestHandler
+ OrcKing()
- buildChain()
+ makeRequest(req : Request)
}
class OrcSoldier {
+ OrcSoldier(handler : RequestHandler)
+ handleRequest(req : Request)
+ toString() : String
}
abstract class RequestHandler {
- 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}
}
}
RequestHandler --> "-next" RequestHandler
OrcKing --> "-chain" RequestHandler
Request --> "-requestType" RequestType
OrcCommander --|> RequestHandler
OrcOfficer --|> RequestHandler
OrcSoldier --|> RequestHandler
@enduml

View File

@ -0,0 +1,84 @@
@startuml
package com.iluwatar.command {
abstract class Target {
- size : Size
- visibility : Visibility
+ Target()
+ getSize() : Size
+ getVisibility() : Visibility
+ printStatus()
+ setSize(size : Size)
+ setVisibility(visibility : Visibility)
+ toString() : String {abstract}
}
class Goblin {
+ Goblin()
+ toString() : String
}
class ShrinkSpell {
- oldSize : Size
- target : Target
+ ShrinkSpell()
+ execute(target : Target)
+ redo()
+ toString() : String
+ undo()
}
class InvisibilitySpell {
- target : Target
+ InvisibilitySpell()
+ execute(target : Target)
+ redo()
+ toString() : String
+ undo()
}
class Wizard {
- redoStack : Deque<Command>
- undoStack : Deque<Command>
+ Wizard()
+ castSpell(command : Command, target : Target)
+ redoLastSpell()
+ toString() : String
+ undoLastSpell()
}
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class Command {
+ Command()
+ execute(Target) {abstract}
+ redo() {abstract}
+ toString() : String {abstract}
+ undo() {abstract}
}
enum Size {
+ LARGE {static}
+ NORMAL {static}
+ SMALL {static}
+ UNDEFINED {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Size {static}
+ values() : Size[] {static}
}
enum Visibility {
+ INVISIBLE {static}
+ UNDEFINED {static}
+ VISIBLE {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Visibility {static}
+ values() : Visibility[] {static}
}
}
Target --> "-size" Size
Wizard --> "-undoStack" Command
ShrinkSpell --> "-oldSize" Size
InvisibilitySpell --> "-target" Target
ShrinkSpell --> "-target" Target
Target --> "-visibility" Visibility
Goblin --|> Target
ShrinkSpell --|> Command
InvisibilitySpell --|> Command
@enduml

View File

@ -0,0 +1,42 @@
@startuml
package com.iluwatar.composite {
class Letter {
- c : char
+ Letter(c : char)
# printThisAfter()
# printThisBefore()
}
class Sentence {
+ Sentence(words : List<Word>)
# printThisAfter()
# printThisBefore()
}
class Word {
+ Word(letters : List<Letter>)
# printThisAfter()
# printThisBefore()
}
class Messenger {
+ Messenger()
~ messageFromElves() : LetterComposite
~ messageFromOrcs() : LetterComposite
}
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class LetterComposite {
- children : List<LetterComposite>
+ LetterComposite()
+ add(letter : LetterComposite)
+ count() : int
+ print()
# printThisAfter() {abstract}
# printThisBefore() {abstract}
}
}
LetterComposite --> "-children" LetterComposite
Letter --|> LetterComposite
Sentence --|> LetterComposite
Word --|> LetterComposite
@enduml

65
dao/etc/dao.urm.puml Normal file
View File

@ -0,0 +1,65 @@
@startuml
package com.iluwatar.dao {
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 DbCustomerDao {
- dataSource : DataSource
+ DbCustomerDao(dataSource : DataSource)
+ add(customer : Customer) : boolean
- createCustomer(resultSet : ResultSet) : Customer
+ delete(customer : Customer) : boolean
+ getAll() : Stream<Customer>
+ getById(id : int) : Optional<Customer>
- getConnection() : Connection
- mutedClose(connection : Connection)
+ update(customer : Customer) : boolean
}
class InMemoryCustomerDao {
- idToCustomer : Map<Integer, Customer>
+ InMemoryCustomerDao()
+ add(customer : Customer) : boolean
+ delete(customer : Customer) : boolean
+ getAll() : Stream<Customer>
+ getById(id : int) : Optional<Customer>
+ update(customer : Customer) : boolean
}
interface CustomerSchemaSql {
+ CREATE_SCHEMA_SQL : String {static}
+ DELETE_SCHEMA_SQL : String {static}
}
class App {
- DB_URL : String {static}
- log : Logger {static}
+ App()
- addCustomers(customerDao : CustomerDao) {static}
- createDataSource() : DataSource {static}
- createSchema(dataSource : DataSource) {static}
- deleteSchema(dataSource : DataSource) {static}
+ generateSampleCustomers() : List<Customer> {static}
+ main(args : String[]) {static}
- performOperationsUsing(customerDao : CustomerDao) {static}
}
}
DbCustomerDao ..|> CustomerDao
InMemoryCustomerDao ..|> CustomerDao
@enduml

View File

@ -0,0 +1,42 @@
@startuml
package com.iluwatar.datamapper {
interface StudentDataMapper {
+ delete(Student) {abstract}
+ find(int) : Optional<Student> {abstract}
+ insert(Student) {abstract}
+ update(Student) {abstract}
}
class App {
- 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
}
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

View File

@ -0,0 +1,29 @@
@startuml
package com.iluwatar.decorator {
class App {
+ App()
+ main(args : String[]) {static}
}
class Troll {
+ Troll()
+ attack()
+ fleeBattle()
+ getAttackPower() : int
}
interface Hostile {
+ attack() {abstract}
+ fleeBattle() {abstract}
+ getAttackPower() : int {abstract}
}
class SmartHostile {
- decorated : Hostile
+ SmartHostile(decorated : Hostile)
+ attack()
+ fleeBattle()
+ getAttackPower() : int
}
}
SmartHostile --> "-decorated" Hostile
Troll ..|> Hostile
SmartHostile ..|> Hostile
@enduml

View File

@ -0,0 +1,36 @@
@startuml
package com.iluwatar.delegation.simple.printers {
class EpsonPrinter {
+ EpsonPrinter()
+ print(message : String)
}
class HpPrinter {
+ HpPrinter()
+ print(message : String)
}
class CanonPrinter {
+ CanonPrinter()
+ print(message : String)
}
}
package com.iluwatar.delegation.simple {
class PrinterController {
- printer : Printer
+ PrinterController(printer : Printer)
+ print(message : String)
}
interface Printer {
+ print(String) {abstract}
}
class App {
+ MESSAGE_TO_PRINT : String {static}
+ App()
+ main(args : String[]) {static}
}
}
PrinterController --> "-printer" Printer
PrinterController ..|> Printer
EpsonPrinter ..|> Printer
HpPrinter ..|> Printer
CanonPrinter ..|> Printer
@enduml

View File

@ -0,0 +1,48 @@
@startuml
package com.iluwatar.dependency.injection {
interface Wizard {
+ smoke() {abstract}
}
class GuiceWizard {
- tobacco : Tobacco
+ GuiceWizard(tobacco : Tobacco)
+ smoke()
}
class OldTobyTobacco {
+ OldTobyTobacco()
}
abstract class Tobacco {
+ Tobacco()
+ smoke(wizard : Wizard)
}
class App {
+ App()
+ main(args : String[]) {static}
}
class RivendellTobacco {
+ RivendellTobacco()
}
class AdvancedWizard {
- tobacco : Tobacco
+ AdvancedWizard(tobacco : Tobacco)
+ smoke()
}
class SecondBreakfastTobacco {
+ SecondBreakfastTobacco()
}
class SimpleWizard {
- tobacco : OldTobyTobacco
+ SimpleWizard()
+ smoke()
}
}
SimpleWizard --> "-tobacco" OldTobyTobacco
AdvancedWizard --> "-tobacco" Tobacco
GuiceWizard --> "-tobacco" Tobacco
GuiceWizard ..|> Wizard
OldTobyTobacco --|> Tobacco
RivendellTobacco --|> Tobacco
AdvancedWizard ..|> Wizard
SecondBreakfastTobacco --|> Tobacco
SimpleWizard ..|> Wizard
@enduml

View File

@ -0,0 +1,20 @@
@startuml
package com.iluwatar.doublechecked.locking {
class App {
+ App()
+ main(args : String[]) {static}
}
class Inventory {
- inventorySize : int
- items : List<Item>
- lock : Lock
+ Inventory(inventorySize : int)
+ addItem(item : Item) : boolean
+ getItems() : List<Item>
}
class Item {
+ Item()
}
}
Inventory --> "-items" Item
@enduml

View File

@ -0,0 +1,65 @@
@startuml
package com.iluwatar.doubledispatch {
class App {
+ App()
+ main(args : String[]) {static}
}
class FlamingAsteroid {
+ FlamingAsteroid(left : int, top : int, right : int, bottom : int)
+ collision(gameObject : GameObject)
}
class SpaceStationIss {
+ SpaceStationIss(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 SpaceStationMir {
+ SpaceStationMir(left : int, top : int, right : int, bottom : int)
+ collision(gameObject : GameObject)
+ collisionResolve(asteroid : FlamingAsteroid)
+ collisionResolve(iss : SpaceStationIss)
+ collisionResolve(meteoroid : Meteoroid)
+ collisionResolve(mir : SpaceStationMir)
}
class Meteoroid {
+ 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
}
}
FlamingAsteroid --|> Meteoroid
SpaceStationIss --|> SpaceStationMir
GameObject --|> Rectangle
SpaceStationMir --|> GameObject
Meteoroid --|> GameObject
@enduml

View File

@ -0,0 +1,73 @@
@startuml
package com.iluwatar.event.aggregator {
class KingsHand {
+ KingsHand()
+ KingsHand(obs : EventObserver)
+ onEvent(e : Event)
+ timePasses(day : Weekday)
}
class KingJoffrey {
+ KingJoffrey()
+ onEvent(e : Event)
}
class Scout {
+ Scout()
+ Scout(obs : EventObserver)
+ timePasses(day : Weekday)
}
class LordVarys {
+ LordVarys()
+ LordVarys(obs : EventObserver)
+ timePasses(day : Weekday)
}
class App {
+ App()
+ main(args : String[]) {static}
}
class LordBaelish {
+ LordBaelish()
+ LordBaelish(obs : EventObserver)
+ timePasses(day : Weekday)
}
abstract class EventEmitter {
- observers : List<EventObserver>
+ EventEmitter()
+ EventEmitter(obs : EventObserver)
# notifyObservers(e : Event)
+ registerObserver(obs : EventObserver)
+ timePasses(Weekday) {abstract}
}
interface EventObserver {
+ onEvent(Event) {abstract}
}
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}
}
enum Event {
+ STARK_SIGHTED {static}
+ TRAITOR_DETECTED {static}
+ WARSHIPS_APPROACHING {static}
- description : String
+ toString() : String
+ valueOf(name : String) : Event {static}
+ values() : Event[] {static}
}
}
EventEmitter --> "-observers" EventObserver
KingsHand ..|> EventObserver
KingsHand --|> EventEmitter
KingJoffrey ..|> EventObserver
Scout --|> EventEmitter
LordVarys --|> EventEmitter
LordBaelish --|> EventEmitter
@enduml

View File

@ -0,0 +1,62 @@
@startuml
package com.iluwatar.eda.handler {
class UserUpdatedEventHandler {
+ UserUpdatedEventHandler()
+ onEvent(event : UserUpdatedEvent)
}
class UserCreatedEventHandler {
+ UserCreatedEventHandler()
+ onEvent(event : UserCreatedEvent)
}
}
package com.iluwatar.eda.event {
abstract class AbstractEvent {
+ AbstractEvent()
+ getType() : Class<? extends Event>
}
class UserUpdatedEvent {
- user : User
+ UserUpdatedEvent(user : User)
+ getUser() : User
}
class UserCreatedEvent {
- user : User
+ UserCreatedEvent(user : User)
+ getUser() : User
}
}
package com.iluwatar.eda.framework {
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 Event {
+ getType() : Class<? extends Event> {abstract}
}
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
UserUpdatedEventHandler ..|> Handler
UserCreatedEventHandler ..|> Handler
UserUpdatedEvent --|> AbstractEvent
UserCreatedEvent --|> AbstractEvent
@enduml

View File

@ -0,0 +1,14 @@
@startuml
package com.iluwatar.execute.around {
interface FileWriterAction {
+ writeFile(FileWriter) {abstract}
}
class SimpleFileWriter {
+ SimpleFileWriter(filename : String, action : FileWriterAction)
}
class App {
+ App()
+ main(args : String[]) {static}
}
}
@enduml

View File

@ -0,0 +1,57 @@
@startuml
package com.iluwatar.facade {
class DwarvenTunnelDigger {
+ DwarvenTunnelDigger()
+ name() : String
+ work()
}
class DwarvenGoldmineFacade {
- workers : List<DwarvenMineWorker>
+ DwarvenGoldmineFacade()
+ digOutGold()
+ endDay()
- makeActions(workers : Collection<DwarvenMineWorker>, actions : Action[]) {static}
+ startNewDay()
}
class DwarvenGoldDigger {
+ DwarvenGoldDigger()
+ name() : String
+ work()
}
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class DwarvenMineWorker {
+ DwarvenMineWorker()
- action(action : Action)
+ action(actions : Action[])
+ goHome()
+ goToMine()
+ goToSleep()
+ name() : String {abstract}
+ wakeUp()
+ work() {abstract}
}
class DwarvenCartOperator {
+ DwarvenCartOperator()
+ name() : String
+ work()
}
~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}
}
}
DwarvenGoldmineFacade --+ DwarvenMineWorker
DwarvenGoldmineFacade --> "-workers" DwarvenMineWorker
Action ..+ DwarvenMineWorker
DwarvenTunnelDigger --|> DwarvenMineWorker
DwarvenGoldDigger --|> DwarvenMineWorker
DwarvenCartOperator --|> DwarvenMineWorker
@enduml

View File

@ -0,0 +1,45 @@
@startuml
package com.iluwatar.factorykit {
interface Builder {
+ add(WeaponType, Supplier<Weapon>) {abstract}
}
class Spear {
+ Spear()
+ toString() : String
}
class Bow {
+ Bow()
+ toString() : String
}
class Sword {
+ Sword()
+ toString() : String
}
interface Weapon {
}
class App {
+ App()
+ main(args : String[]) {static}
}
class Axe {
+ Axe()
+ toString() : String
}
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}
}
}
Spear ..|> Weapon
Bow ..|> Weapon
Sword ..|> Weapon
Axe ..|> Weapon
@enduml

View File

@ -0,0 +1,53 @@
@startuml
package com.iluwatar.factory.method {
class OrcBlacksmith {
+ OrcBlacksmith()
+ manufactureWeapon(weaponType : WeaponType) : Weapon
}
class ElfBlacksmith {
+ ElfBlacksmith()
+ manufactureWeapon(weaponType : WeaponType) : Weapon
}
class OrcWeapon {
- weaponType : WeaponType
+ OrcWeapon(weaponType : WeaponType)
+ getWeaponType() : WeaponType
+ toString() : String
}
interface Blacksmith {
+ manufactureWeapon(WeaponType) : Weapon {abstract}
}
interface Weapon {
+ getWeaponType() : WeaponType {abstract}
}
class ElfWeapon {
- weaponType : WeaponType
+ ElfWeapon(weaponType : WeaponType)
+ getWeaponType() : WeaponType
+ toString() : String
}
class App {
- blacksmith : Blacksmith
+ App(blacksmith : Blacksmith)
+ main(args : String[]) {static}
- manufactureWeapons()
}
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
OrcBlacksmith ..|> Blacksmith
ElfBlacksmith ..|> Blacksmith
OrcWeapon ..|> Weapon
ElfWeapon ..|> Weapon
@enduml

View File

@ -0,0 +1,47 @@
@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.propertiesversion {
class PropertiesFeatureToggleVersion {
- isEnhanced : boolean
+ PropertiesFeatureToggleVersion(properties : Properties)
+ getWelcomeMessage(user : User) : String
+ isEnhanced() : boolean
}
}
package com.iluwatar.featuretoggle.pattern.tieredversion {
class TieredFeatureToggleVersion {
+ TieredFeatureToggleVersion()
+ getWelcomeMessage(user : User) : String
+ isEnhanced() : boolean
}
}
package com.iluwatar.featuretoggle {
class App {
+ App()
+ main(args : String[]) {static}
}
}
UserGroup --> "-freeGroup" User
TieredFeatureToggleVersion ..|> Service
PropertiesFeatureToggleVersion ..|> Service
@enduml

View File

@ -0,0 +1,71 @@
@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 {
+ 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 {
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>
}
abstract class DecoratingIterator<E> {
# fromIterator : Iterator<E>
- next : E
+ DecoratingIterator<E>(fromIterator : Iterator<E>)
+ computeNext() : E {abstract}
+ hasNext() : boolean
+ next() : E
}
}
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

115
flux/etc/flux.urm.puml Normal file
View File

@ -0,0 +1,115 @@
@startuml
package com.iluwatar.flux.view {
class ContentView {
- content : Content
+ ContentView()
+ render()
+ storeChanged(store : Store)
}
class MenuView {
- selected : MenuItem
+ MenuView()
+ itemClicked(item : MenuItem)
+ render()
+ storeChanged(store : Store)
}
interface View {
+ render() {abstract}
+ storeChanged(Store) {abstract}
}
}
package com.iluwatar.flux.action {
class ContentAction {
- content : Content
+ ContentAction(content : Content)
+ getContent() : Content
}
class MenuAction {
- menuItem : MenuItem
+ MenuAction(menuItem : MenuItem)
+ getMenuItem() : MenuItem
}
abstract class Action {
- type : ActionType
+ Action(type : ActionType)
+ getType() : ActionType
}
enum MenuItem {
+ COMPANY {static}
+ HOME {static}
+ PRODUCTS {static}
- title : String
+ toString() : String
+ valueOf(name : String) : MenuItem {static}
+ values() : MenuItem[] {static}
}
enum Content {
+ COMPANY {static}
+ PRODUCTS {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Content {static}
+ values() : Content[] {static}
}
enum ActionType {
+ CONTENT_CHANGED {static}
+ MENU_ITEM_SELECTED {static}
+ valueOf(name : String) : ActionType {static}
+ values() : ActionType[] {static}
}
}
package com.iluwatar.flux.app {
class App {
+ App()
+ main(args : String[]) {static}
}
}
package com.iluwatar.flux.store {
abstract class Store {
- views : List<View>
+ Store()
# notifyChange()
+ onAction(Action) {abstract}
+ registerView(view : View)
}
class ContentStore {
- content : Content
+ ContentStore()
+ getContent() : Content
+ onAction(action : Action)
}
class MenuStore {
- selected : MenuItem
+ MenuStore()
+ getSelected() : MenuItem
+ onAction(action : Action)
}
}
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
ContentStore --|> Store
ContentView ..|> View
MenuAction --|> Action
MenuView ..|> View
MenuStore --|> Store
@enduml

View File

@ -0,0 +1,60 @@
@startuml
package com.iluwatar.flyweight {
class PoisonPotion {
+ PoisonPotion()
+ drink()
}
class StrengthPotion {
+ StrengthPotion()
+ drink()
}
class HealingPotion {
+ HealingPotion()
+ drink()
}
class PotionFactory {
- potions : Map<PotionType, Potion>
+ PotionFactory()
~ createPotion(type : PotionType) : Potion
}
interface Potion {
+ drink() {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
class AlchemistShop {
- bottomShelf : List<Potion>
- topShelf : List<Potion>
+ AlchemistShop()
+ enumerate()
- fillShelves()
+ getBottomShelf() : List<Potion>
+ getTopShelf() : List<Potion>
}
class HolyWaterPotion {
+ HolyWaterPotion()
+ drink()
}
class InvisibilityPotion {
+ InvisibilityPotion()
+ drink()
}
enum PotionType {
+ HEALING {static}
+ HOLY_WATER {static}
+ INVISIBILITY {static}
+ POISON {static}
+ STRENGTH {static}
+ valueOf(name : String) : PotionType {static}
+ values() : PotionType[] {static}
}
}
AlchemistShop --> "-topShelf" Potion
PoisonPotion ..|> Potion
StrengthPotion ..|> Potion
HealingPotion ..|> Potion
HolyWaterPotion ..|> Potion
InvisibilityPotion ..|> Potion
@enduml

View File

@ -0,0 +1,50 @@
@startuml
package com.iluwatar.front.controller {
class App {
+ App()
+ main(args : String[]) {static}
}
class FrontController {
+ FrontController()
- getCommand(request : String) : Command
- getCommandClass(request : String) : Class<T> {static}
+ handleRequest(request : String)
}
class ArcherView {
+ ArcherView()
+ display()
}
interface View {
+ display() {abstract}
}
interface Command {
+ process() {abstract}
}
class ErrorView {
+ ErrorView()
+ display()
}
class ArcherCommand {
+ ArcherCommand()
+ process()
}
class CatapultView {
+ CatapultView()
+ display()
}
class CatapultCommand {
+ CatapultCommand()
+ process()
}
class UnknownCommand {
+ UnknownCommand()
+ process()
}
}
ArcherView ..|> View
ErrorView ..|> View
ArcherCommand ..|> Command
CatapultView ..|> View
CatapultCommand ..|> Command
UnknownCommand ..|> Command
@enduml

View File

@ -0,0 +1,30 @@
@startuml
package com.iluwatar.halfsynchalfasync {
class App {
+ App()
- ap(i : long) : long {static}
+ main(args : String[]) {static}
}
interface AsyncTask<O> {
+ call() : O {abstract}
+ onError(Throwable) {abstract}
+ onPostCall(O) {abstract}
+ onPreCall() {abstract}
}
~class ArithmeticSumTask {
- n : long
+ ArithmeticSumTask(n : long)
+ call() : Long
+ onError(throwable : Throwable)
+ onPostCall(result : Long)
+ onPreCall()
}
class AsynchronousService {
- service : ExecutorService
+ AsynchronousService(workQueue : BlockingQueue<Runnable>)
+ execute(task : AsyncTask<T>)
}
}
ArithmeticSumTask ..+ App
ArithmeticSumTask ..|> AsyncTask
@enduml

View File

@ -0,0 +1,183 @@
@startuml
package com.iluwatar.hexagonal.service {
class LotteryServiceImpl {
- bank : WireTransfers
- notifications : LotteryNotifications
- repository : LotteryTicketRepository
+ LotteryServiceImpl()
+ checkTicketForPrize(id : LotteryTicketId, winningNumbers : LotteryNumbers) : LotteryTicketCheckResult
+ submitTicket(ticket : LotteryTicket) : Optional<LotteryTicketId>
}
interface LotteryService {
+ checkTicketForPrize(LotteryTicketId, LotteryNumbers) : LotteryTicketCheckResult {abstract}
+ submitTicket(LotteryTicket) : Optional<LotteryTicketId> {abstract}
}
}
package com.iluwatar.hexagonal.domain {
class LotteryTicketId {
- id : UUID
+ LotteryTicketId()
+ getId() : UUID
}
class LotteryConstants {
+ PLAYER_MAX_SALDO : int {static}
+ PRIZE_AMOUNT : int {static}
+ SERVICE_BANK_ACCOUNT : String {static}
+ SERVICE_BANK_ACCOUNT_SALDO : 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>
+ hashCode() : int
}
class PlayerDetails {
- bankAccountNumber : String
- emailAddress : String
- phoneNumber : String
- PlayerDetails(email : String, bankAccount : String, phone : String)
+ create(email : String, bankAccount : String, phone : String) : PlayerDetails {static}
+ equals(obj : Object) : boolean
+ getBankAccount() : String
+ getEmail() : String
+ getPhoneNumber() : String
+ hashCode() : int
}
class LotteryTicketCheckResult {
- checkResult : CheckResult
- prizeAmount : int
+ LotteryTicketCheckResult(result : CheckResult)
+ LotteryTicketCheckResult(result : CheckResult, amount : int)
+ equals(obj : Object) : boolean
+ getPrizeAmount() : int
+ getResult() : CheckResult
+ hashCode() : int
}
class LotteryTicket {
- lotteryNumbers : LotteryNumbers
- playerDetails : PlayerDetails
- LotteryTicket(details : PlayerDetails, numbers : LotteryNumbers)
+ create(details : PlayerDetails, numbers : LotteryNumbers) : LotteryTicket {static}
+ equals(obj : Object) : boolean
+ getNumbers() : LotteryNumbers
+ getPlayerDetails() : PlayerDetails
+ hashCode() : int
}
-class RandomNumberGenerator {
- randomIterator : OfInt
+ RandomNumberGenerator(min : int, max : int)
+ nextInt() : int
}
enum CheckResult {
+ NO_PRIZE {static}
+ TICKET_NOT_SUBMITTED {static}
+ WIN_PRIZE {static}
+ valueOf(name : String) : CheckResult {static}
+ values() : CheckResult[] {static}
}
}
package com.iluwatar.hexagonal.banking {
class WireTransfersImpl {
- accounts : Map<String, Integer> {static}
+ WireTransfersImpl()
+ getFunds(bankAccount : String) : int
+ setFunds(bankAccount : String, amount : int)
+ transferFunds(amount : int, sourceBackAccount : String, destinationBankAccount : String) : boolean
}
interface WireTransfers {
+ getFunds(String) : int {abstract}
+ setFunds(String, int) {abstract}
+ transferFunds(int, String, String) : boolean {abstract}
}
}
package com.iluwatar.hexagonal.database {
class LotteryTicketInMemoryRepository {
- tickets : Map<LotteryTicketId, LotteryTicket> {static}
+ LotteryTicketInMemoryRepository()
+ 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}
}
}
package com.iluwatar.hexagonal.notifications {
interface LotteryNotifications {
+ notifyNoWin(PlayerDetails) {abstract}
+ notifyPrize(PlayerDetails, int) {abstract}
+ notifyPrizeError(PlayerDetails, int) {abstract}
+ notifyTicketSubmitError(PlayerDetails) {abstract}
+ notifyTicketSubmitted(PlayerDetails) {abstract}
}
class LotteryNotificationsImpl {
+ LotteryNotificationsImpl()
+ notifyNoWin(details : PlayerDetails)
+ notifyPrize(details : PlayerDetails, prizeAmount : int)
+ notifyPrizeError(details : PlayerDetails, prizeAmount : int)
+ notifyTicketSubmitError(details : PlayerDetails)
+ notifyTicketSubmitted(details : PlayerDetails)
}
}
package com.iluwatar.hexagonal {
class App {
- allPlayerDetails : List<PlayerDetails> {static}
+ App()
- getRandomPlayerDetails() : PlayerDetails {static}
+ main(args : String[]) {static}
- submitTickets(lotteryService : LotteryService, numTickets : int) {static}
}
}
package com.iluwatar.hexagonal.administration {
interface LotteryAdministration {
+ getAllSubmittedTickets() : Map<LotteryTicketId, LotteryTicket> {abstract}
+ performLottery() : LotteryNumbers {abstract}
+ resetLottery() {abstract}
}
class LotteryAdministrationImpl {
- bank : WireTransfers
- notifications : LotteryNotifications
- repository : LotteryTicketRepository
- service : LotteryService
+ LotteryAdministrationImpl()
+ getAllSubmittedTickets() : Map<LotteryTicketId, LotteryTicket>
+ performLottery() : LotteryNumbers
+ resetLottery()
}
}
LotteryTicket --> "-playerDetails" PlayerDetails
LotteryAdministrationImpl --> "-bank" WireTransfers
App --> "-allPlayerDetails" PlayerDetails
RandomNumberGenerator ..+ PrimitiveIterator
LotteryAdministrationImpl --> "-repository" LotteryTicketRepository
LotteryAdministrationImpl --+ LotteryTicketCheckResult
LotteryServiceImpl --> "-notifications" LotteryNotifications
LotteryTicket --> "-lotteryNumbers" LotteryNumbers
LotteryAdministrationImpl --> "-notifications" LotteryNotifications
LotteryServiceImpl --> "-repository" LotteryTicketRepository
LotteryServiceImpl --+ LotteryTicketCheckResult
LotteryServiceImpl --> "-bank" WireTransfers
RandomNumberGenerator ..+ LotteryNumbers
LotteryAdministrationImpl --> "-service" LotteryService
LotteryTicketCheckResult --> "-checkResult" CheckResult
CheckResult ..+ LotteryTicketCheckResult
LotteryTicketInMemoryRepository ..|> LotteryTicketRepository
WireTransfersImpl ..|> WireTransfers
LotteryServiceImpl ..|> LotteryService
LotteryNotificationsImpl ..|> LotteryNotifications
LotteryAdministrationImpl ..|> LotteryAdministration
@enduml

View File

@ -0,0 +1,88 @@
@startuml
package com.iluwatar.intercepting.filter {
interface Filter {
+ execute(Order) : String {abstract}
+ getLast() : Filter {abstract}
+ getNext() : Filter {abstract}
+ setNext(Filter) {abstract}
}
abstract class AbstractFilter {
- next : Filter
+ AbstractFilter()
+ AbstractFilter(next : Filter)
+ execute(order : Order) : String
+ getLast() : Filter
+ getNext() : Filter
+ setNext(filter : Filter)
}
class ContactFilter {
+ ContactFilter()
+ execute(order : Order) : String
}
class OrderFilter {
+ OrderFilter()
+ execute(order : Order) : String
}
class Order {
- address : String
- contactNumber : String
- depositNumber : String
- name : String
- order : String
+ Order()
+ Order(name : String, contactNumber : String, address : String, depositNumber : String, order : String)
+ getAddress() : String
+ getContactNumber() : String
+ getDepositNumber() : String
+ getName() : String
+ getOrder() : String
+ setAddress(address : String)
+ setContactNumber(contactNumber : String)
+ setDepositNumber(depositNumber : String)
+ setName(name : String)
+ setOrder(order : String)
}
class AddressFilter {
+ AddressFilter()
+ execute(order : Order) : String
}
~class DListener {
~ DListener(this$0 : Target)
+ actionPerformed(e : ActionEvent)
}
class FilterManager {
- filterChain : FilterChain
+ FilterManager()
+ addFilter(filter : Filter)
+ filterRequest(order : Order) : String
}
class FilterChain {
- chain : Filter
+ FilterChain()
+ addFilter(filter : Filter)
+ execute(order : Order) : String
}
class DepositFilter {
+ DepositFilter()
+ execute(order : Order) : String
}
class App {
+ App()
+ main(args : String[]) {static}
}
class NameFilter {
+ NameFilter()
+ execute(order : Order) : String
}
}
AbstractFilter --> "-next" Filter
DListener --+ Target
FilterChain --> "-chain" Filter
FilterManager --> "-filterChain" FilterChain
AbstractFilter ..|> Filter
ContactFilter --|> AbstractFilter
OrderFilter --|> AbstractFilter
AddressFilter --|> AbstractFilter
DepositFilter --|> AbstractFilter
NameFilter --|> AbstractFilter
@enduml

View File

@ -0,0 +1,50 @@
@startuml
package com.iluwatar.interpreter {
abstract class Expression {
+ Expression()
+ interpret() : int {abstract}
+ toString() : String {abstract}
}
class PlusExpression {
- leftExpression : Expression
- rightExpression : Expression
+ PlusExpression(leftExpression : Expression, rightExpression : Expression)
+ interpret() : int
+ toString() : String
}
class App {
+ App()
+ getOperatorInstance(s : String, left : Expression, right : Expression) : Expression {static}
+ isOperator(s : String) : boolean {static}
+ main(args : String[]) {static}
}
class NumberExpression {
- number : int
+ NumberExpression(number : int)
+ NumberExpression(s : String)
+ interpret() : int
+ toString() : String
}
class MultiplyExpression {
- leftExpression : Expression
- rightExpression : Expression
+ MultiplyExpression(leftExpression : Expression, rightExpression : Expression)
+ interpret() : int
+ toString() : String
}
class MinusExpression {
- leftExpression : Expression
- rightExpression : Expression
+ MinusExpression(leftExpression : Expression, rightExpression : Expression)
+ interpret() : int
+ toString() : String
}
}
MultiplyExpression --> "-leftExpression" Expression
MinusExpression --> "-leftExpression" Expression
PlusExpression --> "-leftExpression" Expression
PlusExpression --|> Expression
NumberExpression --|> Expression
MultiplyExpression --|> Expression
MinusExpression --|> Expression
@enduml

View File

@ -0,0 +1,48 @@
@startuml
package com.iluwatar.iterator {
interface ItemIterator {
+ hasNext() : boolean {abstract}
+ next() : Item {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
class TreasureChestItemIterator {
- chest : TreasureChest
- idx : int
- type : ItemType
+ TreasureChestItemIterator(chest : TreasureChest, type : ItemType)
- findNextIdx() : int
+ hasNext() : boolean
+ next() : Item
}
class TreasureChest {
- items : List<Item>
+ TreasureChest()
+ getItems() : List<Item>
~ iterator(itemType : ItemType) : ItemIterator
}
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}
}
}
Item --> "-type" ItemType
TreasureChest --> "-items" Item
TreasureChestItemIterator --> "-type" ItemType
TreasureChestItemIterator --> "-chest" TreasureChest
TreasureChestItemIterator ..|> ItemIterator
@enduml

125
layers/etc/layers.urm.puml Normal file
View File

@ -0,0 +1,125 @@
@startuml
package com.iluwatar.layers {
interface View {
+ render() {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)
}
interface CakeDao {
}
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
}
class CakeLayerInfo {
+ calories : int
+ id : Optional<Long>
+ name : String
+ CakeLayerInfo(id : Long, name : String, calories : int)
+ CakeLayerInfo(name : String, calories : int)
+ toString() : String
}
interface CakeLayerDao {
}
interface CakeToppingDao {
}
interface CakeBakingService {
+ bakeNewCake(CakeInfo) {abstract}
+ getAllCakes() : List<CakeInfo> {abstract}
+ getAvailableLayers() : List<CakeLayerInfo> {abstract}
+ getAvailableToppings() : List<CakeToppingInfo> {abstract}
+ saveNewLayer(CakeLayerInfo) {abstract}
+ saveNewTopping(CakeToppingInfo) {abstract}
}
class CakeViewImpl {
- cakeBakingService : CakeBakingService
+ CakeViewImpl(cakeBakingService : CakeBakingService)
+ render()
}
class CakeToppingInfo {
+ calories : int
+ id : Optional<Long>
+ name : String
+ CakeToppingInfo(id : Long, name : String, calories : int)
+ CakeToppingInfo(name : String, calories : int)
+ toString() : String
}
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 App {
- cakeBakingService : CakeBakingService {static}
+ App()
- initializeData(cakeBakingService : CakeBakingService) {static}
+ main(args : String[]) {static}
}
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
}
}
CakeViewImpl --> "-cakeBakingService" CakeBakingService
CakeInfo --> "-cakeToppingInfo" CakeToppingInfo
CakeInfo --> "-cakeLayerInfos" CakeLayerInfo
App --> "-cakeBakingService" CakeBakingService
CakeLayer --> "-cake" Cake
Cake --> "-topping" CakeTopping
CakeBakingServiceImpl ..|> CakeBakingService
CakeViewImpl ..|> View
@enduml

View File

@ -0,0 +1,35 @@
@startuml
package com.iluwatar.lazy.loading {
~class HeavyFactory {
- heavyInstance : Heavy
~ HeavyFactory(this$0 : Java8Holder)
+ get() : Heavy
}
class HolderNaive {
- heavy : Heavy
+ HolderNaive()
+ getHeavy() : Heavy
}
class Heavy {
+ Heavy()
}
class HolderThreadSafe {
- heavy : Heavy
+ HolderThreadSafe()
+ getHeavy() : Heavy
}
class Java8Holder {
- heavy : Supplier<Heavy>
+ Java8Holder()
- createAndCacheHeavy() : Heavy
+ getHeavy() : Heavy
}
class App {
+ App()
+ main(args : String[]) {static}
}
}
HolderThreadSafe --> "-heavy" Heavy
HolderNaive --> "-heavy" Heavy
HeavyFactory --> "-heavyInstance" Heavy
@enduml

View File

@ -0,0 +1,68 @@
@startuml
package com.iluwatar.mediator {
class App {
+ App()
+ main(args : String[]) {static}
}
class Hobbit {
+ Hobbit()
+ toString() : String
}
interface PartyMember {
+ act(Action) {abstract}
+ joinedParty(Party) {abstract}
+ partyAction(Action) {abstract}
}
interface Party {
+ act(PartyMember, Action) {abstract}
+ addMember(PartyMember) {abstract}
}
class Wizard {
+ Wizard()
+ toString() : String
}
class PartyImpl {
- members : List<PartyMember>
+ PartyImpl()
+ act(actor : PartyMember, action : Action)
+ addMember(member : PartyMember)
}
class Hunter {
+ Hunter()
+ toString() : String
}
class Rogue {
+ Rogue()
+ toString() : String
}
abstract class PartyMemberBase {
# party : Party
+ PartyMemberBase()
+ act(action : Action)
+ joinedParty(party : Party)
+ partyAction(action : Action)
+ toString() : String {abstract}
}
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}
}
}
PartyImpl --> "-members" PartyMember
PartyMemberBase --> "-party" Party
Hobbit --|> PartyMemberBase
Wizard --|> PartyMemberBase
PartyImpl ..|> Party
Hunter --|> PartyMemberBase
Rogue --|> PartyMemberBase
PartyMemberBase ..|> PartyMember
@enduml

View File

@ -0,0 +1,48 @@
@startuml
package com.iluwatar.memento {
class Star {
- ageYears : int
- massTons : int
- type : StarType
+ Star(startType : StarType, startAge : int, startMass : int)
~ getMemento() : StarMemento
~ setMemento(memento : StarMemento)
+ timePasses()
+ toString() : String
}
interface StarMemento {
}
-class StarMementoInternal {
- ageYears : int
- massTons : int
- type : StarType
- StarMementoInternal()
+ getAgeYears() : int
+ getMassTons() : int
+ getType() : StarType
+ setAgeYears(ageYears : int)
+ setMassTons(massTons : int)
+ setType(type : StarType)
}
class App {
+ App()
+ main(args : String[]) {static}
}
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

View File

@ -0,0 +1,8 @@
@startuml
package com.iluwatar.message.channel {
class App {
+ App()
+ main(args : String[]) {static}
}
}
@enduml

View File

@ -0,0 +1,69 @@
@startuml
package com.iluwatar.model.view.controller {
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 App {
+ App()
+ main(args : String[]) {static}
}
class GiantView {
+ GiantView()
+ displayGiant(giant : GiantModel)
}
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()
}
enum Nourishment {
+ HUNGRY {static}
+ SATURATED {static}
+ STARVING {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Nourishment {static}
+ values() : Nourishment[] {static}
}
enum Fatigue {
+ ALERT {static}
+ SLEEPING {static}
+ TIRED {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Fatigue {static}
+ values() : Fatigue[] {static}
}
enum Health {
+ DEAD {static}
+ HEALTHY {static}
+ WOUNDED {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Health {static}
+ values() : Health[] {static}
}
}
GiantModel --> "-nourishment" Nourishment
GiantController --> "-giant" GiantModel
GiantModel --> "-fatigue" Fatigue
GiantModel --> "-health" Health
GiantController --> "-view" GiantView
@enduml

View File

@ -0,0 +1,87 @@
@startuml
package com.iluwatar.model.view.presenter {
class FileLoader {
- fileName : String
- loaded : boolean
+ 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 App {
+ App()
+ main(args : String[]) {static}
}
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}
}
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)
}
class FileSelectorPresenter {
- loader : FileLoader
- view : FileSelectorView
+ FileSelectorPresenter(view : FileSelectorView)
+ cancelled()
+ confirmed()
+ fileNameChanged()
+ setLoader(loader : FileLoader)
+ start()
}
}
FileSelectorStub --> "-presenter" FileSelectorPresenter
FileSelectorJFrame --> "-presenter" FileSelectorPresenter
FileSelectorPresenter --> "-loader" FileLoader
FileSelectorPresenter --> "-view" FileSelectorView
FileSelectorJFrame ..|> FileSelectorView
FileSelectorStub ..|> FileSelectorView
@enduml

35
monad/etc/monad.urm.puml Normal file
View File

@ -0,0 +1,35 @@
@startuml
package com.iluwatar.monad {
class Validator<T> {
- exceptions : List<Throwable>
- t : T
- Validator<T>(t : 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>
}
class App {
+ App()
+ main(args : String[]) {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
}
enum Sex {
+ FEMALE {static}
+ MALE {static}
+ valueOf(name : String) : Sex {static}
+ values() : Sex[] {static}
}
}
User --> "-sex" Sex
@enduml

View File

@ -0,0 +1,32 @@
@startuml
package com.iluwatar.monostate {
class LoadBalancer {
- id : int {static}
- lastServedId : int {static}
- servers : List<Server> {static}
+ LoadBalancer()
+ addServer(server : Server)
+ getLastServedId() : int {static}
+ getNoOfServers() : int
+ serverRequest(request : Request)
}
class App {
+ App()
+ main(args : String[]) {static}
}
class Request {
+ value : String
+ Request(value : String)
}
class Server {
+ host : String
+ id : int
+ port : int
+ Server(host : String, port : int, id : int)
+ getHost() : String
+ getPort() : int
+ serve(request : Request)
}
}
LoadBalancer --> "-servers" Server
@enduml

View File

@ -0,0 +1,29 @@
@startuml
package com.iluwatar.multiton {
class App {
+ 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 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

View File

@ -0,0 +1,23 @@
@startuml
package com.iluwatar.mute {
interface Resource {
}
class App {
+ App()
- acquireResource() : Resource {static}
- closeResource(resource : Resource) {static}
+ main(args : String[]) {static}
- useOfLoggedMute() {static}
- useOfMute() {static}
- utilizeResource(resource : Resource) {static}
}
class Mute {
- Mute()
+ loggedMute(runnable : CheckedRunnable) {static}
+ mute(runnable : CheckedRunnable) {static}
}
interface CheckedRunnable {
+ run() {abstract}
}
}
@enduml

27
mutex/etc/mutex.urm.puml Normal file
View File

@ -0,0 +1,27 @@
@startuml
package com.iluwatar.mutex {
interface Lock {
+ acquire() {abstract}
+ release() {abstract}
}
class Mutex {
- owner : Object
+ Mutex()
+ acquire()
+ getOwner() : Object
+ release()
}
class Jar {
- beans : int
- lock : Lock
+ Jar(beans : int, lock : Lock)
+ takeBean() : boolean
}
class App {
+ App()
+ main(args : String[]) {static}
}
}
Jar --> "-lock" Lock
Mutex ..|> Lock
@enduml

View File

@ -0,0 +1,84 @@
@startuml
package domainapp.dom.app.homepage {
class HomePageViewModel {
~ simpleObjects : SimpleObjects
+ HomePageViewModel()
+ getObjects() : List<SimpleObject>
+ title() : String
}
class HomePageService {
~ container : DomainObjectContainer
+ HomePageService()
+ homePage() : HomePageViewModel
}
}
package domainapp.dom.modules.simple {
class SimpleObjects {
~ container : DomainObjectContainer
+ SimpleObjects()
+ create(name : String) : SimpleObject
+ findByName(name : String) : List<SimpleObject>
+ listAll() : List<SimpleObject>
+ title() : TranslatableString
}
class SimpleObject {
- container : DomainObjectContainer
- dnFieldFlags : byte[] {static}
- dnFieldNames : String[] {static}
- dnFieldTypes : Class[] {static}
# dnFlags : byte
- dnInheritedFieldCount : int {static}
- dnPersistableSuperclass : Class<T> {static}
# dnStateManager : StateManager
- name : String
+ SimpleObject()
+ ___dn$loadClass(className : String) : Class<T> {static}
- __dnFieldFlagsInit() : byte[] {static}
- __dnFieldNamesInit() : String[] {static}
- __dnFieldTypesInit() : Class[] {static}
# __dnGetInheritedFieldCount() : int {static}
- __dnPersistableSuperclassInit() : Class<T> {static}
+ compareTo(other : SimpleObject) : int
+ default0UpdateName() : String
# dnCopyField(obj : SimpleObject, index : int)
+ dnCopyFields(obj : Object, indices : int[])
+ dnCopyKeyFieldsFromObjectId(fc : ObjectIdFieldConsumer, oid : Object)
# dnCopyKeyFieldsFromObjectId(oid : Object)
+ dnCopyKeyFieldsToObjectId(fs : ObjectIdFieldSupplier, oid : Object)
+ dnCopyKeyFieldsToObjectId(oid : Object)
+ dnGetExecutionContext() : ExecutionContextReference
# dnGetManagedFieldCount() : int {static}
+ dnGetObjectId() : Object
+ dnGetTransactionalObjectId() : Object
+ dnGetVersion() : Object
+ dnGetname() : String
+ dnIsDeleted() : boolean
+ dnIsDetached() : boolean
+ dnIsDirty() : boolean
+ dnIsNew() : boolean
+ dnIsPersistent() : boolean
+ dnIsTransactional() : boolean
+ dnMakeDirty(fieldName : String)
+ dnNewInstance(sm : StateManager) : Persistable
+ dnNewInstance(sm : StateManager, obj : Object) : Persistable
+ dnNewObjectIdInstance() : Object
+ dnNewObjectIdInstance(key : Object) : Object
# dnPreSerialize()
+ dnProvideField(index : int)
+ dnProvideFields(indices : int[])
+ dnReplaceField(index : int)
+ dnReplaceFields(indices : int[])
+ dnReplaceFlags()
+ dnReplaceStateManager(sm : StateManager)
+ dnSetname(name : String)
- dnSuperClone() : Object
+ getName() : String
+ getVersionSequence() : Long
+ setName(val : String)
+ title() : TranslatableString
+ updateName(name : String) : SimpleObject
+ validateUpdateName(name : String) : TranslatableString
}
}
HomePageViewModel --> "-simpleObjects" SimpleObjects
@enduml

View File

@ -0,0 +1,92 @@
@startuml
package domainapp.dom.app.homepage {
class HomePageViewModel {
~ simpleObjects : SimpleObjects
+ HomePageViewModel()
+ getObjects() : List<SimpleObject>
+ title() : String
}
class HomePageService {
~ container : DomainObjectContainer
+ HomePageService()
+ homePage() : HomePageViewModel
}
}
package domainapp.dom.modules.simple {
class SimpleObject {
- container : DomainObjectContainer
- dnFieldFlags : byte[] {static}
- dnFieldNames : String[] {static}
- dnFieldTypes : Class[] {static}
# dnFlags : byte
- dnInheritedFieldCount : int {static}
- dnPersistableSuperclass : Class<T> {static}
# dnStateManager : StateManager
- name : String
+ SimpleObject()
+ ___dn$loadClass(className : String) : Class<T> {static}
- __dnFieldFlagsInit() : byte[] {static}
- __dnFieldNamesInit() : String[] {static}
- __dnFieldTypesInit() : Class[] {static}
# __dnGetInheritedFieldCount() : int {static}
- __dnPersistableSuperclassInit() : Class<T> {static}
+ compareTo(other : SimpleObject) : int
+ default0UpdateName() : String
# dnCopyField(obj : SimpleObject, index : int)
+ dnCopyFields(obj : Object, indices : int[])
+ dnCopyKeyFieldsFromObjectId(fc : ObjectIdFieldConsumer, oid : Object)
# dnCopyKeyFieldsFromObjectId(oid : Object)
+ dnCopyKeyFieldsToObjectId(fs : ObjectIdFieldSupplier, oid : Object)
+ dnCopyKeyFieldsToObjectId(oid : Object)
+ dnGetExecutionContext() : ExecutionContextReference
# dnGetManagedFieldCount() : int {static}
+ dnGetObjectId() : Object
+ dnGetTransactionalObjectId() : Object
+ dnGetVersion() : Object
+ dnGetname() : String
+ dnIsDeleted() : boolean
+ dnIsDetached() : boolean
+ dnIsDirty() : boolean
+ dnIsNew() : boolean
+ dnIsPersistent() : boolean
+ dnIsTransactional() : boolean
+ dnMakeDirty(fieldName : String)
+ dnNewInstance(sm : StateManager) : Persistable
+ dnNewInstance(sm : StateManager, obj : Object) : Persistable
+ dnNewObjectIdInstance() : Object
+ dnNewObjectIdInstance(key : Object) : Object
# dnPreSerialize()
+ dnProvideField(index : int)
+ dnProvideFields(indices : int[])
+ dnReplaceField(index : int)
+ dnReplaceFields(indices : int[])
+ dnReplaceFlags()
+ dnReplaceStateManager(sm : StateManager)
+ dnSetname(name : String)
- dnSuperClone() : Object
+ getName() : String
+ getVersionSequence() : Long
+ setName(val : String)
+ title() : TranslatableString
+ updateName(name : String) : SimpleObject
+ validateUpdateName(name : String) : TranslatableString
}
class SimpleObjects {
~ container : DomainObjectContainer
+ SimpleObjects()
+ create(name : String) : SimpleObject
+ findByName(name : String) : List<SimpleObject>
+ listAll() : List<SimpleObject>
+ title() : TranslatableString
}
}
package domainapp.fixture {
class DomainAppFixturesProvider {
+ DomainAppFixturesProvider()
+ getSpecification() : FixtureScriptsSpecification
}
}
DomainAppFixturesProvider --+ FixtureScripts
DomainAppFixturesProvider --+ FixtureScriptsSpecification
HomePageViewModel --> "-simpleObjects" SimpleObjects
@enduml

View File

@ -0,0 +1,92 @@
@startuml
package domainapp.dom.app.homepage {
class HomePageService {
~ container : DomainObjectContainer
+ HomePageService()
+ homePage() : HomePageViewModel
}
class HomePageViewModel {
~ simpleObjects : SimpleObjects
+ HomePageViewModel()
+ getObjects() : List<SimpleObject>
+ title() : String
}
}
package domainapp.dom.modules.simple {
class SimpleObjects {
~ container : DomainObjectContainer
+ SimpleObjects()
+ create(name : String) : SimpleObject
+ findByName(name : String) : List<SimpleObject>
+ listAll() : List<SimpleObject>
+ title() : TranslatableString
}
class SimpleObject {
- container : DomainObjectContainer
- dnFieldFlags : byte[] {static}
- dnFieldNames : String[] {static}
- dnFieldTypes : Class[] {static}
# dnFlags : byte
- dnInheritedFieldCount : int {static}
- dnPersistableSuperclass : Class<T> {static}
# dnStateManager : StateManager
- name : String
+ SimpleObject()
+ ___dn$loadClass(className : String) : Class<T> {static}
- __dnFieldFlagsInit() : byte[] {static}
- __dnFieldNamesInit() : String[] {static}
- __dnFieldTypesInit() : Class[] {static}
# __dnGetInheritedFieldCount() : int {static}
- __dnPersistableSuperclassInit() : Class<T> {static}
+ compareTo(other : SimpleObject) : int
+ default0UpdateName() : String
# dnCopyField(obj : SimpleObject, index : int)
+ dnCopyFields(obj : Object, indices : int[])
+ dnCopyKeyFieldsFromObjectId(fc : ObjectIdFieldConsumer, oid : Object)
# dnCopyKeyFieldsFromObjectId(oid : Object)
+ dnCopyKeyFieldsToObjectId(fs : ObjectIdFieldSupplier, oid : Object)
+ dnCopyKeyFieldsToObjectId(oid : Object)
+ dnGetExecutionContext() : ExecutionContextReference
# dnGetManagedFieldCount() : int {static}
+ dnGetObjectId() : Object
+ dnGetTransactionalObjectId() : Object
+ dnGetVersion() : Object
+ dnGetname() : String
+ dnIsDeleted() : boolean
+ dnIsDetached() : boolean
+ dnIsDirty() : boolean
+ dnIsNew() : boolean
+ dnIsPersistent() : boolean
+ dnIsTransactional() : boolean
+ dnMakeDirty(fieldName : String)
+ dnNewInstance(sm : StateManager) : Persistable
+ dnNewInstance(sm : StateManager, obj : Object) : Persistable
+ dnNewObjectIdInstance() : Object
+ dnNewObjectIdInstance(key : Object) : Object
# dnPreSerialize()
+ dnProvideField(index : int)
+ dnProvideFields(indices : int[])
+ dnReplaceField(index : int)
+ dnReplaceFields(indices : int[])
+ dnReplaceFlags()
+ dnReplaceStateManager(sm : StateManager)
+ dnSetname(name : String)
- dnSuperClone() : Object
+ getName() : String
+ getVersionSequence() : Long
+ setName(val : String)
+ title() : TranslatableString
+ updateName(name : String) : SimpleObject
+ validateUpdateName(name : String) : TranslatableString
}
}
package domainapp.fixture {
class DomainAppFixturesProvider {
+ DomainAppFixturesProvider()
+ getSpecification() : FixtureScriptsSpecification
}
}
DomainAppFixturesProvider --+ FixtureScripts
DomainAppFixturesProvider --+ FixtureScriptsSpecification
HomePageViewModel --> "-simpleObjects" SimpleObjects
@enduml

View File

@ -0,0 +1,40 @@
@startuml
package com.iluwatar.nullobject {
class NullNode {
- instance : NullNode {static}
- NullNode()
+ getInstance() : NullNode {static}
+ getLeft() : Node
+ getName() : String
+ getRight() : Node
+ getTreeSize() : int
+ walk()
}
interface Node {
+ getLeft() : Node {abstract}
+ getName() : String {abstract}
+ getRight() : Node {abstract}
+ getTreeSize() : int {abstract}
+ walk() {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
class NodeImpl {
- left : Node
- name : String
- right : Node
+ NodeImpl(name : String, left : Node, right : Node)
+ getLeft() : Node
+ getName() : String
+ getRight() : Node
+ getTreeSize() : int
+ walk()
}
}
NullNode --> "-instance" NullNode
NodeImpl --> "-left" Node
NullNode ..|> Node
NodeImpl ..|> Node
@enduml

View File

@ -0,0 +1,29 @@
@startuml
package com.iluwatar.object.pool {
class Oliphaunt {
- counter : int {static}
- id : int
+ Oliphaunt()
+ getId() : int
+ toString() : String
}
class OliphauntPool {
+ OliphauntPool()
# create() : Oliphaunt
}
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class ObjectPool<T> {
- available : HashSet<T>
- inUse : HashSet<T>
+ ObjectPool<T>()
+ checkIn(instance : T)
+ checkOut() : T
# create() : T {abstract}
+ toString() : String
}
}
OliphauntPool --|> ObjectPool
@enduml

View File

@ -0,0 +1,73 @@
@startuml
package com.iluwatar.observer {
class Orcs {
+ Orcs()
+ update(currentWeather : WeatherType)
}
class Hobbits {
+ Hobbits()
+ update(currentWeather : WeatherType)
}
class Weather {
- currentWeather : WeatherType
- observers : List<WeatherObserver>
+ Weather()
+ addObserver(obs : WeatherObserver)
- notifyObservers()
+ removeObserver(obs : WeatherObserver)
+ timePasses()
}
class App {
+ App()
+ main(args : String[]) {static}
}
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 GOrcs {
+ GOrcs()
+ update(weather : GWeather, weatherType : WeatherType)
}
interface Race {
}
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>)
}
class GWeather {
- currentWeather : WeatherType
+ GWeather()
+ timePasses()
}
interface Observer<S extends Observable<S, O, A>, O extends Observer, A> {
+ update(S extends Observable<S, O, A>, A) {abstract}
}
class GHobbits {
+ GHobbits()
+ update(weather : GWeather, weatherType : WeatherType)
}
}
Weather --> "-currentWeather" WeatherType
GWeather --> "-currentWeather" WeatherType
Weather --> "-observers" WeatherObserver
GOrcs ..|> Race
Orcs ..|> WeatherObserver
Hobbits ..|> WeatherObserver
Race --|> Observer
GWeather --|> Observable
GHobbits ..|> Race
@enduml

View File

@ -0,0 +1,8 @@
@startuml
package com.iluwatar.pageobject {
class App {
- App()
+ main(args : String[]) {static}
}
}
@enduml

View File

@ -0,0 +1,72 @@
@startuml
package com.iluwatar.poison.pill {
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}
}
class App {
+ App()
+ main(args : String[]) {static}
}
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
}
class Producer {
- isStopped : boolean
- name : String
- queue : MqPublishPoint
+ Producer(name : String, queue : MqPublishPoint)
+ send(body : String)
+ stop()
}
interface MqSubscribePoint {
+ take() : Message {abstract}
}
class Consumer {
- name : String
- queue : MqSubscribePoint
+ Consumer(name : String, queue : MqSubscribePoint)
+ consume()
}
interface MessageQueue {
}
interface MqPublishPoint {
+ put(Message) {abstract}
}
enum Headers {
+ DATE {static}
+ SENDER {static}
+ valueOf(name : String) : Headers {static}
+ values() : Headers[] {static}
}
}
SimpleMessageQueue --> "-queue" Message
Headers ..+ Message
Consumer --> "-queue" MqSubscribePoint
Producer --> "-queue" MqPublishPoint
SimpleMessage --+ Message
Producer --+ Message
Message --> "-POISON_PILL" Message
Consumer --+ Message
SimpleMessage ..|> Message
SimpleMessageQueue ..|> MessageQueue
MessageQueue --|> MqPublishPoint
MessageQueue --|> MqSubscribePoint
@enduml

View File

@ -0,0 +1,34 @@
@startuml
package com.iluwatar.privateclassdata {
class Stew {
- numCarrots : int
- numMeat : int
- numPeppers : int
- numPotatoes : int
+ Stew(numPotatoes : int, numCarrots : int, numMeat : int, numPeppers : int)
+ mix()
+ taste()
}
class App {
+ App()
+ main(args : String[]) {static}
}
class StewData {
- numCarrots : int
- numMeat : int
- numPeppers : int
- numPotatoes : int
+ StewData(numPotatoes : int, numCarrots : int, numMeat : int, numPeppers : int)
+ getNumCarrots() : int
+ getNumMeat() : int
+ getNumPeppers() : int
+ getNumPotatoes() : int
}
class ImmutableStew {
- data : StewData
+ ImmutableStew(numPotatoes : int, numCarrots : int, numMeat : int, numPeppers : int)
+ mix()
}
}
ImmutableStew --> "-data" StewData
@enduml

View File

@ -0,0 +1,37 @@
@startuml
package com.iluwatar.producer.consumer {
class Producer {
- itemId : int
- name : String
- queue : ItemQueue
+ Producer(name : String, queue : ItemQueue)
+ produce()
}
class ItemQueue {
- queue : BlockingQueue<Item>
+ ItemQueue()
+ put(item : Item)
+ take() : Item
}
class Item {
- id : int
- producer : String
+ Item(producer : String, id : int)
+ getId() : int
+ getProducer() : String
}
class App {
+ App()
+ main(args : String[]) {static}
}
class Consumer {
- name : String
- queue : ItemQueue
+ Consumer(name : String, queue : ItemQueue)
+ consume()
}
}
Consumer --> "-queue" ItemQueue
Producer --> "-queue" ItemQueue
ItemQueue --> "-queue" Item
@enduml

View File

@ -0,0 +1,54 @@
@startuml
package com.iluwatar.property {
class Character {
- name : String
- properties : Map<Stats, Integer>
- prototype : Prototype
- type : Type
+ Character()
+ Character(name : String, prototype : Character)
+ Character(type : Type, prototype : Prototype)
+ get(stat : Stats) : Integer
+ has(stat : Stats) : boolean
+ name() : String
+ remove(stat : Stats)
+ set(stat : Stats, val : Integer)
+ toString() : String
+ type() : Type
}
interface Prototype {
+ get(Stats) : Integer {abstract}
+ has(Stats) : boolean {abstract}
+ remove(Stats) {abstract}
+ set(Stats, Integer) {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
enum Stats {
+ AGILITY {static}
+ ARMOR {static}
+ ATTACK_POWER {static}
+ ENERGY {static}
+ INTELLECT {static}
+ RAGE {static}
+ SPIRIT {static}
+ STRENGTH {static}
+ valueOf(name : String) : Stats {static}
+ values() : Stats[] {static}
}
enum Type {
+ MAGE {static}
+ ROGUE {static}
+ WARRIOR {static}
+ valueOf(name : String) : Type {static}
+ values() : Type[] {static}
}
}
App --+ Character
Character --> "-prototype" Prototype
Character --> "-type" Type
Type ..+ Character
Character ..|> Prototype
@enduml

View File

@ -0,0 +1,81 @@
@startuml
package com.iluwatar.prototype {
interface HeroFactory {
+ createBeast() : Beast {abstract}
+ createMage() : Mage {abstract}
+ createWarlord() : Warlord {abstract}
}
class OrcBeast {
+ OrcBeast()
+ clone() : Beast
+ toString() : String
}
abstract class Mage {
+ Mage()
+ clone() : Mage {abstract}
}
class HeroFactoryImpl {
- beast : Beast
- mage : Mage
- warlord : Warlord
+ HeroFactoryImpl(mage : Mage, warlord : Warlord, beast : Beast)
+ createBeast() : Beast
+ createMage() : Mage
+ createWarlord() : Warlord
}
class ElfMage {
+ ElfMage()
+ clone() : Mage
+ toString() : String
}
abstract class Prototype {
+ Prototype()
+ clone() : Object {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class Warlord {
+ Warlord()
+ clone() : Warlord {abstract}
}
class OrcWarlord {
+ OrcWarlord()
+ clone() : Warlord
+ toString() : String
}
class ElfWarlord {
+ ElfWarlord()
+ clone() : Warlord
+ toString() : String
}
abstract class Beast {
+ Beast()
+ clone() : Beast {abstract}
}
class OrcMage {
+ OrcMage()
+ clone() : Mage
+ toString() : String
}
class ElfBeast {
+ ElfBeast()
+ clone() : Beast
+ toString() : String
}
}
HeroFactoryImpl --> "-beast" Beast
HeroFactoryImpl --> "-warlord" Warlord
HeroFactoryImpl --> "-mage" Mage
OrcBeast --|> Beast
Mage --|> Prototype
HeroFactoryImpl ..|> HeroFactory
ElfMage --|> Mage
Warlord --|> Prototype
OrcWarlord --|> Warlord
ElfWarlord --|> Warlord
Beast --|> Prototype
OrcMage --|> Mage
ElfBeast --|> Beast
@enduml

24
proxy/etc/proxy.urm.puml Normal file
View File

@ -0,0 +1,24 @@
@startuml
package com.iluwatar.proxy {
class WizardTower {
+ WizardTower()
+ enter(wizard : Wizard)
}
class App {
+ App()
+ main(args : String[]) {static}
}
class WizardTowerProxy {
- NUM_WIZARDS_ALLOWED : int {static}
- numWizards : int
+ WizardTowerProxy()
+ enter(wizard : Wizard)
}
class Wizard {
- name : String
+ Wizard(name : String)
+ toString() : String
}
}
WizardTowerProxy --|> WizardTower
@enduml

View File

@ -0,0 +1,8 @@
@startuml
package com.iluwatar.publish.subscribe {
class App {
+ App()
+ main(args : String[]) {static}
}
}
@enduml

View File

@ -0,0 +1,151 @@
@startuml
package com.iluwatar.reactor.app {
~class TcpLoggingClient {
- clientName : String
- serverPort : int
+ TcpLoggingClient(clientName : String, serverPort : int)
+ run()
- sendLogRequests(writer : PrintWriter, inputStream : InputStream)
}
~class UdpLoggingClient {
- clientName : String
- remoteAddress : InetSocketAddress
+ UdpLoggingClient(clientName : String, port : int)
+ run()
}
class LoggingHandler {
- ACK : byte[] {static}
+ LoggingHandler()
- doLogging(data : ByteBuffer) {static}
+ handleChannelRead(channel : AbstractNioChannel, readObject : Object, key : SelectionKey)
- sendReply(channel : AbstractNioChannel, incomingPacket : DatagramPacket, key : SelectionKey) {static}
- sendReply(channel : AbstractNioChannel, key : SelectionKey) {static}
}
class AppClient {
- service : ExecutorService
+ AppClient()
- artificialDelayOf(millis : long) {static}
+ main(args : String[]) {static}
+ start()
+ stop()
}
class App {
- channels : List<AbstractNioChannel>
- dispatcher : Dispatcher
- reactor : NioReactor
+ App(dispatcher : Dispatcher)
+ main(args : String[]) {static}
+ start()
+ stop()
- tcpChannel(port : int, handler : ChannelHandler) : AbstractNioChannel
- udpChannel(port : int, handler : ChannelHandler) : AbstractNioChannel
}
}
package com.iluwatar.reactor.framework {
interface Dispatcher {
+ onChannelReadEvent(AbstractNioChannel, Object, SelectionKey) {abstract}
+ stop() {abstract}
}
class SameThreadDispatcher {
+ SameThreadDispatcher()
+ onChannelReadEvent(channel : AbstractNioChannel, readObject : Object, key : SelectionKey)
+ stop()
}
class ThreadPoolDispatcher {
- executorService : ExecutorService
+ ThreadPoolDispatcher(poolSize : int)
+ onChannelReadEvent(channel : AbstractNioChannel, readObject : Object, key : SelectionKey)
+ stop()
}
interface ChannelHandler {
+ handleChannelRead(AbstractNioChannel, Object, SelectionKey) {abstract}
}
class NioDatagramChannel {
- port : int
+ NioDatagramChannel(port : int, handler : ChannelHandler)
+ bind()
# doWrite(pendingWrite : Object, key : SelectionKey)
+ getInterestedOps() : int
+ getJavaChannel() : DatagramChannel
+ read(key : SelectionKey) : DatagramPacket
+ write(data : Object, key : SelectionKey)
}
class DatagramPacket {
- data : ByteBuffer
- receiver : SocketAddress
- sender : SocketAddress
+ DatagramPacket(data : ByteBuffer)
+ getData() : ByteBuffer
+ getReceiver() : SocketAddress
+ getSender() : SocketAddress
+ setReceiver(receiver : SocketAddress)
+ setSender(sender : SocketAddress)
}
abstract class AbstractNioChannel {
- channel : SelectableChannel
- channelToPendingWrites : Map<SelectableChannel, Queue<Object>>
- handler : ChannelHandler
- reactor : NioReactor
+ AbstractNioChannel(handler : ChannelHandler, channel : SelectableChannel)
+ bind() {abstract}
# doWrite(Object, SelectionKey) {abstract}
~ flush(key : SelectionKey)
+ getHandler() : ChannelHandler
+ getInterestedOps() : int {abstract}
+ getJavaChannel() : SelectableChannel
+ read(SelectionKey) : Object {abstract}
~ setReactor(reactor : NioReactor)
+ write(data : Object, key : SelectionKey)
}
class NioServerSocketChannel {
- port : int
+ NioServerSocketChannel(port : int, handler : ChannelHandler)
+ bind()
# doWrite(pendingWrite : Object, key : SelectionKey)
+ getInterestedOps() : int
+ getJavaChannel() : ServerSocketChannel
+ read(key : SelectionKey) : ByteBuffer
}
class NioReactor {
- dispatcher : Dispatcher
- pendingCommands : Queue<Runnable>
- reactorMain : ExecutorService
- selector : Selector
+ NioReactor(dispatcher : Dispatcher)
+ changeOps(key : SelectionKey, interestedOps : int)
- dispatchReadEvent(key : SelectionKey, readObject : Object)
- eventLoop()
- onChannelAcceptable(key : SelectionKey)
- onChannelReadable(key : SelectionKey)
- onChannelWritable(key : SelectionKey) {static}
- processKey(key : SelectionKey)
- processPendingCommands()
+ registerChannel(channel : AbstractNioChannel) : NioReactor
+ start()
+ stop()
}
~class ChangeKeyOpsCommand {
- interestedOps : int
- key : SelectionKey
+ ChangeKeyOpsCommand(this$0 : NioReactor, key : SelectionKey, interestedOps : int)
+ run()
+ toString() : String
}
}
AbstractNioChannel --> "-handler" ChannelHandler
UdpLoggingClient ..+ AppClient
AbstractNioChannel --> "-reactor" NioReactor
TcpLoggingClient ..+ AppClient
NioReactor --> "-dispatcher" Dispatcher
App --> "-reactor" NioReactor
App --> "-channels" AbstractNioChannel
DatagramPacket ..+ NioDatagramChannel
ChangeKeyOpsCommand --+ NioReactor
App --> "-dispatcher" Dispatcher
LoggingHandler --+ NioDatagramChannel
SameThreadDispatcher ..|> Dispatcher
LoggingHandler ..|> ChannelHandler
ThreadPoolDispatcher ..|> Dispatcher
NioDatagramChannel --|> AbstractNioChannel
NioServerSocketChannel --|> AbstractNioChannel
@enduml

View File

@ -0,0 +1,58 @@
@startuml
package com.iluwatar.reader.writer.lock {
-class ReadLock {
- ReadLock(ReaderWriterLock)
+ lock()
+ lockInterruptibly()
+ newCondition() : Condition
+ tryLock() : boolean
+ tryLock(time : long, unit : TimeUnit) : boolean
+ unlock()
}
class Writer {
- name : String
- writeLock : Lock
+ Writer(name : String, writeLock : Lock)
+ run()
+ write()
}
class ReaderWriterLock {
- currentReaderCount : int
- globalMutex : Set<Object>
- readerLock : ReadLock
- readerMutex : Object
- writerLock : WriteLock
+ ReaderWriterLock()
- doesReaderOwnThisLock() : boolean
- doesWriterOwnThisLock() : boolean
- isLockFree() : boolean
+ readLock() : Lock
- waitUninterruptibly(o : Object) {static}
+ writeLock() : Lock
}
-class WriteLock {
- WriteLock(ReaderWriterLock)
+ lock()
+ lockInterruptibly()
+ newCondition() : Condition
+ tryLock() : boolean
+ tryLock(time : long, unit : TimeUnit) : boolean
+ unlock()
}
class App {
+ App()
+ main(args : String[]) {static}
}
class Reader {
- name : String
- readLock : Lock
+ Reader(name : String, readLock : Lock)
+ read()
+ run()
}
}
ReadLock --+ ReaderWriterLock
ReaderWriterLock --> "-readerLock" ReadLock
ReaderWriterLock --> "-writerLock" WriteLock
WriteLock --+ ReaderWriterLock
@enduml

View File

@ -0,0 +1,56 @@
@startuml
package com.iluwatar.repository {
class App {
+ App()
+ main(args : String[]) {static}
}
class Person {
- age : int
- id : Long
- name : String
- surname : String
+ Person()
+ Person(name : String, surname : String, age : int)
+ equals(obj : Object) : boolean
+ getAge() : int
+ getId() : Long
+ getName() : String
+ getSurname() : String
+ hashCode() : int
+ setAge(age : int)
+ setId(id : Long)
+ setName(name : String)
+ setSurname(surname : String)
+ toString() : String
}
class AgeBetweenSpec {
- from : int
- to : int
+ AgeBetweenSpec(from : int, to : int)
+ toPredicate(root : Root<Person>, query : CriteriaQuery<?>, cb : CriteriaBuilder) : Predicate
}
class AppConfig {
+ AppConfig()
+ dataSource() : DataSource
+ entityManagerFactory() : LocalContainerEntityManagerFactoryBean
- jpaProperties() : Properties {static}
+ main(args : String[]) {static}
+ transactionManager() : JpaTransactionManager
}
interface PersonRepository {
+ findByName(String) : Person {abstract}
}
class NameEqualSpec {
+ name : String
+ NameEqualSpec(name : String)
+ toPredicate(root : Root<Person>, query : CriteriaQuery<?>, cb : CriteriaBuilder) : Predicate
}
class PersonSpecifications {
+ PersonSpecifications()
}
}
App --+ PersonSpecifications
AppConfig --+ PersonSpecifications
NameEqualSpec ..+ PersonSpecifications
AgeBetweenSpec ..+ PersonSpecifications
@enduml

View File

@ -0,0 +1,16 @@
@startuml
package com.iluwatar.resource.acquisition.is.initialization {
class App {
+ App()
+ main(args : String[]) {static}
}
class TreasureChest {
+ TreasureChest()
+ close()
}
class SlidingDoor {
+ SlidingDoor()
+ close()
}
}
@enduml

View File

@ -0,0 +1,58 @@
@startuml
package com.iluwatar.semaphore {
class FruitShop {
- available : boolean[]
- bowls : FruitBowl[]
- semaphore : Semaphore
+ FruitShop()
+ countFruit() : int
+ returnBowl(bowl : FruitBowl)
+ takeBowl() : FruitBowl
}
class FruitBowl {
- fruit : ArrayList<Fruit>
+ FruitBowl()
+ countFruit() : int
+ put(f : Fruit)
+ take() : Fruit
+ toString() : String
}
class Fruit {
- type : FruitType
+ Fruit(type : FruitType)
+ getType() : FruitType
+ toString() : String
}
interface Lock {
+ acquire() {abstract}
+ release() {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
class Semaphore {
- counter : int
- licenses : int
+ Semaphore(licenses : int)
+ acquire()
+ getAvailableLicenses() : int
+ getNumLicenses() : int
+ release()
}
enum FruitType {
+ APPLE {static}
+ LEMON {static}
+ ORANGE {static}
+ valueOf(name : String) : FruitType {static}
+ values() : FruitType[] {static}
}
}
FruitShop --+ Fruit
Fruit --> "-type" FruitType
FruitType ..+ Fruit
FruitBowl --+ Fruit
FruitBowl --> "-fruit" Fruit
FruitShop --> "-semaphore" Semaphore
Semaphore ..|> Lock
@enduml

View File

@ -0,0 +1,55 @@
@startuml
package com.iluwatar.servant {
class King {
- complimentReceived : boolean
- isDrunk : boolean
- isHappy : boolean
- isHungry : boolean
+ King()
+ changeMood()
+ getDrink()
+ getFed()
+ getMood() : boolean
+ receiveCompliments()
}
~interface Royalty {
+ changeMood() {abstract}
+ getDrink() {abstract}
+ getFed() {abstract}
+ getMood() : boolean {abstract}
+ receiveCompliments() {abstract}
}
class Servant {
+ name : String
+ Servant(name : String)
+ checkIfYouWillBeHanged(tableGuests : List<Royalty>) : boolean
+ feed(r : Royalty)
+ giveCompliments(r : Royalty)
+ giveWine(r : Royalty)
}
class Queen {
- complimentReceived : boolean
- isDrunk : boolean
- isFlirty : boolean
- isHappy : boolean
- isHungry : boolean
+ Queen()
+ changeMood()
+ getDrink()
+ getFed()
+ getMood() : boolean
+ receiveCompliments()
+ setFlirtiness(f : boolean)
}
class App {
~ jenkins : Servant {static}
~ travis : Servant {static}
+ App()
+ main(args : String[]) {static}
+ scenario(servant : Servant, compliment : int) {static}
}
}
App --> "-jenkins" Servant
King ..|> Royalty
Queen ..|> Royalty
@enduml

View File

@ -0,0 +1,158 @@
@startuml
package com.iluwatar.servicelayer.hibernate {
class HibernateUtil {
- sessionFactory : SessionFactory {static}
- HibernateUtil()
+ dropSession() {static}
+ getSessionFactory() : SessionFactory {static}
}
}
package com.iluwatar.servicelayer.common {
abstract class BaseEntity {
- version : Long
+ BaseEntity()
+ getId() : Long {abstract}
+ getName() : String {abstract}
+ setId(Long) {abstract}
+ setName(String) {abstract}
}
interface Dao<E extends BaseEntity> {
+ delete(E extends BaseEntity) {abstract}
+ find(Long) : E extends BaseEntity {abstract}
+ findAll() : List<E extends BaseEntity> {abstract}
+ merge(E extends BaseEntity) : E extends BaseEntity {abstract}
+ persist(E extends BaseEntity) {abstract}
}
abstract class DaoBaseImpl<E extends BaseEntity> {
# persistentClass : Class<E extends BaseEntity>
+ DaoBaseImpl<E extends BaseEntity>()
+ delete(entity : E extends BaseEntity)
+ find(id : Long) : E extends BaseEntity
+ findAll() : List<E extends BaseEntity>
# getSession() : Session
+ merge(entity : E extends BaseEntity) : E extends BaseEntity
+ persist(entity : E extends BaseEntity)
}
}
package com.iluwatar.servicelayer.magic {
interface MagicService {
+ findAllSpellbooks() : List<Spellbook> {abstract}
+ findAllSpells() : List<Spell> {abstract}
+ findAllWizards() : List<Wizard> {abstract}
+ findWizardsWithSpell(String) : List<Wizard> {abstract}
+ findWizardsWithSpellbook(String) : List<Wizard> {abstract}
}
class MagicServiceImpl {
- spellDao : SpellDao
- spellbookDao : SpellbookDao
- wizardDao : WizardDao
+ MagicServiceImpl(wizardDao : WizardDao, spellbookDao : SpellbookDao, spellDao : SpellDao)
+ findAllSpellbooks() : List<Spellbook>
+ findAllSpells() : List<Spell>
+ findAllWizards() : List<Wizard>
+ findWizardsWithSpell(name : String) : List<Wizard>
+ findWizardsWithSpellbook(name : String) : List<Wizard>
}
}
package com.iluwatar.servicelayer.wizard {
class Wizard {
- id : Long
- name : String
- spellbooks : Set<Spellbook>
+ Wizard()
+ Wizard(name : String)
+ addSpellbook(spellbook : Spellbook)
+ getId() : Long
+ getName() : String
+ getSpellbooks() : Set<Spellbook>
+ setId(id : Long)
+ setName(name : String)
+ setSpellbooks(spellbooks : Set<Spellbook>)
+ toString() : String
}
class WizardDaoImpl {
+ WizardDaoImpl()
+ findByName(name : String) : Wizard
}
interface WizardDao {
+ findByName(String) : Wizard {abstract}
}
}
package com.iluwatar.servicelayer.app {
class App {
+ App()
+ initData() {static}
+ main(args : String[]) {static}
+ queryData() {static}
}
}
package com.iluwatar.servicelayer.spell {
class SpellDaoImpl {
+ SpellDaoImpl()
+ findByName(name : String) : Spell
}
class Spell {
- id : Long
- name : String
- spellbook : Spellbook
+ Spell()
+ Spell(name : String)
+ getId() : Long
+ getName() : String
+ getSpellbook() : Spellbook
+ setId(id : Long)
+ setName(name : String)
+ setSpellbook(spellbook : Spellbook)
+ toString() : String
}
interface SpellDao {
+ findByName(String) : Spell {abstract}
}
}
package com.iluwatar.servicelayer.spellbook {
interface SpellbookDao {
+ findByName(String) : Spellbook {abstract}
}
class Spellbook {
- id : Long
- name : String
- spells : Set<Spell>
- wizards : Set<Wizard>
+ Spellbook()
+ Spellbook(name : String)
+ addSpell(spell : Spell)
+ getId() : Long
+ getName() : String
+ getSpells() : Set<Spell>
+ getWizards() : Set<Wizard>
+ setId(id : Long)
+ setName(name : String)
+ setSpells(spells : Set<Spell>)
+ setWizards(wizards : Set<Wizard>)
+ toString() : String
}
class SpellbookDaoImpl {
+ SpellbookDaoImpl()
+ findByName(name : String) : Spellbook
}
}
MagicServiceImpl --> "-wizardDao" WizardDao
MagicServiceImpl --> "-spellbookDao" SpellbookDao
MagicServiceImpl --> "-spellDao" SpellDao
Spellbook --> "-spells" Spell
Spellbook --> "-wizards" Wizard
Wizard --|> BaseEntity
SpellbookDao --|> Dao
SpellDaoImpl ..|> SpellDao
SpellDaoImpl --|> DaoBaseImpl
MagicServiceImpl ..|> MagicService
DaoBaseImpl ..|> Dao
WizardDaoImpl ..|> WizardDao
WizardDaoImpl --|> DaoBaseImpl
Spellbook --|> BaseEntity
SpellbookDaoImpl ..|> SpellbookDao
SpellbookDaoImpl --|> DaoBaseImpl
Spell --|> BaseEntity
WizardDao --|> Dao
SpellDao --|> Dao
@enduml

View File

@ -0,0 +1,38 @@
@startuml
package com.iluwatar.servicelocator {
interface Service {
+ execute() {abstract}
+ getId() : int {abstract}
+ getName() : String {abstract}
}
class InitContext {
+ InitContext()
+ lookup(serviceName : String) : Object
}
class ServiceLocator {
- serviceCache : ServiceCache {static}
- ServiceLocator()
+ getService(serviceJndiName : String) : Service {static}
}
class ServiceCache {
- serviceCache : Map<String, Service>
+ ServiceCache()
+ addService(newService : Service)
+ getService(serviceName : String) : Service
}
class App {
+ App()
+ main(args : String[]) {static}
}
class ServiceImpl {
- id : int
- serviceName : String
+ ServiceImpl(serviceName : String)
+ execute()
+ getId() : int
+ getName() : String
}
}
ServiceLocator --> "-serviceCache" ServiceCache
ServiceImpl ..|> Service
@enduml

View File

@ -0,0 +1,42 @@
@startuml
package com.iluwatar.singleton {
class ThreadSafeLazyLoadedIvoryTower {
- instance : ThreadSafeLazyLoadedIvoryTower {static}
- ThreadSafeLazyLoadedIvoryTower()
+ getInstance() : ThreadSafeLazyLoadedIvoryTower {static}
}
-class HelperHolder {
+ INSTANCE : InitializingOnDemandHolderIdiom {static}
- HelperHolder()
}
class App {
+ App()
+ main(args : String[]) {static}
}
class ThreadSafeDoubleCheckLocking {
- instance : ThreadSafeDoubleCheckLocking {static}
- ThreadSafeDoubleCheckLocking()
+ getInstance() : ThreadSafeDoubleCheckLocking {static}
}
class InitializingOnDemandHolderIdiom {
- InitializingOnDemandHolderIdiom()
+ getInstance() : InitializingOnDemandHolderIdiom {static}
}
class IvoryTower {
- INSTANCE : IvoryTower {static}
- IvoryTower()
+ getInstance() : IvoryTower {static}
}
enum EnumIvoryTower {
+ INSTANCE {static}
+ toString() : String
+ valueOf(name : String) : EnumIvoryTower {static}
+ values() : EnumIvoryTower[] {static}
}
}
IvoryTower --> "-INSTANCE" IvoryTower
ThreadSafeDoubleCheckLocking --> "-instance" ThreadSafeDoubleCheckLocking
ThreadSafeLazyLoadedIvoryTower --> "-instance" ThreadSafeLazyLoadedIvoryTower
HelperHolder ..+ InitializingOnDemandHolderIdiom
HelperHolder --> "-INSTANCE" InitializingOnDemandHolderIdiom
@enduml

View File

@ -0,0 +1,106 @@
@startuml
package com.iluwatar.specification.creature {
class Goblin {
+ Goblin()
}
interface Creature {
+ getColor() : Color {abstract}
+ getMovement() : Movement {abstract}
+ getName() : String {abstract}
+ getSize() : Size {abstract}
}
class Troll {
+ Troll()
}
abstract class AbstractCreature {
- color : Color
- movement : Movement
- name : String
- size : Size
+ AbstractCreature(name : String, size : Size, movement : Movement, color : Color)
+ getColor() : Color
+ getMovement() : Movement
+ getName() : String
+ getSize() : Size
+ toString() : String
}
class Shark {
+ Shark()
}
class KillerBee {
+ KillerBee()
}
class Octopus {
+ Octopus()
}
class Dragon {
+ Dragon()
}
}
package com.iluwatar.specification.property {
enum Color {
+ DARK {static}
+ GREEN {static}
+ LIGHT {static}
+ RED {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Color {static}
+ values() : Color[] {static}
}
enum Movement {
+ FLYING {static}
+ SWIMMING {static}
+ WALKING {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Movement {static}
+ values() : Movement[] {static}
}
enum Size {
+ LARGE {static}
+ NORMAL {static}
+ SMALL {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Size {static}
+ values() : Size[] {static}
}
}
package com.iluwatar.specification.app {
class App {
+ App()
+ main(args : String[]) {static}
}
}
package com.iluwatar.specification.selector {
class SizeSelector {
- s : Size
+ SizeSelector(s : Size)
+ test(t : Creature) : boolean
}
class ColorSelector {
- c : Color
+ ColorSelector(c : Color)
+ test(t : Creature) : boolean
}
class MovementSelector {
- m : Movement
+ MovementSelector(m : Movement)
+ test(t : Creature) : boolean
}
}
SizeSelector --> "-s" Size
AbstractCreature --> "-color" Color
MovementSelector --> "-m" Movement
AbstractCreature --> "-movement" Movement
AbstractCreature --> "-size" Size
ColorSelector --> "-c" Color
Goblin --|> AbstractCreature
Troll --|> AbstractCreature
AbstractCreature ..|> Creature
Shark --|> AbstractCreature
KillerBee --|> AbstractCreature
Octopus --|> AbstractCreature
Dragon --|> AbstractCreature
@enduml

37
state/etc/state.urm.puml Normal file
View File

@ -0,0 +1,37 @@
@startuml
package com.iluwatar.state {
class AngryState {
- mammoth : Mammoth
+ AngryState(mammoth : Mammoth)
+ observe()
+ onEnterState()
}
class Mammoth {
- state : State
+ Mammoth()
- changeStateTo(newState : State)
+ observe()
+ timePasses()
+ toString() : String
}
interface State {
+ observe() {abstract}
+ onEnterState() {abstract}
}
class PeacefulState {
- mammoth : Mammoth
+ PeacefulState(mammoth : Mammoth)
+ observe()
+ onEnterState()
}
class App {
+ App()
+ main(args : String[]) {static}
}
}
PeacefulState --> "-mammoth" Mammoth
AngryState --> "-mammoth" Mammoth
Mammoth --> "-state" State
AngryState ..|> State
PeacefulState ..|> State
@enduml

View File

@ -0,0 +1,91 @@
@startuml
package com.iluwatar.stepbuilder {
interface BuildStep {
+ build() : Character {abstract}
}
-class CharacterSteps {
- abilities : List<String>
- fighterClass : String
- name : String
- spell : String
- weapon : String
- wizardClass : String
- CharacterSteps()
+ build() : Character
+ fighterClass(fighterClass : String) : WeaponStep
+ name(name : String) : ClassStep
+ noAbilities() : BuildStep
+ noMoreAbilities() : BuildStep
+ noSpell() : BuildStep
+ noWeapon() : BuildStep
+ withAbility(ability : String) : AbilityStep
+ withSpell(spell : String) : AbilityStep
+ withWeapon(weapon : String) : AbilityStep
+ wizardClass(wizardClass : String) : SpellStep
}
class App {
+ App()
+ main(args : String[]) {static}
}
interface ClassStep {
+ fighterClass(String) : WeaponStep {abstract}
+ wizardClass(String) : SpellStep {abstract}
}
interface WeaponStep {
+ noWeapon() : BuildStep {abstract}
+ withWeapon(String) : AbilityStep {abstract}
}
interface AbilityStep {
+ noAbilities() : BuildStep {abstract}
+ noMoreAbilities() : BuildStep {abstract}
+ withAbility(String) : AbilityStep {abstract}
}
interface NameStep {
+ name(String) : ClassStep {abstract}
}
class CharacterStepBuilder {
- CharacterStepBuilder()
+ newBuilder() : NameStep {static}
}
class Character {
- abilities : List<String>
- fighterClass : String
- name : String
- spell : String
- weapon : String
- wizardClass : String
+ Character(name : String)
+ getAbilities() : List<String>
+ getFighterClass() : String
+ getName() : String
+ getSpell() : String
+ getWeapon() : String
+ getWizardClass() : String
+ setAbilities(abilities : List<String>)
+ setFighterClass(fighterClass : String)
+ setName(name : String)
+ setSpell(spell : String)
+ setWeapon(weapon : String)
+ setWizardClass(wizardClass : String)
+ toString() : String
}
interface SpellStep {
+ noSpell() : BuildStep {abstract}
+ withSpell(String) : AbilityStep {abstract}
}
}
App --+ CharacterStepBuilder
WeaponStep ..+ CharacterStepBuilder
SpellStep ..+ CharacterStepBuilder
AbilityStep ..+ CharacterStepBuilder
ClassStep ..+ CharacterStepBuilder
CharacterSteps ..+ CharacterStepBuilder
NameStep ..+ CharacterStepBuilder
BuildStep ..+ CharacterStepBuilder
CharacterSteps ..|> NameStep
CharacterSteps ..|> ClassStep
CharacterSteps ..|> WeaponStep
CharacterSteps ..|> SpellStep
CharacterSteps ..|> AbilityStep
CharacterSteps ..|> BuildStep
@enduml

View File

@ -0,0 +1,33 @@
@startuml
package com.iluwatar.strategy {
class DragonSlayer {
- strategy : DragonSlayingStrategy
+ DragonSlayer(strategy : DragonSlayingStrategy)
+ changeStrategy(strategy : DragonSlayingStrategy)
+ goToBattle()
}
class SpellStrategy {
+ SpellStrategy()
+ execute()
}
class ProjectileStrategy {
+ ProjectileStrategy()
+ execute()
}
interface DragonSlayingStrategy {
+ execute() {abstract}
}
class MeleeStrategy {
+ MeleeStrategy()
+ execute()
}
class App {
+ App()
+ main(args : String[]) {static}
}
}
DragonSlayer --> "-strategy" DragonSlayingStrategy
SpellStrategy ..|> DragonSlayingStrategy
ProjectileStrategy ..|> DragonSlayingStrategy
MeleeStrategy ..|> DragonSlayingStrategy
@enduml

View File

@ -0,0 +1,36 @@
@startuml
package com.iluwatar.templatemethod {
class SubtleMethod {
+ SubtleMethod()
# confuseTarget(target : String)
# pickTarget() : String
# stealTheItem(target : String)
}
class HitAndRunMethod {
+ HitAndRunMethod()
# confuseTarget(target : String)
# pickTarget() : String
# stealTheItem(target : String)
}
abstract class StealingMethod {
+ StealingMethod()
# confuseTarget(String) {abstract}
# pickTarget() : String {abstract}
+ steal()
# stealTheItem(String) {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
class HalflingThief {
- method : StealingMethod
+ HalflingThief(method : StealingMethod)
+ changeMethod(method : StealingMethod)
+ steal()
}
}
HalflingThief --> "-method" StealingMethod
SubtleMethod --|> StealingMethod
HitAndRunMethod --|> StealingMethod
@enduml

View File

@ -0,0 +1,35 @@
@startuml
package com.iluwatar.threadpool {
class Worker {
- task : Task
+ Worker(task : Task)
+ run()
}
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class Task {
- ID_GENERATOR : AtomicInteger {static}
- id : int
- timeMs : int
+ Task(timeMs : int)
+ getId() : int
+ getTimeMs() : int
+ toString() : String
}
class PotatoPeelingTask {
- TIME_PER_POTATO : int {static}
+ PotatoPeelingTask(numPotatoes : int)
+ toString() : String
}
class CoffeeMakingTask {
- TIME_PER_CUP : int {static}
+ CoffeeMakingTask(numCups : int)
+ toString() : String
}
}
Worker --> "-task" Task
PotatoPeelingTask --|> Task
CoffeeMakingTask --|> Task
@enduml

View File

@ -0,0 +1,38 @@
@startuml
package com.iluwatar.tolerantreader {
class RainbowFishSerializer {
- RainbowFishSerializer()
+ readV1(filename : String) : RainbowFish {static}
+ writeV1(rainbowFish : RainbowFish, filename : String) {static}
+ writeV2(rainbowFish : RainbowFishV2, filename : String) {static}
}
class RainbowFish {
- age : int
- lengthMeters : int
- name : String
- serialVersionUID : long {static}
- weightTons : int
+ RainbowFish(name : String, age : int, lengthMeters : int, weightTons : int)
+ getAge() : int
+ getLengthMeters() : int
+ getName() : String
+ getWeightTons() : int
}
class RainbowFishV2 {
- angry : boolean
- hungry : boolean
- serialVersionUID : long {static}
- sleeping : boolean
+ RainbowFishV2(name : String, age : int, lengthMeters : int, weightTons : int)
+ RainbowFishV2(name : String, age : int, lengthMeters : int, weightTons : int, sleeping : boolean, hungry : boolean, angry : boolean)
+ getAngry() : boolean
+ getHungry() : boolean
+ getSleeping() : boolean
}
class App {
+ App()
+ main(args : String[]) {static}
}
}
RainbowFishV2 --|> RainbowFish
@enduml

25
twin/etc/twin.urm.puml Normal file
View File

@ -0,0 +1,25 @@
@startuml
package com.iluwatar.twin {
class App {
+ App()
+ main(args : String[]) {static}
- waiting() {static}
}
class BallItem {
- isSuspended : boolean
- twin : BallThread
+ BallItem()
+ click()
+ doDraw()
+ move()
+ setTwin(twin : BallThread)
}
abstract class GameItem {
+ GameItem()
+ click() {abstract}
+ doDraw() {abstract}
+ draw()
}
}
BallItem --|> GameItem
@enduml

View File

@ -0,0 +1,21 @@
@startuml
package com.iluwatar.value.object {
class App {
+ App()
+ main(args : String[]) {static}
}
class HeroStat {
- intelligence : int
- luck : int
- strength : int
- HeroStat(strength : int, intelligence : int, luck : int)
+ equals(obj : Object) : boolean
+ getIntelligence() : int
+ getLuck() : int
+ getStrength() : int
+ hashCode() : int
+ toString() : String
+ valueOf(strength : int, intelligence : int, luck : int) : HeroStat {static}
}
}
@enduml

View File

@ -0,0 +1,57 @@
@startuml
package com.iluwatar.visitor {
class CommanderVisitor {
+ CommanderVisitor()
+ visitCommander(commander : Commander)
+ visitSergeant(sergeant : Sergeant)
+ visitSoldier(soldier : Soldier)
}
class Sergeant {
+ Sergeant(children : Unit[])
+ accept(visitor : UnitVisitor)
+ toString() : String
}
class Commander {
+ Commander(children : Unit[])
+ accept(visitor : UnitVisitor)
+ toString() : String
}
abstract class Unit {
- children : Unit[]
+ Unit(children : Unit[])
+ accept(visitor : UnitVisitor)
}
class Soldier {
+ Soldier(children : Unit[])
+ accept(visitor : UnitVisitor)
+ toString() : String
}
class SergeantVisitor {
+ SergeantVisitor()
+ visitCommander(commander : Commander)
+ visitSergeant(sergeant : Sergeant)
+ visitSoldier(soldier : Soldier)
}
interface UnitVisitor {
+ visitCommander(Commander) {abstract}
+ visitSergeant(Sergeant) {abstract}
+ visitSoldier(Soldier) {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
class SoldierVisitor {
+ SoldierVisitor()
+ visitCommander(commander : Commander)
+ visitSergeant(sergeant : Sergeant)
+ visitSoldier(soldier : Soldier)
}
}
CommanderVisitor ..|> UnitVisitor
Sergeant --|> Unit
Commander --|> Unit
Soldier --|> Unit
SergeantVisitor ..|> UnitVisitor
SoldierVisitor ..|> UnitVisitor
@enduml