├── .gitignore
├── .travis.yml
├── CODE_COVERAGE.md
├── CONTRIBUTING.MD
├── LICENSE.md
├── README.md
├── abstract-factory
├── .gitignore
├── README.md
├── etc
│ ├── abstract-factory.png
│ ├── abstract-factory.ucls
│ └── abstract-factory_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── abstractfactory
│ │ ├── App.java
│ │ ├── Army.java
│ │ ├── Castle.java
│ │ ├── ElfArmy.java
│ │ ├── ElfCastle.java
│ │ ├── ElfKing.java
│ │ ├── ElfKingdomFactory.java
│ │ ├── King.java
│ │ ├── KingdomFactory.java
│ │ ├── OrcArmy.java
│ │ ├── OrcCastle.java
│ │ ├── OrcKing.java
│ │ └── OrcKingdomFactory.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── abstractfactory
│ ├── AbstractFactoryTest.java
│ └── AppTest.java
├── adapter
├── README.md
├── etc
│ ├── adapter.png
│ └── adapter.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── adapter
│ │ ├── App.java
│ │ ├── BattleFishingBoat.java
│ │ ├── BattleShip.java
│ │ ├── Captain.java
│ │ └── FishingBoat.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── adapter
│ ├── AdapterPatternTest.java
│ └── AppTest.java
├── api-gateway
├── README.md
├── api-gateway-service
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── iluwatar
│ │ │ │ └── api
│ │ │ │ └── gateway
│ │ │ │ ├── ApiGateway.java
│ │ │ │ ├── App.java
│ │ │ │ ├── DesktopProduct.java
│ │ │ │ ├── ImageClient.java
│ │ │ │ ├── ImageClientImpl.java
│ │ │ │ ├── MobileProduct.java
│ │ │ │ ├── PriceClient.java
│ │ │ │ └── PriceClientImpl.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── api
│ │ └── gateway
│ │ └── ApiGatewayTest.java
├── etc
│ ├── api-gateway.png
│ └── api-gateway.ucls
├── image-microservice
│ ├── etc
│ │ ├── image-microservice.png
│ │ └── image-microservice.ucls
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── iluwatar
│ │ │ │ └── image
│ │ │ │ └── microservice
│ │ │ │ ├── ImageApplication.java
│ │ │ │ └── ImageController.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── image
│ │ └── microservice
│ │ └── ImageControllerTest.java
├── pom.xml
└── price-microservice
│ ├── etc
│ ├── price-microservice.png
│ └── price-microservice.ucls
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── iluwatar
│ │ │ └── price
│ │ │ └── microservice
│ │ │ ├── PriceApplication.java
│ │ │ └── PriceController.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── price
│ └── microservice
│ └── PriceControllerTest.java
├── async-method-invocation
├── README.md
├── etc
│ ├── async-method-invocation.png
│ └── async-method-invocation.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── async
│ │ └── method
│ │ └── invocation
│ │ ├── App.java
│ │ ├── AsyncCallback.java
│ │ ├── AsyncExecutor.java
│ │ ├── AsyncResult.java
│ │ └── ThreadAsyncExecutor.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── async
│ └── method
│ └── invocation
│ ├── AppTest.java
│ └── ThreadAsyncExecutorTest.java
├── bridge
├── README.md
├── etc
│ ├── bridge.png
│ └── bridge.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── bridge
│ │ ├── App.java
│ │ ├── BlindingMagicWeapon.java
│ │ ├── BlindingMagicWeaponImpl.java
│ │ ├── Excalibur.java
│ │ ├── FlyingMagicWeapon.java
│ │ ├── FlyingMagicWeaponImpl.java
│ │ ├── MagicWeapon.java
│ │ ├── MagicWeaponImpl.java
│ │ ├── Mjollnir.java
│ │ ├── SoulEatingMagicWeapon.java
│ │ ├── SoulEatingMagicWeaponImpl.java
│ │ └── Stormbringer.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── bridge
│ ├── AppTest.java
│ ├── BlindingMagicWeaponTest.java
│ ├── FlyingMagicWeaponTest.java
│ ├── MagicWeaponTest.java
│ └── SoulEatingMagicWeaponTest.java
├── builder
├── .gitignore
├── README.md
├── etc
│ ├── builder.png
│ ├── builder.ucls
│ └── builder_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── builder
│ │ ├── App.java
│ │ ├── Armor.java
│ │ ├── HairColor.java
│ │ ├── HairType.java
│ │ ├── Hero.java
│ │ ├── Profession.java
│ │ └── Weapon.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── builder
│ ├── AppTest.java
│ └── HeroTest.java
├── business-delegate
├── README.md
├── etc
│ ├── business-delegate.png
│ └── business-delegate.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── business
│ │ └── delegate
│ │ ├── App.java
│ │ ├── BusinessDelegate.java
│ │ ├── BusinessLookup.java
│ │ ├── BusinessService.java
│ │ ├── Client.java
│ │ ├── EjbService.java
│ │ ├── JmsService.java
│ │ └── ServiceType.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── business
│ └── delegate
│ ├── AppTest.java
│ └── BusinessDelegateTest.java
├── caching
├── .gitignore
├── README.md
├── etc
│ ├── caching.png
│ └── caching.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── caching
│ │ ├── App.java
│ │ ├── AppManager.java
│ │ ├── CacheStore.java
│ │ ├── CachingPolicy.java
│ │ ├── DbManager.java
│ │ ├── LruCache.java
│ │ └── UserAccount.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── caching
│ ├── AppTest.java
│ └── CachingTest.java
├── callback
├── README.md
├── etc
│ ├── callback.png
│ └── callback.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── callback
│ │ ├── App.java
│ │ ├── Callback.java
│ │ ├── LambdasApp.java
│ │ ├── SimpleTask.java
│ │ └── Task.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── callback
│ ├── AppTest.java
│ └── CallbackTest.java
├── chain
├── README.md
├── etc
│ ├── chain.png
│ ├── chain.ucls
│ └── chain_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── chain
│ │ ├── App.java
│ │ ├── OrcCommander.java
│ │ ├── OrcKing.java
│ │ ├── OrcOfficer.java
│ │ ├── OrcSoldier.java
│ │ ├── Request.java
│ │ ├── RequestHandler.java
│ │ └── RequestType.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── chain
│ ├── AppTest.java
│ └── OrcKingTest.java
├── checkstyle-suppressions.xml
├── checkstyle.xml
├── command
├── README.md
├── etc
│ ├── command.png
│ └── command.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── command
│ │ ├── App.java
│ │ ├── Command.java
│ │ ├── Goblin.java
│ │ ├── InvisibilitySpell.java
│ │ ├── ShrinkSpell.java
│ │ ├── Size.java
│ │ ├── Target.java
│ │ ├── Visibility.java
│ │ └── Wizard.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── command
│ ├── AppTest.java
│ └── CommandTest.java
├── composite
├── README.md
├── etc
│ ├── composite.png
│ ├── composite.ucls
│ └── composite_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── composite
│ │ ├── App.java
│ │ ├── Letter.java
│ │ ├── LetterComposite.java
│ │ ├── Messenger.java
│ │ ├── Sentence.java
│ │ └── Word.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── composite
│ ├── AppTest.java
│ └── MessengerTest.java
├── dao
├── README.md
├── etc
│ ├── dao.png
│ └── dao.ucls
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── iluwatar
│ │ │ └── dao
│ │ │ ├── App.java
│ │ │ ├── Customer.java
│ │ │ ├── CustomerDao.java
│ │ │ ├── CustomerSchemaSql.java
│ │ │ ├── DbCustomerDao.java
│ │ │ └── InMemoryCustomerDao.java
│ └── resources
│ │ └── log4j.xml
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── dao
│ ├── AppTest.java
│ ├── CustomerTest.java
│ ├── DbCustomerDaoTest.java
│ └── InMemoryCustomerDaoTest.java
├── data-mapper
├── etc
│ ├── data-mapper.png
│ └── data-mapper.ucls
├── index.md
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── iluwatar
│ │ │ └── datamapper
│ │ │ ├── App.java
│ │ │ ├── DataMapperException.java
│ │ │ ├── Student.java
│ │ │ ├── StudentDataMapper.java
│ │ │ └── StudentDataMapperImpl.java
│ └── resources
│ │ └── log4j.xml
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── datamapper
│ ├── AppTest.java
│ ├── DataMapperTest.java
│ └── StudentTest.java
├── decorator
├── README.md
├── etc
│ ├── decorator.png
│ └── decorator.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── decorator
│ │ ├── App.java
│ │ ├── Hostile.java
│ │ ├── SmartHostile.java
│ │ └── Troll.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── decorator
│ ├── AppTest.java
│ ├── SmartHostileTest.java
│ └── TrollTest.java
├── delegation
├── README.md
├── etc
│ ├── delegation.png
│ └── delegation.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── delegation
│ │ └── simple
│ │ ├── App.java
│ │ ├── Printer.java
│ │ ├── PrinterController.java
│ │ └── printers
│ │ ├── CanonPrinter.java
│ │ ├── EpsonPrinter.java
│ │ └── HpPrinter.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── delegation
│ └── simple
│ ├── AppTest.java
│ └── DelegateTest.java
├── dependency-injection
├── README.md
├── etc
│ ├── dependency-injection.png
│ └── dependency-injection.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── dependency
│ │ └── injection
│ │ ├── AdvancedWizard.java
│ │ ├── App.java
│ │ ├── GuiceWizard.java
│ │ ├── OldTobyTobacco.java
│ │ ├── RivendellTobacco.java
│ │ ├── SecondBreakfastTobacco.java
│ │ ├── SimpleWizard.java
│ │ ├── Tobacco.java
│ │ ├── TobaccoModule.java
│ │ └── Wizard.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── dependency
│ └── injection
│ ├── AdvancedWizardTest.java
│ ├── AppTest.java
│ ├── GuiceWizardTest.java
│ ├── SimpleWizardTest.java
│ └── StdOutTest.java
├── double-checked-locking
├── README.md
├── etc
│ ├── double-checked-locking.png
│ ├── double-checked-locking.ucls
│ └── double_checked_locking_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── doublechecked
│ │ └── locking
│ │ ├── App.java
│ │ ├── Inventory.java
│ │ └── Item.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── doublechecked
│ └── locking
│ ├── AppTest.java
│ └── InventoryTest.java
├── double-dispatch
├── README.md
├── etc
│ ├── double-dispatch.png
│ └── double-dispatch.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── doubledispatch
│ │ ├── App.java
│ │ ├── FlamingAsteroid.java
│ │ ├── GameObject.java
│ │ ├── Meteoroid.java
│ │ ├── Rectangle.java
│ │ ├── SpaceStationIss.java
│ │ └── SpaceStationMir.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── doubledispatch
│ ├── AppTest.java
│ ├── CollisionTest.java
│ ├── FlamingAsteroidTest.java
│ ├── MeteoroidTest.java
│ ├── RectangleTest.java
│ ├── SpaceStationIssTest.java
│ └── SpaceStationMirTest.java
├── event-aggregator
├── README.md
├── etc
│ ├── classes.png
│ └── classes.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── event
│ │ └── aggregator
│ │ ├── App.java
│ │ ├── Event.java
│ │ ├── EventEmitter.java
│ │ ├── EventObserver.java
│ │ ├── KingJoffrey.java
│ │ ├── KingsHand.java
│ │ ├── LordBaelish.java
│ │ ├── LordVarys.java
│ │ ├── Scout.java
│ │ └── Weekday.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── event
│ └── aggregator
│ ├── AppTest.java
│ ├── EventEmitterTest.java
│ ├── EventTest.java
│ ├── KingJoffreyTest.java
│ ├── KingsHandTest.java
│ ├── LordBaelishTest.java
│ ├── LordVarysTest.java
│ ├── ScoutTest.java
│ └── WeekdayTest.java
├── event-driven-architecture
├── README.md
├── etc
│ ├── eda.png
│ └── eda.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── eda
│ │ ├── App.java
│ │ ├── event
│ │ ├── AbstractEvent.java
│ │ ├── UserCreatedEvent.java
│ │ └── UserUpdatedEvent.java
│ │ ├── framework
│ │ ├── Event.java
│ │ ├── EventDispatcher.java
│ │ └── Handler.java
│ │ ├── handler
│ │ ├── UserCreatedEventHandler.java
│ │ └── UserUpdatedEventHandler.java
│ │ └── model
│ │ └── User.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── eda
│ ├── AppTest.java
│ ├── event
│ └── UserCreatedEventTest.java
│ └── framework
│ └── EventDispatcherTest.java
├── exclude-pmd.properties
├── execute-around
├── README.md
├── etc
│ ├── execute-around.png
│ └── execute-around.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── execute
│ │ └── around
│ │ ├── App.java
│ │ ├── FileWriterAction.java
│ │ └── SimpleFileWriter.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── execute
│ └── around
│ ├── AppTest.java
│ └── SimpleFileWriterTest.java
├── facade
├── README.md
├── etc
│ ├── facade.png
│ ├── facade.ucls
│ └── facade_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── facade
│ │ ├── App.java
│ │ ├── DwarvenCartOperator.java
│ │ ├── DwarvenGoldDigger.java
│ │ ├── DwarvenGoldmineFacade.java
│ │ ├── DwarvenMineWorker.java
│ │ └── DwarvenTunnelDigger.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── facade
│ ├── AppTest.java
│ └── DwarvenGoldmineFacadeTest.java
├── factory-kit
├── README.md
├── etc
│ ├── factory-kit.png
│ └── factory-kit.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── factorykit
│ │ ├── App.java
│ │ ├── Axe.java
│ │ ├── Bow.java
│ │ ├── Builder.java
│ │ ├── Spear.java
│ │ ├── Sword.java
│ │ ├── Weapon.java
│ │ ├── WeaponFactory.java
│ │ └── WeaponType.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── factorykit
│ ├── app
│ └── AppTest.java
│ └── factorykit
│ └── FactoryKitTest.java
├── factory-method
├── .gitignore
├── README.md
├── etc
│ ├── factory-method.png
│ ├── factory-method.ucls
│ └── factory-method_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── factory
│ │ └── method
│ │ ├── App.java
│ │ ├── Blacksmith.java
│ │ ├── ElfBlacksmith.java
│ │ ├── ElfWeapon.java
│ │ ├── OrcBlacksmith.java
│ │ ├── OrcWeapon.java
│ │ ├── Weapon.java
│ │ └── WeaponType.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── factory
│ └── method
│ ├── AppTest.java
│ └── FactoryMethodTest.java
├── faq.md
├── feature-toggle
├── README.md
├── etc
│ ├── feature-toggle.png
│ └── feature-toggle.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── featuretoggle
│ │ ├── App.java
│ │ ├── pattern
│ │ ├── Service.java
│ │ ├── propertiesversion
│ │ │ └── PropertiesFeatureToggleVersion.java
│ │ └── tieredversion
│ │ │ └── TieredFeatureToggleVersion.java
│ │ └── user
│ │ ├── User.java
│ │ └── UserGroup.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── featuretoggle
│ ├── pattern
│ ├── propertiesversion
│ │ └── PropertiesFeatureToggleVersionTest.java
│ └── tieredversion
│ │ └── TieredFeatureToggleVersionTest.java
│ └── user
│ └── UserGroupTest.java
├── fluentinterface
├── README.md
├── etc
│ ├── fluentinterface.png
│ └── fluentinterface.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── fluentinterface
│ │ ├── app
│ │ └── App.java
│ │ └── fluentiterable
│ │ ├── FluentIterable.java
│ │ ├── lazy
│ │ ├── DecoratingIterator.java
│ │ └── LazyFluentIterable.java
│ │ └── simple
│ │ └── SimpleFluentIterable.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── fluentinterface
│ ├── app
│ └── AppTest.java
│ └── fluentiterable
│ ├── FluentIterableTest.java
│ ├── lazy
│ └── LazyFluentIterableTest.java
│ └── simple
│ └── SimpleFluentIterableTest.java
├── flux
├── README.md
├── etc
│ ├── flux.png
│ └── flux.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── flux
│ │ ├── action
│ │ ├── Action.java
│ │ ├── ActionType.java
│ │ ├── Content.java
│ │ ├── ContentAction.java
│ │ ├── MenuAction.java
│ │ └── MenuItem.java
│ │ ├── app
│ │ └── App.java
│ │ ├── dispatcher
│ │ └── Dispatcher.java
│ │ ├── store
│ │ ├── ContentStore.java
│ │ ├── MenuStore.java
│ │ └── Store.java
│ │ └── view
│ │ ├── ContentView.java
│ │ ├── MenuView.java
│ │ └── View.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── flux
│ ├── action
│ ├── ContentTest.java
│ └── MenuItemTest.java
│ ├── app
│ └── AppTest.java
│ ├── dispatcher
│ └── DispatcherTest.java
│ ├── store
│ ├── ContentStoreTest.java
│ └── MenuStoreTest.java
│ └── view
│ ├── ContentViewTest.java
│ └── MenuViewTest.java
├── flyweight
├── README.md
├── etc
│ ├── flyweight.png
│ ├── flyweight.ucls
│ └── flyweight_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── flyweight
│ │ ├── AlchemistShop.java
│ │ ├── App.java
│ │ ├── HealingPotion.java
│ │ ├── HolyWaterPotion.java
│ │ ├── InvisibilityPotion.java
│ │ ├── PoisonPotion.java
│ │ ├── Potion.java
│ │ ├── PotionFactory.java
│ │ ├── PotionType.java
│ │ └── StrengthPotion.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── flyweight
│ ├── AlchemistShopTest.java
│ └── AppTest.java
├── front-controller
├── README.md
├── etc
│ ├── front-controller.png
│ └── front-controller.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── front
│ │ └── controller
│ │ ├── App.java
│ │ ├── ApplicationException.java
│ │ ├── ArcherCommand.java
│ │ ├── ArcherView.java
│ │ ├── CatapultCommand.java
│ │ ├── CatapultView.java
│ │ ├── Command.java
│ │ ├── ErrorView.java
│ │ ├── FrontController.java
│ │ ├── UnknownCommand.java
│ │ └── View.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── front
│ └── controller
│ ├── AppTest.java
│ ├── ApplicationExceptionTest.java
│ ├── CommandTest.java
│ ├── FrontControllerTest.java
│ ├── StdOutTest.java
│ └── ViewTest.java
├── half-sync-half-async
├── README.md
├── etc
│ ├── half-sync-half-async.png
│ └── half-sync-half-async.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── halfsynchalfasync
│ │ ├── App.java
│ │ ├── AsyncTask.java
│ │ └── AsynchronousService.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── halfsynchalfasync
│ ├── AppTest.java
│ └── AsynchronousServiceTest.java
├── hexagonal
├── README.md
├── etc
│ ├── hexagonal.png
│ └── hexagonal.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── hexagonal
│ │ ├── App.java
│ │ ├── administration
│ │ ├── LotteryAdministration.java
│ │ └── LotteryAdministrationImpl.java
│ │ ├── banking
│ │ ├── WireTransfers.java
│ │ └── WireTransfersImpl.java
│ │ ├── database
│ │ ├── LotteryTicketInMemoryRepository.java
│ │ └── LotteryTicketRepository.java
│ │ ├── domain
│ │ ├── LotteryConstants.java
│ │ ├── LotteryNumbers.java
│ │ ├── LotteryTicket.java
│ │ ├── LotteryTicketCheckResult.java
│ │ ├── LotteryTicketId.java
│ │ └── PlayerDetails.java
│ │ ├── notifications
│ │ ├── LotteryNotifications.java
│ │ └── LotteryNotificationsImpl.java
│ │ └── service
│ │ ├── LotteryService.java
│ │ └── LotteryServiceImpl.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── hexagonal
│ ├── AppTest.java
│ ├── banking
│ └── WireTransfersTest.java
│ ├── database
│ └── LotteryTicketRepositoryTest.java
│ ├── domain
│ ├── LotteryNumbersTest.java
│ ├── LotteryTicketCheckResultTest.java
│ ├── LotteryTicketTest.java
│ └── PlayerDetailsTest.java
│ ├── lottery
│ └── LotteryTest.java
│ └── test
│ └── LotteryTestUtils.java
├── intercepting-filter
├── README.md
├── etc
│ ├── intercepting-filter.png
│ └── intercepting-filter.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── intercepting
│ │ └── filter
│ │ ├── AbstractFilter.java
│ │ ├── AddressFilter.java
│ │ ├── App.java
│ │ ├── Client.java
│ │ ├── ContactFilter.java
│ │ ├── DepositFilter.java
│ │ ├── Filter.java
│ │ ├── FilterChain.java
│ │ ├── FilterManager.java
│ │ ├── NameFilter.java
│ │ ├── Order.java
│ │ ├── OrderFilter.java
│ │ └── Target.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── intercepting
│ └── filter
│ ├── AppTest.java
│ ├── FilterManagerTest.java
│ ├── FilterTest.java
│ └── OrderTest.java
├── interpreter
├── README.md
├── etc
│ ├── interpreter.png
│ ├── interpreter.ucls
│ └── interpreter_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── interpreter
│ │ ├── App.java
│ │ ├── Expression.java
│ │ ├── MinusExpression.java
│ │ ├── MultiplyExpression.java
│ │ ├── NumberExpression.java
│ │ └── PlusExpression.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── interpreter
│ ├── AppTest.java
│ ├── ExpressionTest.java
│ ├── MinusExpressionTest.java
│ ├── MultiplyExpressionTest.java
│ ├── NumberExpressionTest.java
│ └── PlusExpressionTest.java
├── iterator
├── README.md
├── etc
│ ├── iterator.png
│ ├── iterator.ucls
│ └── iterator_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── iterator
│ │ ├── App.java
│ │ ├── Item.java
│ │ ├── ItemIterator.java
│ │ ├── ItemType.java
│ │ ├── TreasureChest.java
│ │ └── TreasureChestItemIterator.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── iterator
│ ├── AppTest.java
│ └── TreasureChestTest.java
├── layers
├── README.md
├── etc
│ ├── layers.png
│ └── layers.ucls
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── iluwatar
│ │ │ └── layers
│ │ │ ├── App.java
│ │ │ ├── Cake.java
│ │ │ ├── CakeBakingException.java
│ │ │ ├── CakeBakingService.java
│ │ │ ├── CakeBakingServiceImpl.java
│ │ │ ├── CakeDao.java
│ │ │ ├── CakeInfo.java
│ │ │ ├── CakeLayer.java
│ │ │ ├── CakeLayerDao.java
│ │ │ ├── CakeLayerInfo.java
│ │ │ ├── CakeTopping.java
│ │ │ ├── CakeToppingDao.java
│ │ │ ├── CakeToppingInfo.java
│ │ │ ├── CakeViewImpl.java
│ │ │ └── View.java
│ └── resources
│ │ ├── META-INF
│ │ └── persistence.xml
│ │ └── applicationContext.xml
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── layers
│ ├── AppTest.java
│ ├── CakeBakingExceptionTest.java
│ ├── CakeBakingServiceImplTest.java
│ ├── CakeTest.java
│ ├── CakeViewImplTest.java
│ └── StdOutTest.java
├── lazy-loading
├── README.md
├── etc
│ ├── lazy-loading.png
│ └── lazy-loading.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── lazy
│ │ └── loading
│ │ ├── App.java
│ │ ├── Heavy.java
│ │ ├── HolderNaive.java
│ │ ├── HolderThreadSafe.java
│ │ └── Java8Holder.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── lazy
│ └── loading
│ ├── AbstractHolderTest.java
│ ├── AppTest.java
│ ├── HolderNaiveTest.java
│ ├── HolderThreadSafeTest.java
│ └── Java8HolderTest.java
├── mediator
├── README.md
├── etc
│ ├── mediator.png
│ ├── mediator.ucls
│ └── mediator_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── mediator
│ │ ├── Action.java
│ │ ├── App.java
│ │ ├── Hobbit.java
│ │ ├── Hunter.java
│ │ ├── Party.java
│ │ ├── PartyImpl.java
│ │ ├── PartyMember.java
│ │ ├── PartyMemberBase.java
│ │ ├── Rogue.java
│ │ └── Wizard.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── mediator
│ ├── AppTest.java
│ ├── PartyImplTest.java
│ └── PartyMemberTest.java
├── memento
├── README.md
├── etc
│ ├── memento.png
│ └── memento.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── memento
│ │ ├── App.java
│ │ ├── Star.java
│ │ ├── StarMemento.java
│ │ └── StarType.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── memento
│ ├── AppTest.java
│ └── StarTest.java
├── message-channel
├── .gitignore
├── README.md
├── etc
│ ├── message-channel.png
│ └── message-channel.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── message
│ │ └── channel
│ │ └── App.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── message
│ └── channel
│ └── AppTest.java
├── model-view-controller
├── README.md
├── etc
│ ├── model-view-controller.png
│ └── model-view-controller.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── model
│ │ └── view
│ │ └── controller
│ │ ├── App.java
│ │ ├── Fatigue.java
│ │ ├── GiantController.java
│ │ ├── GiantModel.java
│ │ ├── GiantView.java
│ │ ├── Health.java
│ │ └── Nourishment.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── model
│ └── view
│ └── controller
│ ├── AppTest.java
│ ├── GiantControllerTest.java
│ ├── GiantModelTest.java
│ └── GiantViewTest.java
├── model-view-presenter
├── README.md
├── etc
│ ├── data
│ │ └── test.txt
│ ├── model-view-presenter.png
│ ├── model-view-presenter.ucls
│ └── model-view-presenter_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── model
│ │ └── view
│ │ └── presenter
│ │ ├── App.java
│ │ ├── FileLoader.java
│ │ ├── FileSelectorJFrame.java
│ │ ├── FileSelectorPresenter.java
│ │ ├── FileSelectorStub.java
│ │ └── FileSelectorView.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── model
│ └── view
│ └── presenter
│ ├── AppTest.java
│ ├── FileLoaderTest.java
│ └── FileSelectorPresenterTest.java
├── monad
├── README.md
├── etc
│ ├── monad.png
│ └── monad.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── monad
│ │ ├── App.java
│ │ ├── Sex.java
│ │ ├── User.java
│ │ └── Validator.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── monad
│ ├── AppTest.java
│ └── MonadTest.java
├── monostate
├── README.md
├── etc
│ ├── MonoState.ucls
│ └── monostate.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── monostate
│ │ ├── App.java
│ │ ├── LoadBalancer.java
│ │ ├── Request.java
│ │ └── Server.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── monostate
│ ├── AppTest.java
│ └── LoadBalancerTest.java
├── multiton
├── README.md
├── etc
│ ├── multiton.png
│ └── multiton.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── multiton
│ │ ├── App.java
│ │ ├── Nazgul.java
│ │ └── NazgulName.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── multiton
│ ├── AppTest.java
│ └── NazgulTest.java
├── mute-idiom
├── README.md
├── etc
│ ├── mute-idiom.png
│ └── mute-idiom.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── mute
│ │ ├── App.java
│ │ ├── CheckedRunnable.java
│ │ ├── Mute.java
│ │ └── Resource.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── mute
│ ├── AppTest.java
│ └── MuteTest.java
├── mutex
├── README.md
├── etc
│ └── mutex.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── mutex
│ │ ├── App.java
│ │ ├── Jar.java
│ │ ├── Lock.java
│ │ ├── Mutex.java
│ │ └── Thief.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── mutex
│ ├── AppTest.java
│ ├── JarTest.java
│ └── MutexTest.java
├── naked-objects
├── .gitattributes
├── .gitignore
├── README
├── README.md
├── dom
│ ├── log4j.properties
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ ├── META-INF
│ │ │ └── persistence.xml
│ │ │ └── domainapp
│ │ │ └── dom
│ │ │ ├── app
│ │ │ └── homepage
│ │ │ │ ├── HomePageService.java
│ │ │ │ ├── HomePageViewModel.java
│ │ │ │ ├── HomePageViewModel.layout.json
│ │ │ │ └── HomePageViewModel.png
│ │ │ └── modules
│ │ │ └── simple
│ │ │ ├── SimpleObject.java
│ │ │ ├── SimpleObject.layout.json
│ │ │ ├── SimpleObject.png
│ │ │ └── SimpleObjects.java
│ │ └── test
│ │ └── java
│ │ └── domainapp
│ │ └── dom
│ │ └── modules
│ │ └── simple
│ │ ├── SimpleObjectTest.java
│ │ └── SimpleObjectsTest.java
├── etc
│ ├── naked-objects.png
│ └── naked-objects.ucls
├── fixture
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── domainapp
│ │ └── fixture
│ │ ├── DomainAppFixturesProvider.java
│ │ ├── modules
│ │ └── simple
│ │ │ ├── SimpleObjectCreate.java
│ │ │ └── SimpleObjectsTearDown.java
│ │ └── scenarios
│ │ └── RecreateSimpleObjects.java
├── integtests
│ ├── .gitignore
│ ├── logging.properties
│ ├── pom.xml
│ └── src
│ │ └── test
│ │ └── java
│ │ └── domainapp
│ │ └── integtests
│ │ ├── bootstrap
│ │ └── SimpleAppSystemInitializer.java
│ │ ├── specglue
│ │ ├── BootstrappingGlue.java
│ │ ├── CatalogOfFixturesGlue.java
│ │ └── modules
│ │ │ └── simple
│ │ │ └── SimpleObjectGlue.java
│ │ ├── specs
│ │ ├── RunSpecs.java
│ │ └── modules
│ │ │ └── simple
│ │ │ └── SimpleObjectSpec_listAllAndCreate.feature
│ │ └── tests
│ │ ├── SimpleAppIntegTest.java
│ │ └── modules
│ │ └── simple
│ │ ├── SimpleObjectIntegTest.java
│ │ └── SimpleObjectsIntegTest.java
├── pom.xml
└── webapp
│ ├── ide
│ ├── eclipse
│ │ └── launch
│ │ │ └── .gitignore
│ └── intellij
│ │ └── launch
│ │ ├── README.txt
│ │ ├── SimpleApp_PROTOTYPE.xml
│ │ └── SimpleApp__enhance_only_.xml
│ ├── lib
│ └── .gitignore
│ ├── pom.xml
│ └── src
│ └── main
│ ├── java
│ └── domainapp
│ │ └── webapp
│ │ └── SimpleApplication.java
│ ├── jettyconsole
│ ├── isis-banner.pdn
│ └── isis-banner.png
│ ├── resources
│ └── domainapp
│ │ └── webapp
│ │ └── welcome.html
│ └── webapp
│ ├── WEB-INF
│ ├── isis.properties
│ ├── logging.properties
│ ├── persistor.properties
│ ├── persistor_datanucleus.properties
│ ├── shiro.ini
│ ├── translations-en.po
│ ├── translations-es.po
│ ├── translations-nl.po
│ ├── translations.po
│ ├── viewer_restfulobjects.properties
│ ├── viewer_wicket.properties
│ └── web.xml
│ ├── about
│ ├── images
│ │ └── isis-logo.png
│ └── index.html
│ ├── css
│ └── application.css
│ ├── images
│ └── spinning-icon.gif
│ └── scripts
│ └── application.js
├── null-object
├── README.md
├── etc
│ ├── null-object.png
│ └── null-object.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── nullobject
│ │ ├── App.java
│ │ ├── Node.java
│ │ ├── NodeImpl.java
│ │ └── NullNode.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── nullobject
│ ├── AppTest.java
│ ├── NullNodeTest.java
│ ├── StdOutTest.java
│ └── TreeTest.java
├── object-pool
├── README.md
├── etc
│ ├── object-pool.png
│ └── object-pool.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── object
│ │ └── pool
│ │ ├── App.java
│ │ ├── ObjectPool.java
│ │ ├── Oliphaunt.java
│ │ └── OliphauntPool.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── object
│ └── pool
│ ├── AppTest.java
│ └── OliphauntPoolTest.java
├── observer
├── README.md
├── etc
│ ├── observer.png
│ ├── observer.ucls
│ └── observer_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── observer
│ │ ├── App.java
│ │ ├── Hobbits.java
│ │ ├── Orcs.java
│ │ ├── Weather.java
│ │ ├── WeatherObserver.java
│ │ ├── WeatherType.java
│ │ └── generic
│ │ ├── GHobbits.java
│ │ ├── GOrcs.java
│ │ ├── GWeather.java
│ │ ├── Observable.java
│ │ ├── Observer.java
│ │ └── Race.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── observer
│ ├── AppTest.java
│ ├── HobbitsTest.java
│ ├── OrcsTest.java
│ ├── StdOutTest.java
│ ├── WeatherObserverTest.java
│ ├── WeatherTest.java
│ └── generic
│ ├── GHobbitsTest.java
│ ├── GWeatherTest.java
│ ├── ObserverTest.java
│ └── OrcsTest.java
├── poison-pill
├── README.md
├── etc
│ ├── poison-pill.png
│ └── poison-pill.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── poison
│ │ └── pill
│ │ ├── App.java
│ │ ├── Consumer.java
│ │ ├── Message.java
│ │ ├── MessageQueue.java
│ │ ├── MqPublishPoint.java
│ │ ├── MqSubscribePoint.java
│ │ ├── Producer.java
│ │ ├── SimpleMessage.java
│ │ └── SimpleMessageQueue.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── poison
│ └── pill
│ ├── AppTest.java
│ ├── ConsumerTest.java
│ ├── PoisonMessageTest.java
│ ├── ProducerTest.java
│ ├── SimpleMessageTest.java
│ └── StdOutTest.java
├── pom.xml
├── private-class-data
├── README.md
├── etc
│ ├── private-class-data.png
│ └── private-class-data.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── privateclassdata
│ │ ├── App.java
│ │ ├── ImmutableStew.java
│ │ ├── Stew.java
│ │ └── StewData.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── privateclassdata
│ ├── AppTest.java
│ ├── ImmutableStewTest.java
│ ├── StdOutTest.java
│ └── StewTest.java
├── producer-consumer
├── README.md
├── etc
│ ├── producer-consumer.png
│ └── producer-consumer.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── producer
│ │ └── consumer
│ │ ├── App.java
│ │ ├── Consumer.java
│ │ ├── Item.java
│ │ ├── ItemQueue.java
│ │ └── Producer.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── producer
│ └── consumer
│ ├── AppTest.java
│ ├── ConsumerTest.java
│ ├── ProducerTest.java
│ └── StdOutTest.java
├── property
├── README.md
├── etc
│ ├── property.png
│ └── property.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── property
│ │ ├── App.java
│ │ ├── Character.java
│ │ ├── Prototype.java
│ │ └── Stats.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── property
│ ├── AppTest.java
│ └── CharacterTest.java
├── prototype
├── README.md
├── etc
│ ├── prototype.png
│ ├── prototype.ucls
│ └── prototype_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── prototype
│ │ ├── App.java
│ │ ├── Beast.java
│ │ ├── ElfBeast.java
│ │ ├── ElfMage.java
│ │ ├── ElfWarlord.java
│ │ ├── HeroFactory.java
│ │ ├── HeroFactoryImpl.java
│ │ ├── Mage.java
│ │ ├── OrcBeast.java
│ │ ├── OrcMage.java
│ │ ├── OrcWarlord.java
│ │ ├── Prototype.java
│ │ └── Warlord.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── prototype
│ ├── AppTest.java
│ ├── HeroFactoryImplTest.java
│ └── PrototypeTest.java
├── proxy
├── README.md
├── etc
│ ├── proxy.png
│ ├── proxy.ucls
│ └── proxy_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── proxy
│ │ ├── App.java
│ │ ├── Wizard.java
│ │ ├── WizardTower.java
│ │ └── WizardTowerProxy.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── proxy
│ ├── AppTest.java
│ ├── StdOutTest.java
│ ├── WizardTest.java
│ ├── WizardTowerProxyTest.java
│ └── WizardTowerTest.java
├── publish-subscribe
├── .gitignore
├── README.md
├── etc
│ ├── publish-subscribe.png
│ └── publish-subscribe.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── publish
│ │ └── subscribe
│ │ └── App.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── publish
│ └── subscribe
│ └── AppTest.java
├── reactor
├── README.md
├── etc
│ ├── reactor.png
│ └── reactor.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── reactor
│ │ ├── app
│ │ ├── App.java
│ │ ├── AppClient.java
│ │ └── LoggingHandler.java
│ │ └── framework
│ │ ├── AbstractNioChannel.java
│ │ ├── ChannelHandler.java
│ │ ├── Dispatcher.java
│ │ ├── NioDatagramChannel.java
│ │ ├── NioReactor.java
│ │ ├── NioServerSocketChannel.java
│ │ ├── SameThreadDispatcher.java
│ │ └── ThreadPoolDispatcher.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── reactor
│ └── app
│ └── ReactorTest.java
├── reader-writer-lock
├── README.md
├── etc
│ ├── reader-writer-lock.png
│ └── reader-writer-lock.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── reader
│ │ └── writer
│ │ └── lock
│ │ ├── App.java
│ │ ├── Reader.java
│ │ ├── ReaderWriterLock.java
│ │ └── Writer.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── reader
│ └── writer
│ └── lock
│ ├── AppTest.java
│ ├── ReaderAndWriterTest.java
│ ├── ReaderTest.java
│ ├── StdOutTest.java
│ └── WriterTest.java
├── repository
├── README.md
├── etc
│ ├── repository.png
│ └── repository.ucls
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── iluwatar
│ │ │ └── repository
│ │ │ ├── App.java
│ │ │ ├── AppConfig.java
│ │ │ ├── Person.java
│ │ │ ├── PersonRepository.java
│ │ │ └── PersonSpecifications.java
│ └── resources
│ │ ├── META-INF
│ │ └── persistence.xml
│ │ └── applicationContext.xml
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── repository
│ ├── AnnotationBasedRepositoryTest.java
│ ├── AppConfigTest.java
│ ├── AppTest.java
│ └── RepositoryTest.java
├── resource-acquisition-is-initialization
├── README.md
├── etc
│ ├── resource-acquisition-is-initialization.png
│ └── resource-acquisition-is-initialization.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── resource
│ │ └── acquisition
│ │ └── is
│ │ └── initialization
│ │ ├── App.java
│ │ ├── SlidingDoor.java
│ │ └── TreasureChest.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── resource
│ └── acquisition
│ └── is
│ └── initialization
│ ├── AppTest.java
│ ├── ClosableTest.java
│ └── StdOutTest.java
├── semaphore
├── README.md
├── etc
│ └── semaphore.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── semaphore
│ │ ├── App.java
│ │ ├── Customer.java
│ │ ├── Fruit.java
│ │ ├── FruitBowl.java
│ │ ├── FruitShop.java
│ │ ├── Lock.java
│ │ └── Semaphore.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── semaphore
│ ├── AppTest.java
│ ├── FruitBowlTest.java
│ └── SemaphoreTest.java
├── servant
├── README.md
├── etc
│ ├── servant-pattern.png
│ └── servant-pattern.ucls
├── pom.xml
└── src
│ ├── etc
│ ├── servant.jpg
│ ├── servant.svg
│ └── servant.xml
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── servant
│ │ ├── App.java
│ │ ├── King.java
│ │ ├── Queen.java
│ │ ├── Royalty.java
│ │ └── Servant.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── servant
│ ├── AppTest.java
│ ├── KingTest.java
│ ├── QueenTest.java
│ └── ServantTest.java
├── service-layer
├── README.md
├── bin
│ └── pom.xml
├── etc
│ ├── service-layer.png
│ └── service-layer.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── servicelayer
│ │ ├── app
│ │ └── App.java
│ │ ├── common
│ │ ├── BaseEntity.java
│ │ ├── Dao.java
│ │ └── DaoBaseImpl.java
│ │ ├── hibernate
│ │ └── HibernateUtil.java
│ │ ├── magic
│ │ ├── MagicService.java
│ │ └── MagicServiceImpl.java
│ │ ├── spell
│ │ ├── Spell.java
│ │ ├── SpellDao.java
│ │ └── SpellDaoImpl.java
│ │ ├── spellbook
│ │ ├── Spellbook.java
│ │ ├── SpellbookDao.java
│ │ └── SpellbookDaoImpl.java
│ │ └── wizard
│ │ ├── Wizard.java
│ │ ├── WizardDao.java
│ │ └── WizardDaoImpl.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── servicelayer
│ ├── app
│ └── AppTest.java
│ ├── common
│ └── BaseDaoTest.java
│ ├── magic
│ └── MagicServiceImplTest.java
│ ├── spell
│ └── SpellDaoImplTest.java
│ ├── spellbook
│ └── SpellbookDaoImplTest.java
│ └── wizard
│ └── WizardDaoImplTest.java
├── service-locator
├── README.md
├── etc
│ ├── service-locator.png
│ └── service-locator.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── servicelocator
│ │ ├── App.java
│ │ ├── InitContext.java
│ │ ├── Service.java
│ │ ├── ServiceCache.java
│ │ ├── ServiceImpl.java
│ │ └── ServiceLocator.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── servicelocator
│ ├── AppTest.java
│ └── ServiceLocatorTest.java
├── singleton
├── README.md
├── etc
│ ├── singleton.png
│ ├── singleton.ucls
│ └── singleton_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── singleton
│ │ ├── App.java
│ │ ├── EnumIvoryTower.java
│ │ ├── InitializingOnDemandHolderIdiom.java
│ │ ├── IvoryTower.java
│ │ ├── ThreadSafeDoubleCheckLocking.java
│ │ └── ThreadSafeLazyLoadedIvoryTower.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── singleton
│ ├── AppTest.java
│ ├── EnumIvoryTowerTest.java
│ ├── InitializingOnDemandHolderIdiomTest.java
│ ├── IvoryTowerTest.java
│ ├── SingletonTest.java
│ ├── ThreadSafeDoubleCheckLockingTest.java
│ └── ThreadSafeLazyLoadedIvoryTowerTest.java
├── specification
├── README.md
├── etc
│ ├── specification.png
│ └── specification.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── specification
│ │ ├── app
│ │ └── App.java
│ │ ├── creature
│ │ ├── AbstractCreature.java
│ │ ├── Creature.java
│ │ ├── Dragon.java
│ │ ├── Goblin.java
│ │ ├── KillerBee.java
│ │ ├── Octopus.java
│ │ ├── Shark.java
│ │ └── Troll.java
│ │ ├── property
│ │ ├── Color.java
│ │ ├── Movement.java
│ │ └── Size.java
│ │ └── selector
│ │ ├── ColorSelector.java
│ │ ├── MovementSelector.java
│ │ └── SizeSelector.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── specification
│ ├── app
│ └── AppTest.java
│ ├── creature
│ └── CreatureTest.java
│ └── selector
│ ├── ColorSelectorTest.java
│ ├── MovementSelectorTest.java
│ └── SizeSelectorTest.java
├── state
├── README.md
├── etc
│ ├── state.png
│ ├── state.ucls
│ └── state_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── state
│ │ ├── AngryState.java
│ │ ├── App.java
│ │ ├── Mammoth.java
│ │ ├── PeacefulState.java
│ │ └── State.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── state
│ ├── AppTest.java
│ └── MammothTest.java
├── step-builder
├── README.md
├── etc
│ ├── step-builder.png
│ └── step-builder.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── stepbuilder
│ │ ├── App.java
│ │ ├── Character.java
│ │ └── CharacterStepBuilder.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── stepbuilder
│ ├── AppTest.java
│ └── CharacterStepBuilderTest.java
├── strategy
├── README.md
├── etc
│ ├── strategy.png
│ ├── strategy.ucls
│ └── strategy_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── strategy
│ │ ├── App.java
│ │ ├── DragonSlayer.java
│ │ ├── DragonSlayingStrategy.java
│ │ ├── MeleeStrategy.java
│ │ ├── ProjectileStrategy.java
│ │ └── SpellStrategy.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── strategy
│ ├── AppTest.java
│ ├── DragonSlayerTest.java
│ └── DragonSlayingStrategyTest.java
├── template-method
├── README.md
├── etc
│ ├── template-method.png
│ ├── template-method.ucls
│ └── template-method_1.png
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── templatemethod
│ │ ├── App.java
│ │ ├── HalflingThief.java
│ │ ├── HitAndRunMethod.java
│ │ ├── StealingMethod.java
│ │ └── SubtleMethod.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── templatemethod
│ ├── AppTest.java
│ ├── HalflingThiefTest.java
│ ├── HitAndRunMethodTest.java
│ ├── StealingMethodTest.java
│ └── SubtleMethodTest.java
├── thread-pool
├── README.md
├── etc
│ ├── thread-pool.png
│ └── thread-pool.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── threadpool
│ │ ├── App.java
│ │ ├── CoffeeMakingTask.java
│ │ ├── PotatoPeelingTask.java
│ │ ├── Task.java
│ │ └── Worker.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── threadpool
│ ├── AppTest.java
│ ├── CoffeeMakingTaskTest.java
│ ├── PotatoPeelingTaskTest.java
│ ├── TaskTest.java
│ └── WorkerTest.java
├── tolerant-reader
├── README.md
├── etc
│ ├── tolerant-reader.png
│ └── tolerant-reader.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── tolerantreader
│ │ ├── App.java
│ │ ├── RainbowFish.java
│ │ ├── RainbowFishSerializer.java
│ │ └── RainbowFishV2.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── tolerantreader
│ ├── AppTest.java
│ ├── RainbowFishSerializerTest.java
│ ├── RainbowFishTest.java
│ └── RainbowFishV2Test.java
├── twin
├── .gitignore
├── README.md
├── etc
│ ├── twin.png
│ └── twin.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── twin
│ │ ├── App.java
│ │ ├── BallItem.java
│ │ ├── BallThread.java
│ │ └── GameItem.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── twin
│ ├── AppTest.java
│ ├── BallItemTest.java
│ ├── BallThreadTest.java
│ └── StdOutTest.java
├── update-ghpages.sh
├── value-object
├── README.md
├── etc
│ ├── value-object.png
│ └── value-object.ucls
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iluwatar
│ │ └── value
│ │ └── object
│ │ ├── App.java
│ │ └── HeroStat.java
│ └── test
│ └── java
│ └── com
│ └── iluwatar
│ └── value
│ └── object
│ ├── AppTest.java
│ └── HeroStatTest.java
└── visitor
├── README.md
├── etc
├── visitor.png
├── visitor.ucls
└── visitor_1.png
├── pom.xml
└── src
├── main
└── java
│ └── com
│ └── iluwatar
│ └── visitor
│ ├── App.java
│ ├── Commander.java
│ ├── CommanderVisitor.java
│ ├── Sergeant.java
│ ├── SergeantVisitor.java
│ ├── Soldier.java
│ ├── SoldierVisitor.java
│ ├── Unit.java
│ └── UnitVisitor.java
└── test
└── java
└── com
└── iluwatar
└── visitor
├── AppTest.java
├── CommanderTest.java
├── CommanderVisitorTest.java
├── SergeantTest.java
├── SergeantVisitorTest.java
├── SoldierTest.java
├── SoldierVisitorTest.java
├── StdOutTest.java
├── UnitTest.java
└── VisitorTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | .metadata
3 | .settings
4 | .classpath
5 | .project
6 | *.class
7 | # Package Files #
8 | *.jar
9 | *.war
10 | *.ear
11 | .idea
12 | *.iml
13 | *.swp
14 | datanucleus.log
15 | /bin/
16 | /bin/
17 | /bin/
18 |
19 | data-mapper/src/main/resources/log4j.xml
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk8
4 |
5 | env:
6 | global:
7 | - GH_REF: github.com/iluwatar/java-design-patterns.git
8 | - secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
9 |
10 | before_install:
11 | - export DISPLAY=:99.0
12 | - sh -e /etc/init.d/xvfb start
13 |
14 | after_success:
15 | - mvn clean test jacoco:report coveralls:report
16 | - bash update-ghpages.sh
17 |
18 | sudo: false # route the build to the container-based infrastructure for a faster build
19 |
--------------------------------------------------------------------------------
/CODE_COVERAGE.md:
--------------------------------------------------------------------------------
1 | # Code Coverage Report generation
2 |
3 | To generate the code coverage report, execute the following command:
4 | > mvn clean verify
5 |
6 | This will generate code coverage report in each of the modules. In order to view the same, open the following file in your browser.
7 | > target/site/jacoco/index.html
8 |
9 | Please note that the above folder is created under each of the modules. For example:
10 | * adapter/target/site/jacoco/index.html
11 | * busniess-delegate/target/site/jacoco/index.html
12 |
13 |
14 |
--------------------------------------------------------------------------------
/CONTRIBUTING.MD:
--------------------------------------------------------------------------------
1 | This is great you have something to contribute!
2 |
3 | Before going any further please read the [wiki](https://github.com/iluwatar/java-design-patterns/wiki)
4 | with conventions and rules we used for this project.
5 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2016 Ilkka Seppälä
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/abstract-factory/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/abstract-factory/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Abstract Factory
4 | folder: abstract-factory
5 | permalink: /patterns/abstract-factory/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Intermediate
11 | ---
12 |
13 | ## Also known as
14 | Kit
15 |
16 | ## Intent
17 | Provide an interface for creating families of related or dependent
18 | objects without specifying their concrete classes.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Abstract Factory pattern when
24 |
25 | * a system should be independent of how its products are created, composed and represented
26 | * a system should be configured with one of multiple families of products
27 | * a family of related product objects is designed to be used together, and you need to enforce this constraint
28 | * you want to provide a class library of products, and you want to reveal just their interfaces, not their implementations
29 |
30 | ## Real world examples
31 |
32 | * [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)
33 |
34 | ## Credits
35 |
36 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
37 |
--------------------------------------------------------------------------------
/abstract-factory/etc/abstract-factory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/abstract-factory/etc/abstract-factory.png
--------------------------------------------------------------------------------
/abstract-factory/etc/abstract-factory_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/abstract-factory/etc/abstract-factory_1.png
--------------------------------------------------------------------------------
/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.abstractfactory;
24 |
25 | /**
26 | *
27 | * Army interface
28 | *
29 | */
30 | public interface Army {
31 |
32 | String getDescription();
33 | }
34 |
--------------------------------------------------------------------------------
/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.abstractfactory;
24 |
25 | /**
26 | *
27 | * Castle interface
28 | *
29 | */
30 | public interface Castle {
31 |
32 | String getDescription();
33 | }
34 |
--------------------------------------------------------------------------------
/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.abstractfactory;
24 |
25 | /**
26 | *
27 | * King interface
28 | *
29 | */
30 | public interface King {
31 |
32 | String getDescription();
33 | }
34 |
--------------------------------------------------------------------------------
/adapter/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Adapter
4 | folder: adapter
5 | permalink: /patterns/adapter/
6 | categories: Structural
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Beginner
11 | ---
12 |
13 | ## Also known as
14 | Wrapper
15 |
16 | ## Intent
17 | Convert the interface of a class into another interface the clients
18 | expect. Adapter lets classes work together that couldn't otherwise because of
19 | incompatible interfaces.
20 |
21 | 
22 |
23 | ## Applicability
24 | Use the Adapter pattern when
25 |
26 | * you want to use an existing class, and its interface does not match the one you need
27 | * you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces
28 | * you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class.
29 |
30 | ## Real world examples
31 |
32 | * [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29)
33 |
34 | ## Credits
35 |
36 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
37 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
38 |
--------------------------------------------------------------------------------
/adapter/etc/adapter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/adapter/etc/adapter.png
--------------------------------------------------------------------------------
/adapter/src/main/java/com/iluwatar/adapter/BattleShip.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.adapter;
24 |
25 | /**
26 | * The interface expected by the client.
27 | * A Battleship can fire and move.
28 | *
29 | */
30 | public interface BattleShip {
31 |
32 | void fire();
33 |
34 | void move();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/api-gateway/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: API Gateway
4 | folder: api-gateway
5 | permalink: /patterns/api-gateway/
6 | categories: Architectural
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - Spring
11 | ---
12 |
13 | ## Intent
14 |
15 | Aggregate calls to microservices in a single location: the API Gateway. The user makes a single
16 | call to the API Gateway, and the API Gateway then calls each relevant microservice.
17 |
18 | 
19 |
20 | ## Applicability
21 |
22 | Use the API Gateway pattern when
23 |
24 | * you're also using the Microservices pattern and need a single point of aggregation for your
25 | microservice calls
26 |
27 | ## Credits
28 |
29 | * [microservices.io - API Gateway](http://microservices.io/patterns/apigateway.html)
30 | * [NGINX - Building Microservices: Using an API Gateway](https://www.nginx.com/blog/building-microservices-using-an-api-gateway/)
31 |
--------------------------------------------------------------------------------
/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClient.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.api.gateway;
24 |
25 | /**
26 | * An interface used to communicate with the Image microservice
27 | */
28 | public interface ImageClient {
29 | String getImagePath();
30 | }
31 |
--------------------------------------------------------------------------------
/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/PriceClient.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.api.gateway;
24 |
25 | /**
26 | * An interface used to communicate with the Price microservice
27 | */
28 | public interface PriceClient {
29 | String getPrice();
30 | }
31 |
--------------------------------------------------------------------------------
/api-gateway/api-gateway-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # The MIT License
3 | # Copyright (c) 2014 Ilkka Seppälä
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 | #
23 |
24 | server.port=50004
--------------------------------------------------------------------------------
/api-gateway/etc/api-gateway.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/api-gateway/etc/api-gateway.png
--------------------------------------------------------------------------------
/api-gateway/image-microservice/etc/image-microservice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/api-gateway/image-microservice/etc/image-microservice.png
--------------------------------------------------------------------------------
/api-gateway/image-microservice/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # The MIT License
3 | # Copyright (c) 2014 Ilkka Seppälä
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 | #
23 |
24 | server.port=50005
--------------------------------------------------------------------------------
/api-gateway/price-microservice/etc/price-microservice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/api-gateway/price-microservice/etc/price-microservice.png
--------------------------------------------------------------------------------
/api-gateway/price-microservice/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # The MIT License
3 | # Copyright (c) 2014 Ilkka Seppälä
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 | #
23 |
24 | server.port=50006
--------------------------------------------------------------------------------
/async-method-invocation/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Async Method Invocation
4 | folder: async-method-invocation
5 | permalink: /patterns/async-method-invocation/
6 | categories: Concurrency
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - Functional
11 | ---
12 |
13 | ## Intent
14 | Asynchronous method invocation is pattern where the calling thread
15 | is not blocked while waiting results of tasks. The pattern provides parallel
16 | processing of multiple independent tasks and retrieving the results via
17 | callbacks or waiting until everything is done.
18 |
19 | 
20 |
21 | ## Applicability
22 | Use async method invocation pattern when
23 |
24 | * you have multiple independent tasks that can run in parallel
25 | * you need to improve the performance of a group of sequential tasks
26 | * you have limited amount of processing capacity or long running tasks and the
27 | caller should not wait the tasks to be ready
28 |
29 | ## Real world examples
30 |
31 | * [FutureTask](http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/FutureTask.html), [CompletableFuture](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html) and [ExecutorService](http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html) (Java)
32 | * [Task-based Asynchronous Pattern](https://msdn.microsoft.com/en-us/library/hh873175.aspx) (.NET)
33 |
--------------------------------------------------------------------------------
/async-method-invocation/etc/async-method-invocation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/async-method-invocation/etc/async-method-invocation.png
--------------------------------------------------------------------------------
/bridge/etc/bridge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/bridge/etc/bridge.png
--------------------------------------------------------------------------------
/bridge/src/main/java/com/iluwatar/bridge/BlindingMagicWeaponImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.bridge;
24 |
25 | /**
26 | *
27 | * BlindingMagicWeaponImpl
28 | *
29 | */
30 | public abstract class BlindingMagicWeaponImpl extends MagicWeaponImpl {
31 |
32 | public abstract void blindImp();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/bridge/src/main/java/com/iluwatar/bridge/FlyingMagicWeaponImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.bridge;
24 |
25 | /**
26 | *
27 | * FlyingMagicWeaponImpl
28 | *
29 | */
30 | public abstract class FlyingMagicWeaponImpl extends MagicWeaponImpl {
31 |
32 | public abstract void flyImp();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/bridge/src/main/java/com/iluwatar/bridge/SoulEatingMagicWeaponImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.bridge;
24 |
25 | /**
26 | *
27 | * SoulEatingMagicWeaponImpl
28 | *
29 | */
30 | public abstract class SoulEatingMagicWeaponImpl extends MagicWeaponImpl {
31 |
32 | public abstract void eatSoulImp();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/builder/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/builder/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Builder
4 | folder: builder
5 | permalink: /patterns/builder/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Intermediate
11 | ---
12 |
13 | ## Intent
14 | Separate the construction of a complex object from its
15 | representation so that the same construction process can create different
16 | representations.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Builder pattern when
22 |
23 | * the algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled
24 | * the construction process must allow different representations for the object that's constructed
25 |
26 | ## Real world examples
27 |
28 | * [java.lang.StringBuilder](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html)
29 | * [Apache Camel builders](https://github.com/apache/camel/tree/0e195428ee04531be27a0b659005e3aa8d159d23/camel-core/src/main/java/org/apache/camel/builder)
30 |
31 | ## Credits
32 |
33 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
34 | * [Effective Java (2nd Edition)](http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683)
35 |
--------------------------------------------------------------------------------
/builder/etc/builder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/builder/etc/builder.png
--------------------------------------------------------------------------------
/builder/etc/builder_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/builder/etc/builder_1.png
--------------------------------------------------------------------------------
/business-delegate/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Business Delegate
4 | folder: business-delegate
5 | permalink: /patterns/business-delegate/
6 | categories: Business Tier
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | The Business Delegate pattern adds an abstraction layer between
14 | presentation and business tiers. By using the pattern we gain loose coupling
15 | between the tiers and encapsulate knowledge about how to locate, connect to,
16 | and interact with the business objects that make up the application.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Business Delegate pattern when
22 |
23 | * you want loose coupling between presentation and business tiers
24 | * you want to orchestrate calls to multiple business services
25 | * you want to encapsulate service lookups and service calls
26 |
27 | ## Credits
28 |
29 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
30 |
--------------------------------------------------------------------------------
/business-delegate/etc/business-delegate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/business-delegate/etc/business-delegate.png
--------------------------------------------------------------------------------
/business-delegate/src/main/java/com/iluwatar/business/delegate/BusinessService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.business.delegate;
24 |
25 | /**
26 | *
27 | * Interface for service implementations
28 | *
29 | */
30 | public interface BusinessService {
31 |
32 | void doProcessing();
33 | }
34 |
--------------------------------------------------------------------------------
/business-delegate/src/main/java/com/iluwatar/business/delegate/ServiceType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.business.delegate;
24 |
25 | /**
26 | *
27 | * Enumeration for service types
28 | *
29 | */
30 | public enum ServiceType {
31 |
32 | EJB, JMS;
33 | }
34 |
--------------------------------------------------------------------------------
/caching/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/caching/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Caching
4 | folder: caching
5 | permalink: /patterns/caching/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - Performance
11 | ---
12 |
13 | ## Intent
14 | To avoid expensive re-acquisition of resources by not releasing
15 | the resources immediately after their use. The resources retain their identity, are kept in some
16 | fast-access storage, and are re-used to avoid having to acquire them again.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Caching pattern(s) when
22 |
23 | * Repetitious acquisition, initialization, and release of the same resource causes unnecessary performance overhead.
24 |
25 | ## Credits
26 |
27 | * [Write-through, write-around, write-back: Cache explained](http://www.computerweekly.com/feature/Write-through-write-around-write-back-Cache-explained)
28 | * [Read-Through, Write-Through, Write-Behind, and Refresh-Ahead Caching](https://docs.oracle.com/cd/E15357_01/coh.360/e15723/cache_rtwtwbra.htm#COHDG5177)
29 |
--------------------------------------------------------------------------------
/caching/etc/caching.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/caching/etc/caching.png
--------------------------------------------------------------------------------
/callback/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Callback
4 | folder: callback
5 | permalink: /patterns/callback/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Functional
11 | - Idiom
12 | ---
13 |
14 | ## Intent
15 | Callback is a piece of executable code that is passed as an
16 | argument to other code, which is expected to call back (execute) the argument
17 | at some convenient time.
18 |
19 | 
20 |
21 | ## Applicability
22 | Use the Callback pattern when
23 |
24 | * when some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity.
25 |
26 | ## Real world examples
27 |
28 | * [CyclicBarrier](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CyclicBarrier.html#CyclicBarrier%28int,%20java.lang.Runnable%29) constructor can accept callback that will be triggered every time when barrier is tripped.
29 |
--------------------------------------------------------------------------------
/callback/etc/callback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/callback/etc/callback.png
--------------------------------------------------------------------------------
/callback/src/main/java/com/iluwatar/callback/Callback.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.callback;
24 |
25 | /**
26 | *
27 | * Callback interface
28 | *
29 | */
30 | public interface Callback {
31 |
32 | void call();
33 | }
34 |
--------------------------------------------------------------------------------
/chain/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Chain of responsibility
4 | folder: chain
5 | permalink: /patterns/chain/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Intermediate
11 | ---
12 |
13 | ## Intent
14 | Avoid coupling the sender of a request to its receiver by giving
15 | more than one object a chance to handle the request. Chain the receiving
16 | objects and pass the request along the chain until an object handles it.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use Chain of Responsibility when
22 |
23 | * more than one object may handle a request, and the handler isn't known a priori. The handler should be ascertained automatically
24 | * you want to issue a request to one of several objects without specifying the receiver explicitly
25 | * the set of objects that can handle a request should be specified dynamically
26 |
27 | ## Real world examples
28 |
29 | * [java.util.logging.Logger#log()](http://docs.oracle.com/javase/8/docs/api/java/util/logging/Logger.html#log%28java.util.logging.Level,%20java.lang.String%29)
30 | * [Apache Commons Chain](https://commons.apache.org/proper/commons-chain/index.html)
31 |
32 | ## Credits
33 |
34 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
35 |
--------------------------------------------------------------------------------
/chain/etc/chain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/chain/etc/chain.png
--------------------------------------------------------------------------------
/chain/etc/chain_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/chain/etc/chain_1.png
--------------------------------------------------------------------------------
/chain/src/main/java/com/iluwatar/chain/RequestType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.chain;
24 |
25 | /**
26 | *
27 | * RequestType enumeration
28 | *
29 | */
30 | public enum RequestType {
31 |
32 | DEFEND_CASTLE, TORTURE_PRISONER, COLLECT_TAX
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/chain/src/test/java/com/iluwatar/chain/AppTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.chain;
24 |
25 | import org.junit.Test;
26 |
27 | /**
28 | *
29 | * Application test
30 | *
31 | */
32 | public class AppTest {
33 |
34 | @Test
35 | public void test() {
36 | String[] args = {};
37 | App.main(args);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/command/etc/command.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/command/etc/command.png
--------------------------------------------------------------------------------
/composite/etc/composite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/composite/etc/composite.png
--------------------------------------------------------------------------------
/composite/etc/composite_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/composite/etc/composite_1.png
--------------------------------------------------------------------------------
/dao/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Data Access Object
4 | folder: dao
5 | permalink: /patterns/dao/
6 | categories: Persistence Tier
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | Object provides an abstract interface to some type of database or
14 | other persistence mechanism.
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Data Access Object in any of the following situations
20 |
21 | * when you want to consolidate how the data layer is accessed
22 | * when you want to avoid writing multiple data retrieval/persistence layers
23 |
24 | ## Credits
25 |
26 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
27 |
--------------------------------------------------------------------------------
/dao/etc/dao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/dao/etc/dao.png
--------------------------------------------------------------------------------
/data-mapper/etc/data-mapper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/data-mapper/etc/data-mapper.png
--------------------------------------------------------------------------------
/data-mapper/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Data Mapper
4 | folder: data-mapper
5 | permalink: /patterns/data-mapper/
6 | categories: Persistence Tier
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | A layer of mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself
14 |
15 | 
16 |
17 | ## Applicability
18 | Use the Data Mapper in any of the following situations
19 |
20 | * when you want to decouple data objects from DB access layer
21 | * when you want to write multiple data retrieval/persistence implementations
22 |
23 | ## Credits
24 |
25 | * [Data Mapper](http://richard.jp.leguen.ca/tutoring/soen343-f2010/tutorials/implementing-data-mapper/)
26 |
--------------------------------------------------------------------------------
/decorator/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Decorator
4 | folder: decorator
5 | permalink: /patterns/decorator/
6 | categories: Structural
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Beginner
11 | ---
12 |
13 | ## Also known as
14 | Wrapper
15 |
16 | ## Intent
17 | Attach additional responsibilities to an object dynamically.
18 | Decorators provide a flexible alternative to subclassing for extending
19 | functionality.
20 |
21 | 
22 |
23 | ## Applicability
24 | Use Decorator
25 |
26 | * to add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects
27 | * for responsibilities that can be withdrawn
28 | * when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing
29 |
30 | ## Credits
31 |
32 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
33 | * [Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions](http://www.amazon.com/Functional-Programming-Java-Harnessing-Expressions/dp/1937785467/ref=sr_1_1)
34 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
35 |
--------------------------------------------------------------------------------
/decorator/etc/decorator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/decorator/etc/decorator.png
--------------------------------------------------------------------------------
/delegation/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Delegation
4 | folder: delegation
5 | permalink: /patterns/delegation/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Also known as
13 | Proxy Pattern
14 |
15 | ## Intent
16 | It is a technique where an object expresses certain behavior to the outside but in
17 | reality delegates responsibility for implementing that behaviour to an associated object.
18 |
19 | 
20 |
21 | ## Applicability
22 | Use the Delegate pattern in order to achieve the following
23 |
24 | * Reduce the coupling of methods to their class
25 | * Components that behave identically, but realize that this situation can change in the future.
26 |
27 | ## Credits
28 |
29 | * [Delegate Pattern: Wikipedia ](https://en.wikipedia.org/wiki/Delegation_pattern)
30 | * [Proxy Pattern: Wikipedia ](https://en.wikipedia.org/wiki/Proxy_pattern)
31 |
--------------------------------------------------------------------------------
/delegation/etc/delegation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/delegation/etc/delegation.png
--------------------------------------------------------------------------------
/delegation/src/test/java/com/iluwatar/delegation/simple/AppTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.delegation.simple;
24 |
25 | import org.junit.Test;
26 |
27 | public class AppTest {
28 |
29 | @Test
30 | public void test() {
31 | String[] args = {};
32 | App.main(args);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/dependency-injection/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Dependency Injection
4 | folder: dependency-injection
5 | permalink: /patterns/dependency-injection/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | Dependency Injection is a software design pattern in which one or
14 | more dependencies (or services) are injected, or passed by reference, into a
15 | dependent object (or client) and are made part of the client's state. The
16 | pattern separates the creation of a client's dependencies from its own
17 | behavior, which allows program designs to be loosely coupled and to follow the
18 | inversion of control and single responsibility principles.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Dependency Injection pattern when
24 |
25 | * when you need to remove knowledge of concrete implementation from object
26 | * to enable unit testing of classes in isolation using mock objects or stubs
27 |
--------------------------------------------------------------------------------
/dependency-injection/etc/dependency-injection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/dependency-injection/etc/dependency-injection.png
--------------------------------------------------------------------------------
/dependency-injection/src/main/java/com/iluwatar/dependency/injection/OldTobyTobacco.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.dependency.injection;
24 |
25 | /**
26 | *
27 | * OldTobyTobacco concrete {@link Tobacco} implementation
28 | *
29 | */
30 | public class OldTobyTobacco extends Tobacco {
31 | }
32 |
--------------------------------------------------------------------------------
/dependency-injection/src/main/java/com/iluwatar/dependency/injection/RivendellTobacco.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.dependency.injection;
24 |
25 | /**
26 | *
27 | * RivendellTobacco concrete {@link Tobacco} implementation
28 | *
29 | */
30 | public class RivendellTobacco extends Tobacco {
31 | }
32 |
--------------------------------------------------------------------------------
/dependency-injection/src/main/java/com/iluwatar/dependency/injection/SecondBreakfastTobacco.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.dependency.injection;
24 |
25 | /**
26 | *
27 | * SecondBreakfastTobacco concrete {@link Tobacco} implementation
28 | *
29 | */
30 | public class SecondBreakfastTobacco extends Tobacco {
31 | }
32 |
--------------------------------------------------------------------------------
/dependency-injection/src/main/java/com/iluwatar/dependency/injection/Wizard.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.dependency.injection;
24 |
25 | /**
26 | *
27 | * Wizard interface
28 | *
29 | */
30 | public interface Wizard {
31 |
32 | void smoke();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/double-checked-locking/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Double Checked Locking
4 | folder: double-checked-locking
5 | permalink: /patterns/double-checked-locking/
6 | categories: Concurrency
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Idiom
11 | ---
12 |
13 | ## Intent
14 | Reduce the overhead of acquiring a lock by first testing the
15 | locking criterion (the "lock hint") without actually acquiring the lock. Only
16 | if the locking criterion check indicates that locking is required does the
17 | actual locking logic proceed.
18 |
19 | 
20 |
21 | ## Applicability
22 | Use the Double Checked Locking pattern when
23 |
24 | * there is a concurrent access in object creation, e.g. singleton, where you want to create single instance of the same class and checking if it's null or not maybe not be enough when there are two or more threads that checks if instance is null or not.
25 | * there is a concurrent access on a method where method's behaviour changes according to the some constraints and these constraint change within this method.
26 |
--------------------------------------------------------------------------------
/double-checked-locking/etc/double-checked-locking.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/double-checked-locking/etc/double-checked-locking.png
--------------------------------------------------------------------------------
/double-checked-locking/etc/double_checked_locking_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/double-checked-locking/etc/double_checked_locking_1.png
--------------------------------------------------------------------------------
/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Item.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.doublechecked.locking;
24 |
25 | /**
26 | *
27 | * Item
28 | *
29 | */
30 | public class Item {
31 | }
32 |
--------------------------------------------------------------------------------
/double-dispatch/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Double Dispatch
4 | folder: double-dispatch
5 | permalink: /patterns/double-dispatch/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - Idiom
11 | ---
12 |
13 | ## Intent
14 | Double Dispatch pattern is a way to create maintainable dynamic
15 | behavior based on receiver and parameter types.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Double Dispatch pattern when
21 |
22 | * the dynamic behavior is not defined only based on receiving object's type but also on the receiving method's parameter type.
23 |
24 | ## Real world examples
25 |
26 | * [ObjectOutputStream](https://docs.oracle.com/javase/8/docs/api/java/io/ObjectOutputStream.html)
27 |
--------------------------------------------------------------------------------
/double-dispatch/etc/double-dispatch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/double-dispatch/etc/double-dispatch.png
--------------------------------------------------------------------------------
/event-aggregator/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Event Aggregator
4 | folder: event-aggregator
5 | permalink: /patterns/event-aggregator/
6 | categories: Structural
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | A system with lots of objects can lead to complexities when a
14 | client wants to subscribe to events. The client has to find and register for
15 | each object individually, if each object has multiple events then each event
16 | requires a separate subscription. An Event Aggregator acts as a single source
17 | of events for many objects. It registers for all the events of the many objects
18 | allowing clients to register with just the aggregator.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Event Aggregator pattern when
24 |
25 | * Event Aggregator is a good choice when you have lots of objects that are
26 | potential event sources. Rather than have the observer deal with registering
27 | with them all, you can centralize the registration logic to the Event
28 | Aggregator. As well as simplifying registration, a Event Aggregator also
29 | simplifies the memory management issues in using observers.
30 |
31 | ## Credits
32 |
33 | * [Martin Fowler - Event Aggregator](http://martinfowler.com/eaaDev/EventAggregator.html)
34 |
--------------------------------------------------------------------------------
/event-aggregator/etc/classes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/event-aggregator/etc/classes.png
--------------------------------------------------------------------------------
/event-aggregator/src/main/java/com/iluwatar/event/aggregator/EventObserver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.event.aggregator;
24 |
25 | /**
26 | *
27 | * Observers of events implement this interface.
28 | *
29 | */
30 | public interface EventObserver {
31 |
32 | void onEvent(Event e);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/event-driven-architecture/etc/eda.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/event-driven-architecture/etc/eda.png
--------------------------------------------------------------------------------
/exclude-pmd.properties:
--------------------------------------------------------------------------------
1 | #
2 | # The MIT License
3 | # Copyright (c) 2014 Ilkka Seppälä
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 | #
23 |
24 | com.iluwatar.servicelayer.common.BaseEntity=UnusedPrivateField
25 | com.iluwatar.doublechecked.locking.App=EmptyStatementNotInLoop,EmptyWhileStmt
26 | com.iluwatar.doublechecked.locking.InventoryTest=EmptyStatementNotInLoop,EmptyWhileStmt
27 |
--------------------------------------------------------------------------------
/execute-around/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Execute Around
4 | folder: execute-around
5 | permalink: /patterns/execute-around/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Idiom
11 | ---
12 |
13 | ## Intent
14 | Execute Around idiom frees the user from certain actions that
15 | should always be executed before and after the business method. A good example
16 | of this is resource allocation and deallocation leaving the user to specify
17 | only what to do with the resource.
18 |
19 | 
20 |
21 | ## Applicability
22 | Use the Execute Around idiom when
23 |
24 | * you use an API that requires methods to be called in pairs such as open/close or allocate/deallocate.
25 |
26 | ## Credits
27 | * [Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions](http://www.amazon.com/Functional-Programming-Java-Harnessing-Expressions/dp/1937785467/ref=sr_1_1)
28 |
--------------------------------------------------------------------------------
/execute-around/etc/execute-around.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/execute-around/etc/execute-around.png
--------------------------------------------------------------------------------
/facade/etc/facade.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/facade/etc/facade.png
--------------------------------------------------------------------------------
/facade/etc/facade_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/facade/etc/facade_1.png
--------------------------------------------------------------------------------
/factory-kit/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Factory Kit
4 | folder: factory-kit
5 | permalink: /patterns/factory-kit/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Functional
11 | ---
12 |
13 | ## Intent
14 | Define a factory of immutable content with separated builder and factory interfaces.
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Factory Kit pattern when
20 |
21 | * a class can't anticipate the class of objects it must create
22 | * you just want a new instance of a custom builder instead of the global one
23 | * you explicitly want to define types of objects, that factory can build
24 | * you want a separated builder and creator interface
25 |
26 | ## Credits
27 |
28 | * [Design Pattern Reloaded by Remi Forax: ](https://www.youtube.com/watch?v=-k2X7guaArU)
29 |
--------------------------------------------------------------------------------
/factory-kit/etc/factory-kit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/factory-kit/etc/factory-kit.png
--------------------------------------------------------------------------------
/factory-kit/etc/factory-kit.ucls:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/factory-kit/src/main/java/com/iluwatar/factorykit/Axe.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.factorykit;
24 |
25 | public class Axe implements Weapon {
26 | @Override
27 | public String toString() {
28 | return "Axe";
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/factory-kit/src/main/java/com/iluwatar/factorykit/Bow.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.factorykit;
24 |
25 | public class Bow implements Weapon {
26 | @Override
27 | public String toString() {
28 | return "Bow";
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/factory-kit/src/main/java/com/iluwatar/factorykit/Spear.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.factorykit;
24 |
25 | public class Spear implements Weapon {
26 | @Override
27 | public String toString() {
28 | return "Spear";
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/factory-kit/src/main/java/com/iluwatar/factorykit/Sword.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.factorykit;
24 |
25 | public class Sword implements Weapon {
26 | @Override
27 | public String toString() {
28 | return "Sword";
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/factory-kit/src/main/java/com/iluwatar/factorykit/Weapon.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.factorykit;
24 |
25 | /**
26 | * Interface representing weapon.
27 | */
28 | public interface Weapon {
29 | }
30 |
--------------------------------------------------------------------------------
/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.factorykit;
24 |
25 | /**
26 | * Enumerates {@link Weapon} types
27 | */
28 | public enum WeaponType {
29 | SWORD, AXE, BOW, SPEAR
30 | }
31 |
--------------------------------------------------------------------------------
/factory-method/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/factory-method/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Factory Method
4 | folder: factory-method
5 | permalink: /patterns/factory-method/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Gang Of Four
11 | ---
12 |
13 | ## Also known as
14 | Virtual Constructor
15 |
16 | ## Intent
17 | Define an interface for creating an object, but let subclasses
18 | decide which class to instantiate. Factory Method lets a class defer
19 | instantiation to subclasses.
20 |
21 | 
22 |
23 | ## Applicability
24 | Use the Factory Method pattern when
25 |
26 | * a class can't anticipate the class of objects it must create
27 | * a class wants its subclasses to specify the objects it creates
28 | * classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate
29 |
30 | ## Credits
31 |
32 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
33 |
--------------------------------------------------------------------------------
/factory-method/etc/factory-method.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/factory-method/etc/factory-method.png
--------------------------------------------------------------------------------
/factory-method/etc/factory-method_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/factory-method/etc/factory-method_1.png
--------------------------------------------------------------------------------
/factory-method/src/main/java/com/iluwatar/factory/method/Blacksmith.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.factory.method;
24 |
25 | /**
26 | *
27 | * The interface containing method for producing objects.
28 | *
29 | */
30 | public interface Blacksmith {
31 |
32 | Weapon manufactureWeapon(WeaponType weaponType);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/factory-method/src/main/java/com/iluwatar/factory/method/Weapon.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.factory.method;
24 |
25 | /**
26 | * Weapon interface.
27 | */
28 | public interface Weapon {
29 |
30 | WeaponType getWeaponType();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/feature-toggle/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Feature Toggle
4 | folder: feature-toggle
5 | permalink: /patterns/feature-toggle/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Also known as
13 | Feature Flag
14 |
15 | ## Intent
16 | Used to switch code execution paths based on properties or groupings. Allowing new features to be released, tested
17 | and rolled out. Allowing switching back to the older feature quickly if needed. It should be noted that this pattern,
18 | can easily introduce code complexity. There is also cause for concern that the old feature that the toggle is eventually
19 | going to phase out is never removed, causing redundant code smells and increased maintainability.
20 |
21 | 
22 |
23 | ## Applicability
24 | Use the Feature Toogle pattern when
25 |
26 | * Giving different features to different users.
27 | * Rolling out a new feature incrementally.
28 | * Switching between development and production environments.
29 |
30 | ## Credits
31 |
32 | * [Martin Fowler 29 October 2010 (2010-10-29).](http://martinfowler.com/bliki/FeatureToggle.html)
--------------------------------------------------------------------------------
/feature-toggle/etc/feature-toggle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/feature-toggle/etc/feature-toggle.png
--------------------------------------------------------------------------------
/fluentinterface/etc/fluentinterface.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/fluentinterface/etc/fluentinterface.png
--------------------------------------------------------------------------------
/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.fluentinterface.app;
24 |
25 | import org.junit.Test;
26 |
27 | public class AppTest {
28 |
29 | @Test
30 | public void test() {
31 | String[] args = {};
32 | App.main(args);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/flux/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Flux
4 | folder: flux
5 | permalink: /patterns/flux/
6 | categories: Presentation Tier
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | Flux eschews MVC in favor of a unidirectional data flow. When a
14 | user interacts with a view, the view propagates an action through a central
15 | dispatcher, to the various stores that hold the application's data and business
16 | logic, which updates all of the views that are affected.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Flux pattern when
22 |
23 | * you want to focus on creating explicit and understandable update paths for your application's data, which makes tracing changes during development simpler and makes bugs easier to track down and fix.
24 |
25 | ## Credits
26 |
27 | * [Flux - Application architecture for building user interfaces](http://facebook.github.io/flux/)
28 |
--------------------------------------------------------------------------------
/flux/etc/flux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/flux/etc/flux.png
--------------------------------------------------------------------------------
/flux/src/main/java/com/iluwatar/flux/action/ActionType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.flux.action;
24 |
25 | /**
26 | *
27 | * Types of actions.
28 | *
29 | */
30 | public enum ActionType {
31 |
32 | MENU_ITEM_SELECTED, CONTENT_CHANGED;
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/flyweight/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Flyweight
4 | folder: flyweight
5 | permalink: /patterns/flyweight/
6 | categories: Structural
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Intermediate
11 | - Performance
12 | ---
13 |
14 | ## Intent
15 | Use sharing to support large numbers of fine-grained objects
16 | efficiently.
17 |
18 | 
19 |
20 | ## Applicability
21 | The Flyweight pattern's effectiveness depends heavily on how
22 | and where it's used. Apply the Flyweight pattern when all of the following are
23 | true
24 |
25 | * an application uses a large number of objects
26 | * storage costs are high because of the sheer quantity of objects
27 | * most object state can be made extrinsic
28 | * many groups of objects may be replaced by relatively few shared objects once extrinsic state is removed
29 | * the application doesn't depend on object identity. Since flyweight objects may be shared, identity tests will return true for conceptually distinct objects.
30 |
31 | ## Real world examples
32 |
33 | * [java.lang.Integer#valueOf(int)](http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#valueOf%28int%29)
34 |
35 | ## Credits
36 |
37 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
38 |
--------------------------------------------------------------------------------
/flyweight/etc/flyweight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/flyweight/etc/flyweight.png
--------------------------------------------------------------------------------
/flyweight/etc/flyweight_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/flyweight/etc/flyweight_1.png
--------------------------------------------------------------------------------
/flyweight/src/main/java/com/iluwatar/flyweight/Potion.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.flyweight;
24 |
25 | /**
26 | *
27 | * Interface for Potions.
28 | *
29 | */
30 | public interface Potion {
31 |
32 | void drink();
33 | }
34 |
--------------------------------------------------------------------------------
/flyweight/src/main/java/com/iluwatar/flyweight/PotionType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.flyweight;
24 |
25 | /**
26 | *
27 | * Enumeration for potion types.
28 | *
29 | */
30 | public enum PotionType {
31 |
32 | HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON
33 | }
34 |
--------------------------------------------------------------------------------
/front-controller/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Front Controller
4 | folder: front-controller
5 | permalink: /patterns/front-controller/
6 | categories: Presentation Tier
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | Introduce a common handler for all requests for a web site. This
14 | way we can encapsulate common functionality such as security,
15 | internationalization, routing and logging in a single place.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Front Controller pattern when
21 |
22 | * you want to encapsulate common request handling functionality in single place
23 | * you want to implements dynamic request handling i.e. change routing without modifying code
24 | * make web server configuration portable, you only need to register the handler web server specific way
25 |
26 | ## Real world examples
27 |
28 | * [Apache Struts](https://struts.apache.org/)
29 |
30 | ## Credits
31 |
32 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
33 | * [Presentation Tier Patterns](http://www.javagyan.com/tutorials/corej2eepatterns/presentation-tier-patterns)
34 | * [Patterns of Enterprise Application Architecture](http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420)
35 |
--------------------------------------------------------------------------------
/front-controller/etc/front-controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/front-controller/etc/front-controller.png
--------------------------------------------------------------------------------
/front-controller/src/main/java/com/iluwatar/front/controller/Command.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.front.controller;
24 |
25 | /**
26 | *
27 | * Commands are the intermediary between requests and views.
28 | *
29 | */
30 | public interface Command {
31 |
32 | void process();
33 | }
34 |
--------------------------------------------------------------------------------
/front-controller/src/main/java/com/iluwatar/front/controller/View.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.front.controller;
24 |
25 | /**
26 | *
27 | * Views are the representations rendered for the user.
28 | *
29 | */
30 | public interface View {
31 |
32 | void display();
33 | }
34 |
--------------------------------------------------------------------------------
/half-sync-half-async/etc/half-sync-half-async.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/half-sync-half-async/etc/half-sync-half-async.png
--------------------------------------------------------------------------------
/hexagonal/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Hexagonal Architecture
4 | folder: hexagonal
5 | permalink: /patterns/hexagonal/
6 | categories: Architectural
7 | tags:
8 | - Java
9 | - Difficulty-Expert
10 | ---
11 |
12 | ## Also known as
13 | * Ports and Adapters
14 | * Clean Architecture
15 | * Onion Architecture
16 |
17 | ## Intent
18 | Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use Hexagonal Architecture pattern when
24 |
25 | * it is important that the application is fully testable
26 | * you use Domain Driven Design methodology and/or Microservices architectural style
27 |
28 | ## Real world examples
29 |
30 | * [Apache Isis](https://isis.apache.org/)
31 |
32 | ## Credits
33 |
34 | * [Alistair Cockburn - Hexagonal Architecture](http://alistair.cockburn.us/Hexagonal+architecture)
35 |
--------------------------------------------------------------------------------
/hexagonal/etc/hexagonal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/hexagonal/etc/hexagonal.png
--------------------------------------------------------------------------------
/intercepting-filter/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Intercepting Filter
4 | folder: intercepting-filter
5 | permalink: /patterns/intercepting-filter/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | Provide pluggable filters to conduct necessary pre-processing and
14 | post-processing to requests from a client to a target
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Intercepting Filter pattern when
20 |
21 | * a system uses pre-processing or post-processing requests
22 | * a system should do the authentication/ authorization/ logging or tracking of request and then pass the requests to corresponding handlers
23 | * you want a modular approach to configuring pre-processing and post-processing schemes
24 |
25 | ## Real world examples
26 |
27 | * [Struts 2 - Interceptors](https://struts.apache.org/docs/interceptors.html)
28 |
29 | ## Credits
30 |
31 | * [TutorialsPoint - Intercepting Filter](http://www.tutorialspoint.com/design_pattern/intercepting_filter_pattern.htm)
32 | * [Presentation Tier Patterns](http://www.javagyan.com/tutorials/corej2eepatterns/presentation-tier-patterns)
33 |
--------------------------------------------------------------------------------
/intercepting-filter/etc/intercepting-filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/intercepting-filter/etc/intercepting-filter.png
--------------------------------------------------------------------------------
/interpreter/etc/interpreter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/interpreter/etc/interpreter.png
--------------------------------------------------------------------------------
/interpreter/etc/interpreter_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/interpreter/etc/interpreter_1.png
--------------------------------------------------------------------------------
/interpreter/src/main/java/com/iluwatar/interpreter/Expression.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.interpreter;
24 |
25 | /**
26 | *
27 | * Expression
28 | *
29 | */
30 | public abstract class Expression {
31 |
32 | public abstract int interpret();
33 |
34 | @Override
35 | public abstract String toString();
36 | }
37 |
--------------------------------------------------------------------------------
/iterator/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Iterator
4 | folder: iterator
5 | permalink: /patterns/iterator/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Gang Of Four
11 | ---
12 |
13 | ## Also known as
14 | Cursor
15 |
16 | ## Intent
17 | Provide a way to access the elements of an aggregate object
18 | sequentially without exposing its underlying representation.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Iterator pattern
24 |
25 | * to access an aggregate object's contents without exposing its internal representation
26 | * to support multiple traversals of aggregate objects
27 | * to provide a uniform interface for traversing different aggregate structures
28 |
29 | ## Real world examples
30 |
31 | * [java.util.Iterator](http://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html)
32 |
33 | ## Credits
34 |
35 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
36 |
--------------------------------------------------------------------------------
/iterator/etc/iterator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/iterator/etc/iterator.png
--------------------------------------------------------------------------------
/iterator/etc/iterator_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/iterator/etc/iterator_1.png
--------------------------------------------------------------------------------
/iterator/src/main/java/com/iluwatar/iterator/ItemIterator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.iterator;
24 |
25 | /**
26 | *
27 | * ItemIterator interface.
28 | *
29 | */
30 | public interface ItemIterator {
31 |
32 | boolean hasNext();
33 |
34 | Item next();
35 | }
36 |
--------------------------------------------------------------------------------
/iterator/src/main/java/com/iluwatar/iterator/ItemType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.iterator;
24 |
25 | /**
26 | *
27 | * ItemType enumeration
28 | *
29 | */
30 | public enum ItemType {
31 |
32 | ANY, WEAPON, RING, POTION
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/layers/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Layers
4 | folder: layers
5 | permalink: /patterns/layers/
6 | categories: Architectural
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - Spring
11 | ---
12 |
13 | ## Intent
14 | Layers is an architectural style where software responsibilities are
15 | divided among the different layers of the application.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Layers architecture when
21 |
22 | * you want clearly divide software responsibilities into differents parts of the program
23 | * you want to prevent a change from propagating throughout the application
24 | * you want to make your application more maintainable and testable
25 |
26 | ## Credits
27 |
28 | * [Pattern Oriented Software Architecture Vol I-V](http://www.amazon.com/Pattern-Oriented-Software-Architecture-Volume-Patterns/dp/0471958697)
29 |
--------------------------------------------------------------------------------
/layers/etc/layers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/layers/etc/layers.png
--------------------------------------------------------------------------------
/layers/src/main/java/com/iluwatar/layers/View.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.layers;
24 |
25 | /**
26 | *
27 | * View interface
28 | *
29 | */
30 | public interface View {
31 |
32 | void render();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/lazy-loading/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Lazy Loading
4 | folder: lazy-loading
5 | permalink: /patterns/lazy-loading/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Idiom
11 | - Performance
12 | ---
13 |
14 | ## Intent
15 | Lazy loading is a design pattern commonly used to defer
16 | initialization of an object until the point at which it is needed. It can
17 | contribute to efficiency in the program's operation if properly and
18 | appropriately used.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Lazy Loading idiom when
24 |
25 | * eager loading is expensive or the object to be loaded might not be needed at all
26 |
27 | ## Real world examples
28 |
29 | * JPA annotations @OneToOne, @OneToMany, @ManyToOne, @ManyToMany and fetch = FetchType.LAZY
30 |
31 | ## Credits
32 |
33 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
34 |
--------------------------------------------------------------------------------
/lazy-loading/etc/lazy-loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/lazy-loading/etc/lazy-loading.png
--------------------------------------------------------------------------------
/mediator/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Mediator
4 | folder: mediator
5 | permalink: /patterns/mediator/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Intermediate
11 | ---
12 |
13 | ## Intent
14 | Define an object that encapsulates how a set of objects interact.
15 | Mediator promotes loose coupling by keeping objects from referring to each
16 | other explicitly, and it lets you vary their interaction independently.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Mediator pattern when
22 |
23 | * a set of objects communicate in well-defined but complex ways. The resulting interdependencies are unstructured and difficult to understand
24 | * reusing an object is difficult because it refers to and communicates with many other objects
25 | * a behavior that's distributed between several classes should be customizable without a lot of subclassing
26 |
27 | ## Credits
28 |
29 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
30 |
--------------------------------------------------------------------------------
/mediator/etc/mediator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/mediator/etc/mediator.png
--------------------------------------------------------------------------------
/mediator/etc/mediator_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/mediator/etc/mediator_1.png
--------------------------------------------------------------------------------
/memento/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Memento
4 | folder: memento
5 | permalink: /patterns/memento/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Intermediate
11 | ---
12 |
13 | ## Also known as
14 | Token
15 |
16 | ## Intent
17 | Without violating encapsulation, capture and externalize an
18 | object's internal state so that the object can be restored to this state later.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Memento pattern when
24 |
25 | * a snapshot of an object's state must be saved so that it can be restored to that state later, and
26 | * a direct interface to obtaining the state would expose implementation details and break the object's encapsulation
27 |
28 | ## Real world examples
29 |
30 | * [java.util.Date](http://docs.oracle.com/javase/8/docs/api/java/util/Date.html)
31 |
32 | ## Credits
33 |
34 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
35 |
--------------------------------------------------------------------------------
/memento/etc/memento.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/memento/etc/memento.png
--------------------------------------------------------------------------------
/memento/src/main/java/com/iluwatar/memento/StarMemento.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.memento;
24 |
25 | /**
26 | *
27 | * External interface to memento.
28 | *
29 | */
30 | public interface StarMemento {
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/message-channel/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/message-channel/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Message Channel
4 | folder: message-channel
5 | permalink: /patterns/message-channel/
6 | categories: Integration
7 | tags:
8 | - Java
9 | - EIP
10 | - Apache Camel™
11 | ---
12 |
13 | ## Intent
14 | When two applications communicate using a messaging system they do it by using logical addresses
15 | of the system, so called Message Channels.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Message Channel pattern when
21 |
22 | * two or more applications need to communicate using a messaging system
23 |
24 | ## Real world examples
25 |
26 | * [akka-camel](http://doc.akka.io/docs/akka/snapshot/scala/camel.html)
--------------------------------------------------------------------------------
/message-channel/etc/message-channel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/message-channel/etc/message-channel.png
--------------------------------------------------------------------------------
/model-view-controller/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Model-View-Controller
4 | folder: model-view-controller
5 | permalink: /patterns/model-view-controller/
6 | categories: Presentation Tier
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | Separate the user interface into three interconnected components:
14 | the model, the view and the controller. Let the model manage the data, the view
15 | display the data and the controller mediate updating the data and redrawing the
16 | display.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Model-View-Controller pattern when
22 |
23 | * you want to clearly separate the domain data from its user interface representation
24 |
25 | ## Credits
26 |
27 | * [Trygve Reenskaug - Model-view-controller](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller)
28 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
29 | * [Patterns of Enterprise Application Architecture](http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420)
30 |
--------------------------------------------------------------------------------
/model-view-controller/etc/model-view-controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/model-view-controller/etc/model-view-controller.png
--------------------------------------------------------------------------------
/model-view-presenter/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Model-View-Presenter
4 | folder: model-view-presenter
5 | permalink: /patterns/model-view-presenter/
6 | categories: Presentation Tier
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | Apply a "Separation of Concerns" principle in a way that allows
14 | developers to build and test user interfaces.
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Model-View-Presenter in any of the following
20 | situations
21 |
22 | * when you want to improve the "Separation of Concerns" principle in presentation logic
23 | * when a user interface development and testing is necessary.
24 |
25 | ## Real world examples
26 |
27 | * [MVP4J](https://github.com/amineoualialami/mvp4j)
28 |
--------------------------------------------------------------------------------
/model-view-presenter/etc/data/test.txt:
--------------------------------------------------------------------------------
1 | ====
2 | The MIT License
3 | Copyright (c) 2014 Ilkka Seppälä
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 | ====
23 |
24 | Test line 1
25 | Test line 2
--------------------------------------------------------------------------------
/model-view-presenter/etc/model-view-presenter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/model-view-presenter/etc/model-view-presenter.png
--------------------------------------------------------------------------------
/model-view-presenter/etc/model-view-presenter_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/model-view-presenter/etc/model-view-presenter_1.png
--------------------------------------------------------------------------------
/monad/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Monad
4 | folder: monad
5 | permalink: /patterns/monad/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Advanced
10 | - Functional
11 | ---
12 |
13 | ## Intent
14 |
15 | Monad pattern based on monad from linear algebra represents the way of chaining operations
16 | together step by step. Binding functions can be described as passing one's output to another's input
17 | basing on the 'same type' contract. Formally, monad consists of a type constructor M and two
18 | operations:
19 | bind - that takes monadic object and a function from plain object to monadic value and returns monadic value
20 | return - that takes plain type object and returns this object wrapped in a monadic value.
21 |
22 | 
23 |
24 | ## Applicability
25 |
26 | Use the Monad in any of the following situations
27 |
28 | * when you want to chain operations easily
29 | * when you want to apply each function regardless of the result of any of them
30 |
31 | ## Credits
32 |
33 | * [Design Pattern Reloaded by Remi Forax](https://youtu.be/-k2X7guaArU)
34 | * [Brian Beckman: Don't fear the Monad](https://channel9.msdn.com/Shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads)
35 | * [Monad on Wikipedia](https://en.wikipedia.org/wiki/Monad_(functional_programming))
--------------------------------------------------------------------------------
/monad/etc/monad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/monad/etc/monad.png
--------------------------------------------------------------------------------
/monad/src/main/java/com/iluwatar/monad/Sex.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.monad;
24 |
25 | public enum Sex {
26 | MALE, FEMALE
27 | }
28 |
--------------------------------------------------------------------------------
/monad/src/test/java/com/iluwatar/monad/AppTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.monad;
24 |
25 | import org.junit.Test;
26 |
27 | public class AppTest {
28 |
29 | @Test
30 | public void testMain() {
31 | String[] args = {};
32 | App.main(args);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/monostate/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: MonoState
4 | folder: monostate
5 | permalink: /patterns/monostate/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | Enforces a behaviour like sharing the same state amongst all instances.
14 |
15 | 
16 |
17 | ## Applicability
18 | Use the Monostate pattern when
19 |
20 | * The same state must be shared across all instances of a class.
21 | * Typically this pattern might be used everywhere a Singleton might be used. Singleton usage however is not transparent, Monostate usage is.
22 | * Monostate has one major advantage over singleton. The subclasses might decorate the shared state as they wish and hence can provide dynamically different behaviour than the base class.
23 |
24 | ## Typical Use Case
25 |
26 | * the logging class
27 | * managing a connection to a database
28 | * file manager
29 |
30 | ## Real world examples
31 |
32 | Yet to see this.
33 |
--------------------------------------------------------------------------------
/monostate/etc/monostate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/monostate/etc/monostate.png
--------------------------------------------------------------------------------
/monostate/src/test/java/com/iluwatar/monostate/AppTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.monostate;
24 |
25 | import org.junit.Test;
26 |
27 | public class AppTest {
28 |
29 | @Test
30 | public void testMain() {
31 | String[] args = {};
32 | App.main(args);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/multiton/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Multiton
4 | folder: multiton
5 | permalink: /patterns/multiton/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Also known as
13 | Registry
14 |
15 | ## Intent
16 | Ensure a class only has limited number of instances, and provide a
17 | global point of access to them.
18 |
19 | 
20 |
21 | ## Applicability
22 | Use the Multiton pattern when
23 |
24 | * there must be specific number of instances of a class, and they must be accessible to clients from a well-known access point
25 |
--------------------------------------------------------------------------------
/multiton/etc/multiton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/multiton/etc/multiton.png
--------------------------------------------------------------------------------
/multiton/src/main/java/com/iluwatar/multiton/NazgulName.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.multiton;
24 |
25 | /**
26 | *
27 | * Each Nazgul has different {@link NazgulName}.
28 | *
29 | */
30 | public enum NazgulName {
31 |
32 | KHAMUL, MURAZOR, DWAR, JI_INDUR, AKHORAHIL, HOARMURATH, ADUNAPHEL, REN, UVATHA;
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/mute-idiom/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Mute Idiom
4 | folder: mute-idiom
5 | permalink: /patterns/mute-idiom/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Idiom
11 | ---
12 |
13 | ## Intent
14 | Provide a template to supress any exceptions that either are declared but cannot occur or should only be logged;
15 | while executing some business logic. The template removes the need to write repeated `try-catch` blocks.
16 |
17 |
18 | 
19 |
20 | ## Applicability
21 | Use this idiom when
22 |
23 | * an API declares some exception but can never throw that exception. Eg. ByteArrayOutputStream bulk write method.
24 | * you need to suppress some exception just by logging it, such as closing a resource.
25 |
26 | ## Credits
27 |
28 | * [JOOQ: Mute Design Pattern](http://blog.jooq.org/2016/02/18/the-mute-design-pattern/)
29 |
--------------------------------------------------------------------------------
/mute-idiom/etc/mute-idiom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/mute-idiom/etc/mute-idiom.png
--------------------------------------------------------------------------------
/mutex/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Mutex
4 | folder: mutex
5 | permalink: /patterns/mutex/
6 | categories: Lock
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Also known as
13 | Mutual Exclusion Lock
14 | Binary Semaphore
15 |
16 | ## Intent
17 | Create a lock which only allows a single thread to access a resource at any one instant.
18 |
19 | 
20 |
21 | ## Applicability
22 | Use a Mutex when
23 |
24 | * you need to prevent two threads accessing a critical section at the same time
25 | * concurrent access to a resource could lead to a race condition
26 |
27 | ## Credits
28 |
29 | * [Lock (computer science)] (http://en.wikipedia.org/wiki/Lock_(computer_science))
30 | * [Semaphores] (http://tutorials.jenkov.com/java-concurrency/semaphores.html)
31 |
--------------------------------------------------------------------------------
/mutex/etc/mutex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/mutex/etc/mutex.png
--------------------------------------------------------------------------------
/mutex/src/main/java/com/iluwatar/mutex/Lock.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.mutex;
24 |
25 | /**
26 | * Lock is an interface for a lock which can be acquired and released.
27 | */
28 | public interface Lock {
29 |
30 | void acquire() throws InterruptedException;
31 |
32 | void release();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/mutex/src/test/java/com/iluwatar/mutex/AppTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.mutex;
24 |
25 | import org.junit.Test;
26 | import java.io.IOException;
27 |
28 | public class AppTest{
29 | @Test
30 | public void test() throws IOException {
31 | String[] args = {};
32 | App.main(args);
33 | }
34 | }
--------------------------------------------------------------------------------
/naked-objects/.gitattributes:
--------------------------------------------------------------------------------
1 | #
2 | #
3 | # text files are normalized (convert crlf => lf)
4 | # binary files are not normalized (binary is a macro for -text -diff)
5 | #
6 | #
7 |
8 |
9 | # Unless otherwise stated, assume text
10 |
11 | * text=auto
12 |
13 |
14 | *.java text diff=java
15 | *.html text diff=html
16 | *.xhtml text diff=html
17 | *.xml text
18 | *.txt text
19 |
20 |
21 | *.jar binary
22 | *.so binary
23 | *.dll binary
24 |
25 | # images
26 | *.jpg binary
27 | *.jpeg binary
28 | *.png binary
29 | *.pdn binary
30 | *.pdn binary
31 |
32 |
33 | *.cs text diff=csharp
34 |
35 | *.sln merge=union
36 | *.csproj merge=union
37 | *.vbproj merge=union
38 | *.fsproj merge=union
39 | *.dbproj merge=union
40 |
41 | *.doc diff=astextplain
42 | *.DOC diff=astextplain
43 | *.docx diff=astextplain
44 | *.DOCX diff=astextplain
45 | *.dot diff=astextplain
46 | *.DOT diff=astextplain
47 | *.pdf diff=astextplain
48 | *.PDF diff=astextplain
49 | *.rtf diff=astextplain
50 | *.RTF diff=astextplain
51 |
52 |
--------------------------------------------------------------------------------
/naked-objects/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | *.swp
3 | *.class
4 | bin/
5 | target/
6 | target-ide/
7 | logs/
8 | .settings/
9 | .project
10 | .classpath
11 | .idea
12 | *.iml
13 |
14 | JArchitectOut/
15 | *.jdproj
16 |
17 | neo4j_DB/
18 |
19 | # log files
20 | datanucleus.log
21 | isis.log
22 | i18n-po.log
23 | hs_err_pid*.log
24 |
25 | # Package Files #
26 | *.jar
27 | *.war
28 | *.ear
29 |
30 | dependency-reduced-pom.xml
31 | pom.xml.tag
32 | pom.xml.next
33 | pom.xml.releaseBackup
34 | pom.xml.versionsBackup
35 |
36 | .clover/
37 | *.jdproj
38 | JArchitectOut/
39 |
40 |
41 | rebel.xml
42 | /translations.pot
43 |
--------------------------------------------------------------------------------
/naked-objects/README:
--------------------------------------------------------------------------------
1 | This is an Apache Isis application created with the SimpleApp archetype. The usage instructions can be found at http://isis.apache.org/guides/ug.html#_ug_getting-started_simpleapp-archetype
--------------------------------------------------------------------------------
/naked-objects/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Naked Objects
4 | folder: naked-objects
5 | permalink: /patterns/naked-objects/
6 | categories: Architectural
7 | tags:
8 | - Java
9 | - Difficulty-Expert
10 | ---
11 |
12 | ## Intent
13 | The Naked Objects architectural pattern is well suited for rapid
14 | prototyping. Using the pattern, you only need to write the domain objects,
15 | everything else is autogenerated by the framework.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Naked Objects pattern when
21 |
22 | * you are prototyping and need fast development cycle
23 | * an autogenerated user interface is good enough
24 | * you want to automatically publish the domain as REST services
25 |
26 | ## Real world examples
27 |
28 | * [Apache Isis](https://isis.apache.org/)
29 |
30 | ## Credits
31 |
32 | * [Richard Pawson - Naked Objects](http://downloads.nakedobjects.net/resources/Pawson%20thesis.pdf)
33 |
--------------------------------------------------------------------------------
/naked-objects/dom/src/main/java/META-INF/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.png
--------------------------------------------------------------------------------
/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.png
--------------------------------------------------------------------------------
/naked-objects/etc/naked-objects.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/naked-objects/etc/naked-objects.png
--------------------------------------------------------------------------------
/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3 | * agreements. See the NOTICE file distributed with this work for additional information regarding
4 | * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
5 | * "License"); you may not use this file except in compliance with the License. You may obtain a
6 | * copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software distributed under the License
11 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | * or implied. See the License for the specific language governing permissions and limitations under
13 | * the License.
14 | */
15 |
16 | package domainapp.fixture.modules.simple;
17 |
18 | import org.apache.isis.applib.fixturescripts.FixtureScript;
19 | import org.apache.isis.applib.services.jdosupport.IsisJdoSupport;
20 |
21 | public class SimpleObjectsTearDown extends FixtureScript {
22 |
23 | @javax.inject.Inject
24 | private IsisJdoSupport isisJdoSupport;
25 |
26 | @Override
27 | protected void execute(ExecutionContext executionContext) {
28 | isisJdoSupport.executeUpdate("delete from \"simple\".\"SimpleObject\"");
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/naked-objects/integtests/.gitignore:
--------------------------------------------------------------------------------
1 | /translations.pot
2 |
--------------------------------------------------------------------------------
/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/CatalogOfFixturesGlue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3 | * agreements. See the NOTICE file distributed with this work for additional information regarding
4 | * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
5 | * "License"); you may not use this file except in compliance with the License. You may obtain a
6 | * copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software distributed under the License
11 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | * or implied. See the License for the specific language governing permissions and limitations under
13 | * the License.
14 | */
15 | package domainapp.integtests.specglue;
16 |
17 | import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
18 |
19 | import cucumber.api.java.Before;
20 | import domainapp.fixture.scenarios.RecreateSimpleObjects;
21 |
22 | public class CatalogOfFixturesGlue extends CukeGlueAbstract {
23 |
24 | @Before(value = {"@integration", "@SimpleObjectsFixture"}, order = 20000)
25 | public void integrationFixtures() throws Throwable {
26 | scenarioExecution().install(new RecreateSimpleObjects());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/naked-objects/integtests/src/test/java/domainapp/integtests/specs/RunSpecs.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3 | * agreements. See the NOTICE file distributed with this work for additional information regarding
4 | * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
5 | * "License"); you may not use this file except in compliance with the License. You may obtain a
6 | * copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software distributed under the License
11 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 | * or implied. See the License for the specific language governing permissions and limitations under
13 | * the License.
14 | */
15 | package domainapp.integtests.specs;
16 |
17 | import org.junit.runner.RunWith;
18 |
19 | import cucumber.api.CucumberOptions;
20 | import cucumber.api.junit.Cucumber;
21 |
22 |
23 | /**
24 | * Runs scenarios in all .feature files (this package and any subpackages).
25 | */
26 | @RunWith(Cucumber.class)
27 | @CucumberOptions(format = {"html:target/cucumber-html-report", "json:target/cucumber.json"},
28 | glue = {"classpath:domainapp.integtests.specglue"}, strict = true, tags = {"~@backlog",
29 | "~@ignore"})
30 | public class RunSpecs {
31 | // intentionally empty
32 | }
33 |
--------------------------------------------------------------------------------
/naked-objects/integtests/src/test/java/domainapp/integtests/specs/modules/simple/SimpleObjectSpec_listAllAndCreate.feature:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 | @SimpleObjectsFixture
18 | Feature: List and Create New Simple Objects
19 |
20 | @integration
21 | Scenario: Existing simple objects can be listed and new ones created
22 | Given there are initially 3 simple objects
23 | When I create a new simple object
24 | Then there are 4 simple objects
25 |
26 |
--------------------------------------------------------------------------------
/naked-objects/webapp/ide/eclipse/launch/.gitignore:
--------------------------------------------------------------------------------
1 | /SimpleApp-PROTOTYPE-jrebel.launch
2 | /SimpleApp-PROTOTYPE-no-fixtures.launch
3 | /SimpleApp-PROTOTYPE-with-fixtures.launch
4 | /SimpleApp-SERVER-no-fixtures.launch
5 | /SimpleApp-PROTOTYPE-jrebel.launch
6 | /SimpleApp-PROTOTYPE-no-fixtures.launch
7 | /SimpleApp-PROTOTYPE-with-fixtures.launch
8 | /SimpleApp-SERVER-no-fixtures.launch
9 |
--------------------------------------------------------------------------------
/naked-objects/webapp/ide/intellij/launch/README.txt:
--------------------------------------------------------------------------------
1 | ====
2 | The MIT License
3 | Copyright (c) 2014 Ilkka Seppälä
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 | ====
23 |
24 | Copy into workspace\.idea\runConfigurations directory, and adjust file paths for Maven tasks.
25 |
26 |
--------------------------------------------------------------------------------
/naked-objects/webapp/lib/.gitignore:
--------------------------------------------------------------------------------
1 | #
2 | # explicitly ignoring Microsoft JDBC4 jar
3 | # (cannot redistribute, licensing)
4 | #
5 | sqljdbc4.jar
6 |
--------------------------------------------------------------------------------
/naked-objects/webapp/src/main/jettyconsole/isis-banner.pdn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/naked-objects/webapp/src/main/jettyconsole/isis-banner.pdn
--------------------------------------------------------------------------------
/naked-objects/webapp/src/main/jettyconsole/isis-banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/naked-objects/webapp/src/main/jettyconsole/isis-banner.png
--------------------------------------------------------------------------------
/naked-objects/webapp/src/main/webapp/about/images/isis-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/naked-objects/webapp/src/main/webapp/about/images/isis-logo.png
--------------------------------------------------------------------------------
/naked-objects/webapp/src/main/webapp/css/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 |
--------------------------------------------------------------------------------
/naked-objects/webapp/src/main/webapp/images/spinning-icon.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/naked-objects/webapp/src/main/webapp/images/spinning-icon.gif
--------------------------------------------------------------------------------
/naked-objects/webapp/src/main/webapp/scripts/application.js:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | $(document).ready(function() {
24 | /// here...
25 | });
--------------------------------------------------------------------------------
/null-object/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Null Object
4 | folder: null-object
5 | permalink: /patterns/null-object/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | In most object-oriented languages, such as Java or C#, references
14 | may be null. These references need to be checked to ensure they are not null
15 | before invoking any methods, because methods typically cannot be invoked on
16 | null references. Instead of using a null reference to convey absence of an
17 | object (for instance, a non-existent customer), one uses an object which
18 | implements the expected interface, but whose method body is empty. The
19 | advantage of this approach over a working default implementation is that a Null
20 | Object is very predictable and has no side effects: it does nothing.
21 |
22 | 
23 |
24 | ## Applicability
25 | Use the Null Object pattern when
26 |
27 | * you want to avoid explicit null checks and keep the algorithm elegant and easy to read.
28 |
29 | ## Credits
30 | * [Pattern Languages of Program Design](http://www.amazon.com/Pattern-Languages-Program-Design-Coplien/dp/0201607344/ref=sr_1_1)
31 |
--------------------------------------------------------------------------------
/null-object/etc/null-object.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/null-object/etc/null-object.png
--------------------------------------------------------------------------------
/object-pool/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Object Pool
4 | folder: object-pool
5 | permalink: /patterns/object-pool/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Performance
11 | ---
12 |
13 | ## Intent
14 | When objects are expensive to create and they are needed only for
15 | short periods of time it is advantageous to utilize the Object Pool pattern.
16 | The Object Pool provides a cache for instantiated objects tracking which ones
17 | are in use and which are available.
18 |
19 | 
20 |
21 | ## Applicability
22 | Use the Object Pool pattern when
23 |
24 | * the objects are expensive to create (allocation cost)
25 | * you need a large number of short-lived objects (memory fragmentation)
26 |
--------------------------------------------------------------------------------
/object-pool/etc/object-pool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/object-pool/etc/object-pool.png
--------------------------------------------------------------------------------
/observer/etc/observer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/observer/etc/observer.png
--------------------------------------------------------------------------------
/observer/etc/observer_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/observer/etc/observer_1.png
--------------------------------------------------------------------------------
/observer/src/main/java/com/iluwatar/observer/WeatherObserver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.observer;
24 |
25 | /**
26 | *
27 | * Observer interface.
28 | *
29 | */
30 | public interface WeatherObserver {
31 |
32 | void update(WeatherType currentWeather);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/observer/src/main/java/com/iluwatar/observer/generic/Observer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.observer.generic;
24 |
25 | /**
26 | *
27 | * Observer
28 | */
29 | public interface Observer, O extends Observer, A> {
30 |
31 | void update(S subject, A argument);
32 | }
33 |
--------------------------------------------------------------------------------
/observer/src/main/java/com/iluwatar/observer/generic/Race.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.observer.generic;
24 |
25 | import com.iluwatar.observer.WeatherType;
26 |
27 | /**
28 | *
29 | * Race
30 | *
31 | */
32 | public interface Race extends Observer {
33 | }
34 |
--------------------------------------------------------------------------------
/poison-pill/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Poison Pill
4 | folder: poison-pill
5 | permalink: /patterns/poison-pill/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | Poison Pill is known predefined data item that allows to provide
14 | graceful shutdown for separate distributed consumption process.
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Poison Pill idiom when
20 |
21 | * need to send signal from one thread/process to another to terminate
22 |
23 | ## Real world examples
24 |
25 | * [akka.actor.PoisonPill](http://doc.akka.io/docs/akka/2.1.4/java/untyped-actors.html)
26 |
--------------------------------------------------------------------------------
/poison-pill/etc/poison-pill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/poison-pill/etc/poison-pill.png
--------------------------------------------------------------------------------
/poison-pill/src/main/java/com/iluwatar/poison/pill/MessageQueue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.poison.pill;
24 |
25 | /**
26 | * Represents abstraction of channel (or pipe) that bounds {@link Producer} and {@link Consumer}
27 | */
28 | public interface MessageQueue extends MqPublishPoint, MqSubscribePoint {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/poison-pill/src/main/java/com/iluwatar/poison/pill/MqPublishPoint.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.poison.pill;
24 |
25 | /**
26 | * Endpoint to publish {@link Message} to queue
27 | */
28 | public interface MqPublishPoint {
29 |
30 | void put(Message msg) throws InterruptedException;
31 | }
32 |
--------------------------------------------------------------------------------
/poison-pill/src/main/java/com/iluwatar/poison/pill/MqSubscribePoint.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.poison.pill;
24 |
25 | /**
26 | * Endpoint to retrieve {@link Message} from queue
27 | */
28 | public interface MqSubscribePoint {
29 |
30 | Message take() throws InterruptedException;
31 | }
32 |
--------------------------------------------------------------------------------
/private-class-data/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Private Class Data
4 | folder: private-class-data
5 | permalink: /patterns/private-class-data/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Idiom
11 | ---
12 |
13 | ## Intent
14 | Private Class Data design pattern seeks to reduce exposure of
15 | attributes by limiting their visibility. It reduces the number of class
16 | attributes by encapsulating them in single Data object.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Private Class Data pattern when
22 |
23 | * you want to prevent write access to class data members
24 |
--------------------------------------------------------------------------------
/private-class-data/etc/private-class-data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/private-class-data/etc/private-class-data.png
--------------------------------------------------------------------------------
/producer-consumer/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Producer Consumer
4 | folder: producer-consumer
5 | permalink: /patterns/producer-consumer/
6 | categories: Concurrency
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - I/O
11 | ---
12 |
13 | ## Intent
14 | Producer Consumer Design pattern is a classic concurrency pattern which reduces
15 | coupling between Producer and Consumer by separating Identification of work with Execution of
16 | Work.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Producer Consumer idiom when
22 |
23 | * decouple system by separate work in two process produce and consume.
24 | * addresses the issue of different timing require to produce work or consuming work
25 |
--------------------------------------------------------------------------------
/producer-consumer/etc/producer-consumer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/producer-consumer/etc/producer-consumer.png
--------------------------------------------------------------------------------
/property/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Property
4 | folder: property
5 | permalink: /patterns/property/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | Create hierarchy of objects and new objects using already existing
14 | objects as parents.
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Property pattern when
20 |
21 | * when you like to have objects with dynamic set of fields and prototype inheritance
22 |
23 | ## Real world examples
24 |
25 | * [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain) prototype inheritance
26 |
--------------------------------------------------------------------------------
/property/etc/property.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/property/etc/property.png
--------------------------------------------------------------------------------
/property/src/main/java/com/iluwatar/property/Stats.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.property;
24 |
25 | /**
26 | * All possible attributes that Character can have
27 | */
28 | public enum Stats {
29 |
30 | AGILITY, STRENGTH, ATTACK_POWER, ARMOR, INTELLECT, SPIRIT, ENERGY, RAGE
31 | }
32 |
--------------------------------------------------------------------------------
/prototype/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Prototype
4 | folder: prototype
5 | permalink: /patterns/prototype/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Beginner
11 | ---
12 |
13 | ## Intent
14 | Specify the kinds of objects to create using a prototypical
15 | instance, and create new objects by copying this prototype.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Prototype pattern when a system should be independent of how its products are created, composed and represented; and
21 |
22 | * when the classes to instantiate are specified at run-time, for example, by dynamic loading; or
23 | * to avoid building a class hierarchy of factories that parallels the class hierarchy of products; or
24 | * when instances of a class can have one of only a few different combinations of state. It may be more convenient to install a corresponding number of prototypes and clone them rather than instantiating the class manually, each time with the appropriate state
25 |
26 | ## Real world examples
27 |
28 | * [java.lang.Object#clone()](http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone%28%29)
29 |
30 | ## Credits
31 |
32 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
33 |
--------------------------------------------------------------------------------
/prototype/etc/prototype.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/prototype/etc/prototype.png
--------------------------------------------------------------------------------
/prototype/etc/prototype_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/prototype/etc/prototype_1.png
--------------------------------------------------------------------------------
/prototype/src/main/java/com/iluwatar/prototype/Beast.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.prototype;
24 |
25 | /**
26 | *
27 | * Beast
28 | *
29 | */
30 | public abstract class Beast extends Prototype {
31 |
32 | @Override
33 | public abstract Beast clone() throws CloneNotSupportedException;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/prototype/src/main/java/com/iluwatar/prototype/Mage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.prototype;
24 |
25 | /**
26 | *
27 | * Mage
28 | *
29 | */
30 | public abstract class Mage extends Prototype {
31 |
32 | @Override
33 | public abstract Mage clone() throws CloneNotSupportedException;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/prototype/src/main/java/com/iluwatar/prototype/Prototype.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.prototype;
24 |
25 | /**
26 | *
27 | * Prototype
28 | *
29 | */
30 | public abstract class Prototype implements Cloneable {
31 |
32 | @Override
33 | public abstract Object clone() throws CloneNotSupportedException;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/prototype/src/main/java/com/iluwatar/prototype/Warlord.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.prototype;
24 |
25 | /**
26 | *
27 | * Warlord
28 | *
29 | */
30 | public abstract class Warlord extends Prototype {
31 |
32 | @Override
33 | public abstract Warlord clone() throws CloneNotSupportedException;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/proxy/etc/proxy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/proxy/etc/proxy.png
--------------------------------------------------------------------------------
/proxy/etc/proxy_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/proxy/etc/proxy_1.png
--------------------------------------------------------------------------------
/publish-subscribe/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/publish-subscribe/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Publish Subscribe
4 | folder: publish-subscribe
5 | permalink: /patterns/publish-subscribe/
6 | categories: Integration
7 | tags:
8 | - Java
9 | - EIP
10 | - Apache Camel™
11 | ---
12 |
13 | ## Intent
14 | Broadcast messages from sender to all the interested receivers.
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Publish Subscribe Channel pattern when
20 |
21 | * two or more applications need to communicate using a messaging system for broadcasts.
22 |
23 | ## Credits
24 |
25 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
26 |
--------------------------------------------------------------------------------
/publish-subscribe/etc/publish-subscribe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/publish-subscribe/etc/publish-subscribe.png
--------------------------------------------------------------------------------
/reactor/etc/reactor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/reactor/etc/reactor.png
--------------------------------------------------------------------------------
/reader-writer-lock/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Reader Writer Lock
4 | folder: reader-writer-lock
5 | permalink: /patterns/reader-writer-lock/
6 | categories: Concurrent
7 | tags:
8 | - Java
9 | ---
10 |
11 | **Intent:**
12 |
13 | Suppose we have a shared memory area with the basic constraints detailed above. It is possible to protect the shared data behind a mutual exclusion mutex, in which case no two threads can access the data at the same time. However, this solution is suboptimal, because it is possible that a reader R1 might have the lock, and then another reader R2 requests access. It would be foolish for R2 to wait until R1 was done before starting its own read operation; instead, R2 should start right away. This is the motivation for the Reader Writer Lock pattern.
14 |
15 | 
16 |
17 | **Applicability:**
18 |
19 | Application need to increase the performance of resource synchronize for multiple thread, in particularly there are mixed read/write operations.
20 |
21 | **Real world examples:**
22 |
23 | * [Java Reader Writer Lock](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReadWriteLock.html)
24 |
25 | **Credits**
26 |
27 | * [Readers–writer lock](https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock)
28 |
29 | * [Readers–writers_problem](https://en.wikipedia.org/wiki/Readers%E2%80%93writers_problem)
--------------------------------------------------------------------------------
/reader-writer-lock/etc/reader-writer-lock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/reader-writer-lock/etc/reader-writer-lock.png
--------------------------------------------------------------------------------
/repository/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Repository
4 | folder: repository
5 | permalink: /patterns/repository/
6 | categories: Persistence Tier
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - Spring
11 | ---
12 |
13 | ## Intent
14 | Repository layer is added between the domain and data mapping
15 | layers to isolate domain objects from details of the database access code and
16 | to minimize scattering and duplication of query code. The Repository pattern is
17 | especially useful in systems where number of domain classes is large or heavy
18 | querying is utilized.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Repository pattern when
24 |
25 | * the number of domain objects is large
26 | * you want to avoid duplication of query code
27 | * you want to keep the database querying code in single place
28 | * you have multiple data sources
29 |
30 | ## Real world examples
31 |
32 | * [Spring Data](http://projects.spring.io/spring-data/)
33 |
34 | ## Credits
35 |
36 | * [Don’t use DAO, use Repository](http://thinkinginobjects.com/2012/08/26/dont-use-dao-use-repository/)
37 | * [Advanced Spring Data JPA - Specifications and Querydsl](https://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/)
38 |
--------------------------------------------------------------------------------
/repository/etc/repository.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/repository/etc/repository.png
--------------------------------------------------------------------------------
/resource-acquisition-is-initialization/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Resource Acquisition Is Initialization
4 | folder: resource-acquisition-is-initialization
5 | permalink: /patterns/resource-acquisition-is-initialization/
6 | categories: Other
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Idiom
11 | ---
12 |
13 | ## Intent
14 | Resource Acquisition Is Initialization pattern can be used to implement exception safe resource management.
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Resource Acquisition Is Initialization pattern when
20 |
21 | * you have resources that must be closed in every condition
22 |
--------------------------------------------------------------------------------
/resource-acquisition-is-initialization/etc/resource-acquisition-is-initialization.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/resource-acquisition-is-initialization/etc/resource-acquisition-is-initialization.png
--------------------------------------------------------------------------------
/semaphore/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Semaphore
4 | folder: semaphore
5 | permalink: /patterns/semaphore/
6 | categories: Lock
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Also known as
13 | Counting Semaphore
14 |
15 | ## Intent
16 | Create a lock which mediates access to a pool of resources.
17 | Only a limited number of threads, specified at the creation
18 | of the semaphore, can access the resources at any given time.
19 | A semaphore which only allows one concurrent access to a resource
20 | is called a binary semaphore.
21 |
22 | 
23 |
24 | ## Applicability
25 | Use a Semaphore when
26 |
27 | * you have a pool of resources to allocate to different threads
28 | * concurrent access to a resource could lead to a race condition
29 |
30 | ## Credits
31 |
32 | * [Semaphore(programming)] (http://en.wikipedia.org/wiki/Semaphore_(programming))
33 | * [Semaphores] (http://tutorials.jenkov.com/java-concurrency/semaphores.html)
34 |
--------------------------------------------------------------------------------
/semaphore/etc/semaphore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/semaphore/etc/semaphore.png
--------------------------------------------------------------------------------
/semaphore/src/test/java/com/iluwatar/semaphore/AppTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.semaphore;
24 |
25 | import org.junit.Test;
26 | import java.io.IOException;
27 |
28 | public class AppTest{
29 | @Test
30 | public void test() throws IOException {
31 | String[] args = {};
32 | App.main(args);
33 | }
34 | }
--------------------------------------------------------------------------------
/servant/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Servant
4 | folder: servant
5 | permalink: /patterns/servant/
6 | categories: Structural
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | Servant is used for providing some behavior to a group of classes.
14 | Instead of defining that behavior in each class - or when we cannot factor out
15 | this behavior in the common parent class - it is defined once in the Servant.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Servant pattern when
21 |
22 | * when we want some objects to perform a common action and don't want to define this action as a method in every class.
23 |
24 | ## Credits
25 | * [Let's Modify the Objects-First Approach into Design-Patterns-First](http://edu.pecinovsky.cz/papers/2006_ITiCSE_Design_Patterns_First.pdf)
26 |
--------------------------------------------------------------------------------
/servant/etc/servant-pattern.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/servant/etc/servant-pattern.png
--------------------------------------------------------------------------------
/servant/src/etc/servant.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/servant/src/etc/servant.jpg
--------------------------------------------------------------------------------
/service-layer/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Service Layer
4 | folder: service-layer
5 | permalink: /patterns/service-layer/
6 | categories: Architectural
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | Service Layer is an abstraction over domain logic. Typically
14 | applications require multiple kinds of interfaces to the data they store and
15 | logic they implement: data loaders, user interfaces, integration gateways, and
16 | others. Despite their different purposes, these interfaces often need common
17 | interactions with the application to access and manipulate its data and invoke
18 | its business logic. The Service Layer fulfills this role.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Service Layer pattern when
24 |
25 | * you want to encapsulate domain logic under API
26 | * you need to implement multiple interfaces with common logic and data
27 |
28 | ## Credits
29 |
30 | * [Martin Fowler - Service Layer](http://martinfowler.com/eaaCatalog/serviceLayer.html)
31 | * [Patterns of Enterprise Application Architecture](http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420)
32 |
--------------------------------------------------------------------------------
/service-layer/etc/service-layer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/service-layer/etc/service-layer.png
--------------------------------------------------------------------------------
/service-locator/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Service Locator
4 | folder: service-locator
5 | permalink: /patterns/service-locator/
6 | categories: Structural
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | - Performance
11 | ---
12 |
13 | ## Intent
14 | Encapsulate the processes involved in obtaining a service with a
15 | strong abstraction layer.
16 |
17 | 
18 |
19 | ## Applicability
20 | The service locator pattern is applicable whenever we want
21 | to locate/fetch various services using JNDI which, typically, is a redundant
22 | and expensive lookup. The service Locator pattern addresses this expensive
23 | lookup by making use of caching techniques ie. for the very first time a
24 | particular service is requested, the service Locator looks up in JNDI, fetched
25 | the relevant service and then finally caches this service object. Now, further
26 | lookups of the same service via Service Locator is done in its cache which
27 | improves the performance of application to great extent.
28 |
29 | ## Typical Use Case
30 |
31 | * when network hits are expensive and time consuming
32 | * lookups of services are done quite frequently
33 | * large number of services are being used
34 |
35 | ## Credits
36 |
37 | * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
38 |
--------------------------------------------------------------------------------
/service-locator/etc/service-locator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/service-locator/etc/service-locator.png
--------------------------------------------------------------------------------
/singleton/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Singleton
4 | folder: singleton
5 | permalink: /patterns/singleton/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Gang Of Four
10 | - Difficulty-Beginner
11 | ---
12 |
13 | ## Intent
14 | Ensure a class only has one instance, and provide a global point of
15 | access to it.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Singleton pattern when
21 |
22 | * there must be exactly one instance of a class, and it must be accessible to clients from a well-known access point
23 | * when the sole instance should be extensible by subclassing, and clients should be able to use an extended instance without modifying their code
24 |
25 | ## Typical Use Case
26 |
27 | * the logging class
28 | * managing a connection to a database
29 | * file manager
30 |
31 | ## Real world examples
32 |
33 | * [java.lang.Runtime#getRuntime()](http://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#getRuntime%28%29)
34 |
35 | ## Credits
36 |
37 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
38 | * [Effective Java (2nd Edition)](http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683)
39 |
--------------------------------------------------------------------------------
/singleton/etc/singleton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/singleton/etc/singleton.png
--------------------------------------------------------------------------------
/singleton/etc/singleton_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/singleton/etc/singleton_1.png
--------------------------------------------------------------------------------
/specification/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Specification
4 | folder: specification
5 | permalink: /patterns/specification/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | Specification pattern separates the statement of how to match a
14 | candidate, from the candidate object that it is matched against. As well as its
15 | usefulness in selection, it is also valuable for validation and for building to
16 | order
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Specification pattern when
22 |
23 | * you need to select a subset of objects based on some criteria, and to refresh the selection at various times
24 | * you need to check that only suitable objects are used for a certain role (validation)
25 |
26 | ## Credits
27 |
28 | * [Martin Fowler - Specifications](http://martinfowler.com/apsupp/spec.pdf)
29 |
--------------------------------------------------------------------------------
/specification/etc/specification.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/specification/etc/specification.png
--------------------------------------------------------------------------------
/state/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: State
4 | folder: state
5 | permalink: /patterns/state/
6 | categories: Behavioral
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - Gang Of Four
11 | ---
12 |
13 | ## Also known as
14 | Objects for States
15 |
16 | ## Intent
17 | Allow an object to alter its behavior when its internal state
18 | changes. The object will appear to change its class.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the State pattern in either of the following cases
24 |
25 | * an object's behavior depends on its state, and it must change its behavior at run-time depending on that state
26 | * operations have large, multipart conditional statements that depend on the object's state. This state is usually represented by one or more enumerated constants. Often, several operations will contain this same conditional structure. The State pattern puts each branch of the conditional in a separate class. This lets you treat the object's state as an object in its own right that can vary independently from other objects.
27 |
28 | ## Credits
29 |
30 | * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
31 |
--------------------------------------------------------------------------------
/state/etc/state.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/state/etc/state.png
--------------------------------------------------------------------------------
/state/etc/state_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/state/etc/state_1.png
--------------------------------------------------------------------------------
/state/src/main/java/com/iluwatar/state/State.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | * Copyright (c) 2014 Ilkka Seppälä
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 | package com.iluwatar.state;
24 |
25 | /**
26 | *
27 | * State interface.
28 | *
29 | */
30 | public interface State {
31 |
32 | void onEnterState();
33 |
34 | void observe();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/step-builder/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Step Builder
4 | folder: step-builder
5 | permalink: /patterns/step-builder/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | An extension of the Builder pattern that fully guides the user through the creation of the object with no chances of confusion.
14 | The user experience will be much more improved by the fact that he will only see the next step methods available, NO build method until is the right time to build the object.
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Step Builder pattern when the algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled the construction process must allow different representations for the object that's constructed when in the process of constructing the order is important.
20 |
21 | ## Credits
22 |
23 | * [Marco Castigliego - Step Builder](http://rdafbn.blogspot.co.uk/2012/07/step-builder-pattern_28.html)
24 |
--------------------------------------------------------------------------------
/step-builder/etc/step-builder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/step-builder/etc/step-builder.png
--------------------------------------------------------------------------------
/strategy/etc/strategy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/strategy/etc/strategy.png
--------------------------------------------------------------------------------
/strategy/etc/strategy_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/strategy/etc/strategy_1.png
--------------------------------------------------------------------------------
/template-method/etc/template-method.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/template-method/etc/template-method.png
--------------------------------------------------------------------------------
/template-method/etc/template-method_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/template-method/etc/template-method_1.png
--------------------------------------------------------------------------------
/thread-pool/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Thread Pool
4 | folder: thread-pool
5 | permalink: /patterns/thread-pool/
6 | categories: Concurrency
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | - Performance
11 | ---
12 |
13 | ## Intent
14 | It is often the case that tasks to be executed are short-lived and
15 | the number of tasks is large. Creating a new thread for each task would make
16 | the system spend more time creating and destroying the threads than executing
17 | the actual tasks. Thread Pool solves this problem by reusing existing threads
18 | and eliminating the latency of creating new threads.
19 |
20 | 
21 |
22 | ## Applicability
23 | Use the Thread Pool pattern when
24 |
25 | * you have a large number of short-lived tasks to be executed in parallel
26 |
--------------------------------------------------------------------------------
/thread-pool/etc/thread-pool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/thread-pool/etc/thread-pool.png
--------------------------------------------------------------------------------
/tolerant-reader/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Tolerant Reader
4 | folder: tolerant-reader
5 | permalink: /patterns/tolerant-reader/
6 | categories: Integration
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | Tolerant Reader is an integration pattern that helps creating
14 | robust communication systems. The idea is to be as tolerant as possible when
15 | reading data from another service. This way, when the communication schema
16 | changes, the readers must not break.
17 |
18 | 
19 |
20 | ## Applicability
21 | Use the Tolerant Reader pattern when
22 |
23 | * the communication schema can evolve and change and yet the receiving side should not break
24 |
25 | ## Credits
26 |
27 | * [Martin Fowler - Tolerant Reader](http://martinfowler.com/bliki/TolerantReader.html)
28 |
--------------------------------------------------------------------------------
/tolerant-reader/etc/tolerant-reader.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/tolerant-reader/etc/tolerant-reader.png
--------------------------------------------------------------------------------
/twin/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/twin/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Twin
4 | folder: twin
5 | permalink: /patterns/twin/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Intermediate
10 | ---
11 |
12 | ## Intent
13 | Twin pattern is a design pattern which provides a standard solution to simulate multiple
14 | inheritance in java
15 |
16 | 
17 |
18 | ## Applicability
19 | Use the Twin idiom when
20 |
21 | * to simulate multiple inheritance in a language that does not support this feature.
22 | * to avoid certain problems of multiple inheritance such as name clashes.
23 |
24 | ## Credits
25 |
26 | * [Twin – A Design Pattern for Modeling Multiple Inheritance](http://www.ssw.uni-linz.ac.at/Research/Papers/Moe99/Paper.pdf)
27 |
--------------------------------------------------------------------------------
/twin/etc/twin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/twin/etc/twin.png
--------------------------------------------------------------------------------
/value-object/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: pattern
3 | title: Value Object
4 | folder: value-object
5 | permalink: /patterns/value-object/
6 | categories: Creational
7 | tags:
8 | - Java
9 | - Difficulty-Beginner
10 | ---
11 |
12 | ## Intent
13 | Provide objects which follow value semantics rather than reference semantics.
14 | This means value objects' equality are not based on identity. Two value objects are
15 | equal when they have the same value, not necessarily being the same object.
16 |
17 | 
18 |
19 | ## Applicability
20 | Use the Value Object when
21 |
22 | * you need to measure the objects' equality based on the objects' value
23 |
24 | ## Real world examples
25 |
26 | * [java.util.Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)
27 | * [java.time.LocalDate](https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html)
28 | * [joda-time, money, beans](http://www.joda.org/)
29 |
30 | ## Credits
31 |
32 | * [Patterns of Enterprise Application Architecture](http://www.martinfowler.com/books/eaa.html)
33 | * [VALJOs - Value Java Objects : Stephen Colebourne's blog](http://blog.joda.org/2014/03/valjos-value-java-objects.html)
34 | * [Value Object : Wikipedia](https://en.wikipedia.org/wiki/Value_object)
35 |
--------------------------------------------------------------------------------
/value-object/etc/value-object.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/value-object/etc/value-object.png
--------------------------------------------------------------------------------
/value-object/etc/value-object.ucls:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/visitor/etc/visitor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/visitor/etc/visitor.png
--------------------------------------------------------------------------------
/visitor/etc/visitor_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErnestMing/JavaDesignPartternImpl/34431d71b4a00ef79895db9aaca30020baace209/visitor/etc/visitor_1.png
--------------------------------------------------------------------------------