Compare commits

...

161 Commits

Author SHA1 Message Date
allcontributors[bot]
3b87565fb6
docs: add HattoriHenzo as a contributor for code (#1981)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2022-04-15 20:16:46 +03:00
HattoriHenzo
da9f26bbc0
fix: Correction of the CheckStyle issue the project acyclic-visitor (#1969) 2022-04-15 20:14:12 +03:00
Subhrodip Mohanta
dde31bfe34
enhancement: Update Gitignore for OSX (#1955) 2022-02-12 20:14:44 +02:00
allcontributors[bot]
1596e9048d
docs: add ShivanshCharak as a contributor for code (#1958)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2022-01-30 21:01:10 +02:00
ShivanshCharak
a4aff05123
refactoring: modified modem.java (#1952) 2022-01-30 20:57:46 +02:00
Ilkka Seppälä
c87689b247
task: Update Multiton example (#1950)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2022-01-24 21:58:44 +05:30
Ilkka Seppälä
5ce0419b44
task: Update Maven version (#1949)
* Update maven and maven wrapper to the latest versions

* Update maven-war-plugin version

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2022-01-24 21:57:02 +05:30
allcontributors[bot]
58ce3a2ab2
docs: add Kevinyl3 as a contributor for code (#1951)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2022-01-18 21:58:43 +02:00
Kevin
7652b11bca
new pattern: Issue#1264: Implemented Composite-View Pattern (#1923)
* initial commit, created package, README, pom, and directory structure.

* Issue#1264, continue working on JavaBeans, added getters, setters, and private fields. Created test file for JavaBeans.

* set up junit for tests folder.

* Issue#1264, set up local server and added web-application framework to composite-view to allow the JSP to run on a local Tomcat container. Wrote unit tests for Java-bean class, working on JSP pages.

* Issue#1264, Added forwarding functionality to servlet and main composite view page.

* Issue#1264, Finished composite view template in newsDisplay.jsp and created atomic sub-view components in businessNews.jsp, header.jsp, localNews.jsp, scienceNews.jsp, sportsNews.jsp, worldNews.jsp. Composite view page renders correctly, atomic views are inserted in and substituted in the template page depending on request parameters.

* Issue#1264, Added all views, updated README.md with documentation.

* Issue#1264, updated README.md, moved images folder into etc folder.

* Issue#1264, removed build artifacts from tracked files.

* Issue#1264, updated README.md

* Issue#1264, updated README.md

* Issue#1264, removed unused import, made AppServlet class final, changed to .equals() for string comparison.

* Issue#1264, in AppServlet, put the output writing into try blocks to ensure writers are closed.

* Issue#1264, added tests for Servlet, coverage up to 100%, used lombok to reduce boilerplate setters and getter, updated README.md with better grammar, appropriate tags and links to related patterns. Updated pom.xml to get rid of superfluous lines.

* Issue#1264, made changes as requested in README.md.

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2022-01-18 21:51:53 +02:00
Ilkka Seppälä
07ee94d671
refactoring: execute around idiom (#1945)
* Refactor execute around the idiom

* fix checkstyle errors

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2022-01-10 17:04:19 +05:30
Ilkka Seppälä
c5492184b7
enhancement: check spelling and update topic (#1943)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2022-01-08 18:03:19 +05:30
Ilkka Seppälä
4f8007d674
enhancement: Refactor and add explanation for value object (#1942)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2022-01-08 18:01:09 +05:30
Ilkka Seppälä
2d2dec98e8
enhancement: Add explanation for factory kit (#1941)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2022-01-08 17:59:30 +05:30
Ilkka Seppälä
3cc9bc2dea
refactoring: unit of work (#1940)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2022-01-08 17:57:11 +05:30
Ilkka Seppälä
11f20593b2
Update throttling pattern (#1937)
* Create component.urm.puml

* Create App.java

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Create AppTest.java

* Add files via upload

* Update README.md

* Update README.md

* Update pom.xml

* Update App.java

* Update BjornGraphicsComponent.java

* Update BjornInputComponent.java

* Update BjornPhysicsComponent.java

* Update Component.java

* Update App.java

* Delete App.java

* Delete BjornGraphicsComponent.java

* Delete BjornInputComponent.java

* Delete BjornPhysicsComponent.java

* Delete Component.java

* Delete GameObject.java

* Delete GraphicsComponent.java

* Delete InputComponent.java

* Delete PhysicsComponent.java

* Create App.java

* Update App.java

* Update App.java

* Create BjornGraphicsComponent.java

* Create BjornInputComponent.java

* Create BjornPhysicsComponent.java

* Create Component.java

* Create GameObject.java

* Create GraphicsComponent.java

* Create InputComponent.java

* Create PhysicsComponent.java

* Delete AppTest.java

* Delete UpdateTest.java

* Create AppTest.java

* Create UpdateTest.java

* Update throttling pattern example

* delete unwanted files

Co-authored-by: YanchaoMiao <11710204@mail.sustech.edu.cn>
2022-01-07 09:46:59 +02:00
Ilkka Seppälä
c66ca67201
#590 add explanation for event aggregator (#1936) 2022-01-06 18:43:16 +02:00
allcontributors[bot]
2679f7aa6f
docs: add castleKing1997 as a contributor for code (#1939)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2022-01-01 20:48:21 +02:00
DragonDreamer
8403fdacdd
feature: Metadata Mapping pattern (#1932)
* metadata-mapping

* Update README.md

* add class diagram

* update README.md

* fix identation

* Update pom.xml

* fix indentation

* fix ci

* remove e.printstack

* fix ci

* update class diagram

* fix ci

* fix ci

* fix sc

* fix smells

* Update DatabaseUtil.java

* fix coverage

* Update DatabaseUtil.java

* Update DatabaseUtil.java

* Update DatabaseUtil.java

* Update metadata-mapping/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* fix review

* fix review

* Update App.java

* Update App.java

* fix review

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2022-01-01 20:46:20 +02:00
allcontributors[bot]
f670ae547b
docs: add Leisterbecker as a contributor for code (#1935)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-12-23 20:45:14 +02:00
Leisterbecker
df73d80365
improvement: EventAggregator now considers Event-Type (#1933)
* Implemented more granular registration of observers with HashMap;
Key: Event, Value: List of Observers registered for the event;

* Edited constructors and super calls of all EventEmitter extenders

* Edited constructor calls in App.java

* Edited EventEmitterTest

* Added new white walkers event, scout emits at wednesday, varys observes and emits at saturday

* Added white walkers event to KingsHandTest.java

* Varys now passes events

* Corrected some indentation levels and added curly braces to if statements

* Corrected some styling

* Switched lines in App.java,
added javadoc to registerObserver

* Fixed some indents, added param comments
2021-12-23 20:43:36 +02:00
allcontributors[bot]
4588e09939
docs: add yuhangbin as a contributor for code (#1934)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-12-23 18:11:48 +02:00
CharlieYu
69883196d2
improvement: Optimized NioReactor stop() (Reactor Pattern) (#1930)
* Optimized NioReactor stop()

* Optimized ThreadPoolDispatcher stop()
2021-12-23 18:10:17 +02:00
allcontributors[bot]
4dcc20b733
docs: add interactwithankush as a contributor for code (#1931)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-12-16 20:06:21 +05:30
interactwithankush
600227d2e4
fix: Sonar report - fix blocker and critical ones (#1899)
* update SpatialPartitionBubbles - fix Sonar blocker issue

* fix Sonar critical issue - Define constant instead of duplicating the literal

* fix Sonar critical issue - remove unnecessary default constructor

* fix Sonar critical issue - Define constant instead of duplicating the literal

* fix Sonar critical issue - Define constant instead of duplicating the literal

* fix Sonar critical issue - Define constant instead of duplicating the literal

* fix Sonar critical issue - fix checkstyle issue

* fix Sonar critical issue - fix code smells

* fix Sonar critical issue - fix code smells

* fix Sonar critical issue - fix code smells

* fix sonarbugs - adding test cases for Commander class

* sonar fix - add assert commands in CommanderTest

* sonar fix - add test cases for CommanderTest

* sonar fix - add test cases for CommanderTest

* sonar fix - add test cases for CommanderTest

* sonar fix - add test cases for CommanderTest

* sonar fix - add test cases for CommanderTest

* sonar fix - add test cases for CommanderTest

* sonar fix - add test cases for CommanderTest

* sonar bug fix & test cases

* sonar bug fix & test cases

* sonar bug fix & test cases

* sonar bug fix & test cases

* sonar bug fix & test cases

* Revert "sonar bug fix & test cases"

This reverts commit 640dd55e35a9730e981d14665913f3d9b5b2d3b2.

* sonar bug fix & test cases

* sonar bug fix & test cases

* sonar bug fix & test cases

* sonar bug fix : avoid Thread.sleep

* sonar bug fix : cleanup Thread.sleep

* sonar bug fix: test commit

* sonar bug fix: test commit

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: atayal <Ankush_Tayal@intuit.com>
2021-12-16 20:05:13 +05:30
Ilkka Seppälä
fee898cd27
fix: Add language to claim check frontmatter (#1928)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-12-16 20:00:25 +05:30
Ilkka Seppälä
b1242629c8
fix: Grammatical fixes for Adapter (#1783)
* Grammatical fixes

* Update adapter/README.md

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-12-16 19:59:06 +05:30
allcontributors[bot]
5d78a77b97
docs: add Shrirang97 as a contributor for review, code (#1927)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-12-11 17:08:30 +02:00
Shrirang
9063336687
feature: Claim check pattern azure (#1897)
* Archietecture Diagram added

* Added pom.xml

* Architecture Diagram Updated

* Added Microservices and kafka

* ReadME File Added

* ReadME file Updated

* #1329 ReadMe file updated and working pattern code added

* #1329 readme file updated

* #1329 readme file updated and java documentation added

* #1329 repository merged

* Update claim-check-pattern/ReadME.md

#1329 Real world description updated

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 Update claim-check-pattern/ReadME.md

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 Applicability section in ReadMe file updated

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 Tutorial section in ReadMe file updated

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 Storage Data section in ReadMe File updated

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 workflow section Update claim-check-pattern/ReadME.md

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 Update claim-check-pattern/pom.xml

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 deleted mvnw.cmd file

* #1329 deleted  drawio file

* #1329 deleted mvnw file

* #1329 deleted mvnw file

* #1329 mvnw.cmd file deleted

* #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/MessageHeader.java

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/UsageCostDetail.java

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/UsageDetail.java

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 deleted mvnw file

* #1329 deleted mvnw.cmd file

* #1329 Update claim-check-pattern/usage-detail-sender/src/main/java/com/callusage/domain/Message.java

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 Update claim-check-pattern/ReadME.md

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>

* #1329 pom file dependencies fixed, readmeflie updated, removed unused imports

* #1329 Readfile updated, class javadoc added

* #1329  UML class diagrams added, readme file updated

* #1329  lombok annotations used on model classes, common dependencies moved to parent pom

* #1329  test cases added

* include claim-check-pattern in parent pom

* #1329 code smells fixed

* #1329 code smells removed

* #1329 security issues fixed

* #1329 updated pom files and refactored packages name

* #1329 checkstyle warning fixed

* #1329 code coverage increased

* #1329 minor changed.

* checkpoint created with common utility

* Claim-Check-Pattern | Shrirang97 | Implemented using Java Azure Functions

* Claim-Check-Pattern | Shrirang97 | Updated Functions logic

* Update MessageHandlerUtility.java

* Update UsageCostProcessorFunction.java

* claim-check-pattern | Shrirang97 | Added test cases

* claim-check-pattern | Shrirang97 | Test cases for Azure functions fixed

* Claim-Check-Pattern | Shrirang | Used string as request body

* claim-check-pattern | Shrirang | Working test cases

* claim-check-pattern | Shrirang | Issue fixed while deserializing

* claim-check-pattern | Shrirang | removed unused import

* claim-check-pattern | Shrirang | fixed refactoring

* claim-chek-pattern | Shrirang | added lombok | fixed dependencies & test cases

* Delete .DS_Store

* claim-check-pattern | Shrirang | Fixed unrelated file

* Update BookService.java

* Update BookService.java

* claim-check-pattern | Shrirang | Fixed unrelated files

* claim-check-pattern | Shrirang | Fixed review comments

* Update UsageCostProcessorFunction.java

* Update ReadME.md

* Rename ReadME.md to README.md

* claim-check-pattern | Shrirang | Incorporated review comments.

* Update cloud-claim-check-pattern/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update cloud-claim-check-pattern/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update cloud-claim-check-pattern/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update cloud-claim-check-pattern/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update cloud-claim-check-pattern/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update cloud-claim-check-pattern/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update cloud-claim-check-pattern/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Updated readme file

* Read me file updated | Added more description

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2021-12-11 16:59:36 +02:00
allcontributors[bot]
b22c8bc32f
docs: add Kevinyl3 as a contributor for review (#1926)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-12-11 16:34:05 +02:00
allcontributors[bot]
f7fc48d6b7
docs: add vashisthabhinav as a contributor for doc (#1921)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-12-06 11:59:55 +02:00
Abhinav Vashisth
414e3263b1
docs: Correcting some grammatical errors of README.md (#1911)
* Update README.md

Corrected some sentences grammatically.

* Update README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2021-12-06 11:56:46 +02:00
Ilkka Seppälä
2674cb9523
Set version for the next development iteration 2021-11-11 21:49:55 +02:00
Ilkka Seppälä
925755fa35
Reach milestone 1.25.0 2021-11-11 21:47:49 +02:00
Zhang WH
89b2072131
fix: use double check to fix concurrent problem (#1909)
Co-authored-by: zhangwenhe <zhangwh@ehualu.com>
2021-11-11 19:46:24 +02:00
allcontributors[bot]
0a7b524bd1
docs: add harshalkh as a contributor for code (#1900)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-31 09:12:05 +02:00
Harshal
36c6ce1df7
sonar fix: Update App.java (#1896)
* Update App.java

Sonar issue fix

* Update App.java
2021-10-31 09:10:58 +02:00
Harshal
22ddd57146
sonar fix: Update App.java (#1898) 2021-10-31 09:08:49 +02:00
Subhrodip Mohanta
72bb189dc0
CI: Update Workflows (#1879)
* Update Workflows

#1875

* Updated requested changes
2021-10-27 21:44:00 +03:00
Fiordy
bee1283371
docs: updated example with lombok as per code (#1891) 2021-10-24 17:27:24 +03:00
allcontributors[bot]
785cbf42b7
docs: add Fiordy as a contributor for doc (#1890)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-24 09:51:18 +03:00
Fiordy
c51eb66c89
docs: abstract-factory - readme - corrected code description as per real file (#1887) 2021-10-24 09:49:52 +03:00
allcontributors[bot]
1eb74203fc
docs: add uh-zz as a contributor for translation (#1889)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-24 09:41:49 +03:00
Reo Uehara
c6803f920d
translation: Add Japanese README (#1885) 2021-10-24 09:40:05 +03:00
Anum Amin
b80ac39e1f
docs: Add tutorial link for Acyclic Visitor pattern (#525) (#1884) 2021-10-24 09:23:12 +03:00
Anum Amin
da6d20e997
docs: Add tutorial links for Builder pattern (#525) (#1883) 2021-10-24 09:11:34 +03:00
Anum Amin
5dbb176a33
docs: Add tutorial links for Adapter pattern (#525) (#1882) 2021-10-24 09:09:06 +03:00
Anum Amin
e3c3b02efd
docs: Add tutorial links for Active object pattern (#525) (#1881) 2021-10-24 09:06:15 +03:00
allcontributors[bot]
988c478ad4
docs: add blueberry404 as a contributor for doc (#1888)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-24 09:04:52 +03:00
Anum Amin
221daf5d74
docs: Add tutorial links for Visitor pattern (#525) (#1880) 2021-10-24 09:03:29 +03:00
allcontributors[bot]
90b1b922e1
docs: add ManviGoel26 as a contributor for doc (#1878)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-21 21:15:45 +03:00
Manvi Goel
bd71bc1311
docs: add explanation for twin pattern (#1869)
* add explanation for twin pattern

* updated explanation of twin pattern
2021-10-21 21:14:10 +03:00
allcontributors[bot]
54d19d4c87
docs: add carldea as a contributor for code (#1876)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Removed Conflicts

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Subhrodip Mohanta <contact@subho.xyz>
2021-10-21 23:39:05 +05:30
allcontributors[bot]
464b166fa3
docs: add Mozartuss as a contributor for translation (#1877)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-21 20:40:58 +03:00
Mozartus
78abdb4e13
Fix typo, grammer and links (#1874) 2021-10-21 20:39:34 +03:00
Carl Dea
d1c26f9d84
task: update GHA JDK build vendor from adopt build to Zulu (#1868)
* Using the latest LTS and fixed (major) versions of the OpenJDK.
Signed-off-by: Carl Dea <carldea@gmail.com>

* Using the latest LTS and fixed (major) versions of the OpenJDK. Removed 17 & 18-ea releases.
Signed-off-by: Carl Dea <carldea@gmail.com>

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
2021-10-21 21:00:45 +05:30
Mozartus
ba51a49802
translation: Add a German README (#1872)
* Add German Readme

* Add german readme
2021-10-20 21:29:15 +03:00
Victor
73eca64b9f
refactoring: Issue-1694: Improve caching pattern code quality (#1810)
* Changed database implementation. Removed static objects.

* Fix Logs

* Fix 40 errors from checkstyle plugin run. 139 left))

* Fix CacheStore errors from checkstyle plugin 107 left

* Fix last errors in checkstyle.

* Fix sonar issues

* Fix issues in VALIDATE phase

* Fix Bug with mongo connection. Used "Try with resources"

* Add test

* Added docker-compose for mongo db. MongoDb db work fixed.

* Provided missing tests

* Comments to start Application with mongo.

* Fixes according PR comments. Mainly Readme edits.

* Remove duplicated imports
2021-10-20 20:44:01 +03:00
Subhrodip Mohanta
8aac45ab69
maintenance: Update Spacing of XML (#1866)
PR Set 4 of 4
2021-10-19 20:56:44 +03:00
Subhrodip Mohanta
2c93c81cf9
maintenance: Update Spacing of XML (#1865)
PR Set 3 of 4
2021-10-19 20:54:24 +03:00
Subhrodip Mohanta
656b441e29
maintenance: Update Spacing of XML (#1864)
PR Set 2 of 4
2021-10-19 20:51:43 +03:00
Subhrodip Mohanta
37d9ff3342
maintenance: Update Spacing of XML (#1863)
PR Set 1 of 4
2021-10-19 20:49:46 +03:00
Subhrodip Mohanta
d9dae3ae6a
doc fix: Recalculate already added rows. (#1862) 2021-10-19 20:06:38 +03:00
Subhrodip Mohanta
1354bf0f55
docs: Update README.md to accommodate 7 contributors per row (#1854)
* Update per line Contributor to 7 from 4

This will be helpful to reduce page size and shorten the length of the README, which is our landing page in GitHub and help us make it clutter free

* Update the Readme to accommodate upto 7 rows
2021-10-16 20:19:25 +03:00
allcontributors[bot]
dc7c99c32f
docs: add Dev-AliGhasemi as a contributor for code (#1861)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-16 20:11:23 +03:00
Ali Ghasemi
c2786e5dc4
add monitor design pattern (#1640)
* add monitor design pattern .

* add extra line and change compiler version to 11 in pom.xml.

* encapsulate getBalance method .

* update puml file .

* export uml as png .

* duplicate codes eliminated .

* update tag

* change the format of pom.xml

* using logger to print

* change AtomicRefrence to type inference var

* explanations added !

* Update monitor/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update monitor/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update monitor/src/main/java/com/iluwatar/monitor/Main.java

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update monitor/src/main/java/com/iluwatar/monitor/Main.java

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update monitor/src/main/java/com/iluwatar/monitor/Main.java

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update monitor/src/main/java/com/iluwatar/monitor/Main.java

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* e.printStackTrace have changed to logger to prints standard output (STD OUT) .

* add programmatic example .

* Delete mvnw

* mvnw.cmd deleted .

* added mvnw from master

* AddUnitTest

* Add language to readme.md

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
Co-authored-by: Subhrodip Mohanta <subhromo@cisco.com>
Co-authored-by: Subhrodip Mohanta <contact@subho.xyz>
2021-10-16 20:08:53 +03:00
allcontributors[bot]
a1f3c6fe20
docs: add JCarlosR as a contributor for translation (#1857)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-15 20:27:23 +03:00
JCarlos
0ad44ced24
docs: Fix typos spanish readme and factory (#1834)
* Fix typos for Spanish README

* Fix typos in the factory example
2021-10-15 20:24:49 +03:00
allcontributors[bot]
4c5c0fd63e
docs: add sims-keshri as a contributor for code (#1853)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-13 13:17:48 +05:30
Simran Keshri
5a644f1092
refactoring: Critical Sonar Issues (#1833)
* Resolve Sonar Code Smell: Define a constant instead of duplicating this literal 'Space rocket <' 4 times.

* Resolve Sonar Critical Code Smell: Define a constant instead of duplicating this literal 'Error connecting to MongoDB' 4 times.

* Fix checkstyle violation.

* Resolve Sonar Critical Code Smell: Define a constant instead of duplicating this literal 'LITERAL 0' 4 times.

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-10-13 13:15:22 +05:30
Ilkka Seppälä
cab9048e06
docs: fixes for yaml frontmatter (#1851)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-10-13 12:59:55 +05:30
allcontributors[bot]
d247b6ed69
docs: add VxDxK as a contributor for translation (#1848)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-11 21:45:21 +03:00
Vadim
0a73ead12d
translation: Add Russian translation (#1846)
* Add ru url to README.md

* Create russian README.md
2021-10-11 21:43:58 +03:00
allcontributors[bot]
ddb9b14eed
docs: add muklasr as a contributor for translation (#1845)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-08 20:47:25 +03:00
Muklas Rahmanto
0255111b4e
translation: Add Indonesian translation (#1841)
* Create README.md in id

* Add README.md in id url
2021-10-08 20:45:59 +03:00
allcontributors[bot]
9513d2be58
docs: add Conhan93 as a contributor for doc (#1844)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-08 20:36:02 +03:00
Conny Hansson
119abf3ee4
Doc: Corrected a few spelling mistakes (#1840) 2021-10-08 20:34:47 +03:00
allcontributors[bot]
87cc4df14b
docs: Add frascu as a Contributor for Code (#1835)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-10-05 10:07:07 +05:30
Francesco Scuccimarri
57f9c2e968
task: Update Lombok to version 1.18.20 (#1828)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-10-05 10:05:20 +05:30
Ilkka Seppälä
42eb7950ae
task: Fix broken links (#1817)
* Fix some broken links

* Remove extra space

* Update filename

* Fix some links in localization folders

* Fix link

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-09-29 00:13:31 +05:30
allcontributors[bot]
be72a96cd6
docs: add tan31989 as a contributor for code (#1820)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-09-29 00:11:14 +05:30
Nagaraj Tantri
be25c0b433
bug-fix: Use Junit5 in the serverless module tests (#1794)
* #1667: Fixing the serverless tests to use Junit5 and also modifying other classes to remove the deprecated initMock() method

* #1667: Fixing the sonar code smells

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-09-29 00:09:19 +05:30
Alain
be59e50205
doc: Fix Typos in French local doc (#1818)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-09-28 21:49:30 +05:30
allcontributors[bot]
ec90320eda
docs: add mortezaadi as a contributor for code (#1816)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-09-07 21:46:23 +03:00
Morteza Adigozalpour
3126ad3106
fix: Remove unnecessary and possibly not threadsafe flag (#1811) 2021-09-07 21:43:47 +03:00
allcontributors[bot]
e2ebb59fe7
docs: add karthikbhat13 as a contributor for code (#1808)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-08-08 15:53:13 +03:00
karthikbhat13
d87e8cf10d
feature: Added FanOut/FanIn Pattern (#1800)
* Added FanOut/FanIn Pattern (#8)

* #1627 adding fanout-fanin pattern

* #1627 adding class diagram image

* #1627 adding readme

* #1627 adding license

* #1627 updating relations

* #1627 interrupting the thread

* #1627 fixing sonar issues

* #1627 fixing sonar issues

* #1627 adding more info in README.md

* Added FanOut/FanIn (#9)

* #1627 adding fanout-fanin pattern

* #1627 adding class diagram image

* #1627 adding readme

* #1627 adding license

* #1627 updating relations

* #1627 interrupting the thread

* #1627 fixing sonar issues

* #1627 fixing sonar issues

* #1627 adding more info in README.md

* #1627 adding programmatic examples in README.md
2021-08-08 15:51:27 +03:00
Mike Liu
c5a4068e84
docs: Translation for zh (#1805)
* add state and callback pattern

* add command and template-method pattern

* add iterator pattern

* add bridege and DI pattern

* fix issue #1600

* add converter,proxy,visitor pattern

* add caching,composite,delegation,dirty-flag,interpreter patterns

* add dao and producer-consumer

* add dto and provate class data pattern

* fix #1646 png path problems

* fix #1646 composite png path case problem

* add abstract document pattern and version-number pattern

* add ambassador pattern

* add acyclic-visitor and api-gateway pattern

* add abstract-factory pattern

* add active-object pattern

* add aggregator-microservices and arrange-act-assert pattern

* update async-method-invocation pattern

* add balking and business-delegate pattern

* add bytecode and circuit-break pattern

* update arrange/act/assert pattern problems

* add csch pattern

* add language code, correct pic path

* #1805 update permalink

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
Co-authored-by: Mike <admin@xiaod.info>
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2021-08-01 20:25:54 +05:30
Ilkka Seppälä
d36efdbc7c
TASK: Add language to yaml front matter (#1806) 2021-07-25 17:28:54 +05:30
allcontributors[bot]
3f654ab0c8
docs: add AndriyPyzh as a contributor for code (#1804)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-07-22 17:00:52 +03:00
AndriyPyzh
eac85678f0
feature: Added Domain Model pattern (#1795)
* domain-model pattern

* fixed optional get before check isPresent

* readme minor changes

* change currency representation with joda money

* changed names of test methods

* fixed code smells

* Update domain-model/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* Update domain-model/README.md

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>

* updated readme and diagrams

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2021-07-22 16:58:21 +03:00
allcontributors[bot]
eaeb6e717c
docs: add marlo2222 as a contributor for translation (#1798)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-07-09 10:47:34 +03:00
Marlo Henrique
28fc672a2f
translation: portuguese translation and languages codes (#1792)
* portuguese translation and languages codes

* fix unlinked links

Co-authored-by: Marlo Henrique de Lima Oliveira <marlo.oliveira@rsinet.com.br>
2021-07-09 10:44:06 +03:00
Ilkka Seppälä
04bf566dc1
task: Explanations and grammar fixes for all the GoF patterns (#1791)
* Grammatical fixes to command pattern

* Update bridge pattern readme

* Fixes to builder pattern grammar

* Update chain of responsibility

* Improvements to the composite example

* Fixes to headings

* Minor updates to decorator pattern

* Update facade

* Update factory example

* Update factory method

* Update flyweight

* Interpreter explanation

* Update iterator readme

* Add explanation for mediator pattern

* Grammatical fixes to memento

* Grammar fixes for observer

* Update explanation for the prototype pattern

* Proxy pattern grammar fixes

* Update singleton

* Grammar fixes to state pattern

* Grammar fixes for strategy

* Grammar fixes, template method

* Grammar fixes for visitor

* Fix typo
2021-06-24 18:27:20 +05:30
jinishavora
bbdff14a66
Fix: Fixing License issue in MVVM pattern (#1701)
* Fixing License issue in MVVM pattern

* Updating LICENSE.md

* Updating pom.xml

* License header update to MVVM module only.

* Updating pom and removing gpl txt

* Adding gpl txt file

Co-authored-by: Jinisha <Jinisha@LAPTOP-VG38PNMC.fios-router.home>
2021-06-08 21:40:24 +03:00
allcontributors[bot]
eade10a98d
docs: add samuelpsouza as a contributor (#1785)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-06-07 22:32:23 +05:30
Samuel Souza
43e7ca515a
refactor: #1012 - Resolve Sonar report: missing assertions in several AppTest classes (#1784)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-06-07 22:30:44 +05:30
Ilkka Seppälä
f6d43975fa
docs: Grammatical fixes for Abstract Factory (#1782)
* Grammatical fixes

* Update abstract-factory/README.md

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-06-05 13:03:25 +05:30
allcontributors[bot]
c0d36894c2
docs: add Xenilo137 as a contributor (#1781)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-06-04 21:54:17 +03:00
Xenilo137
6cf025447a
fix: change 'swinged' to 'swung' in sword.java and hammer.java of bridge pattern (#1779)
* minor (non-coding) change

* Update Sword.java
2021-06-04 21:50:40 +03:00
allcontributors[bot]
dafe02f1be
docs: add JuanManuelAbate as a contributor (#1780)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-06-04 21:39:47 +03:00
Juan Manuel Abate
784cdee819
localizations: #1771 Spanish translation and languages codes (#1777)
* #1771 Move translations to a new directory to have more organization

* #1771 spanish translation

* #1771 change the language codes to follow ISO 639-1 and change the links

* #1771 remove country flags
2021-06-04 21:36:42 +03:00
Subhrodip Mohanta
5e434b783e
fix: added license headers to newly created files (#1775) 2021-05-31 22:39:42 +03:00
JackieNim
f597fc1b07
fix: Fixed pages showing up in wrong language (#1752)
* Fix languages

* Missed change for version number

* Add language field for presentation

* Revert change in README for double buffer

Co-authored-by: Jackie Nim <=>
2021-05-19 19:49:05 +03:00
allcontributors[bot]
1b880c1818
docs: add tao-sun2 as a contributor (#1757)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-05-17 22:09:29 +03:00
Tao
e498c25675
feature: #1319 add table module pattern (#1742)
* modify table module pattern

* fix code smells

* resolve conversation

Co-authored-by: tao-sun2 <sustc18st@gmai.com>
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2021-05-17 22:06:35 +03:00
Noam Greenshtain
122e6edb38
feature: resolve #1282 for Lockable Object pattern. (#1702)
* Added Lockable-Object pattern. Closes #1282.

* Refactor method name.

* Refactor sonar lint bugs.

* Added tests and enum Constants.

* Increase coverage.

* Changed @Data to Getters and Setters.

* Iluwatar's comment on pull request #1702.

* Fixed codes mells.

* Incremented wait time to 3 seconds.

* Reduced wait time to 2 seconds.

* Cleaned Code Smells.

* Incremented wait time, removed cool down.

* Refactored README.md file.

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
2021-05-14 21:26:41 +05:30
allcontributors[bot]
ea3c9d955e
docs: add EdisonE3 as a contributor (#1751)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-05-11 19:17:36 +05:30
EdisonE3
f1feb3f6a0
feature: Implement Presentation Model Pattern (#1710)
* #415 initial all componets

* #415 add src and tests

* #415 add diagram

* #415 add README

* #415 add README

* #415 change pom.xml

* #415 change pom.xml

* #415 change pom.xml

* #415 update pom.xml

* #415 change some code smell

* #415 change some code smell

* #415 update test

* #415 add javadoc

* #415 remove author tag

* #415 add lombok @AllArgsConstructor

* #415 fix code converge

* #415 fix code converge

* #415 fix code converge

* #415 add javadoc

* #415 fix code smell

* #415 fix code smell

* #415 add log information

* #415 remove unused import

* #415 add javadoc and more test

* #415 modify test

* #415 fix checkstyle

* #415 remove useless code and add more javadoc and test.

* #415 add package-info.java.

* #415 add package-info.java.

* #415 add more test.

* #415 fix code smell.

* #415 fix code smell and increase code coverage.

* #415 fix code smell.

* #415 update README.md

* #415 update README.md

* #415 make this demo better

* #415 satisfy checkstyle

* #415 make some field static.

* #415 make some fields static.

* #415 rename some fields static.

* Delete package-info.java

Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
2021-05-11 19:16:11 +05:30
VR
1388e38744
docs: Correcting the URL to fix #1747 (#1748)
* Correcting the Hyperlink to redirect to the correct URL.
Corresponds to bug #1703

* Deleting the extra Hyphen(-) that was incorrectly added.

* Corrected the contributors inside the Readme file.

Updated the correct number of contributors to be in sync with `master`

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-05-11 16:30:30 +05:30
allcontributors[bot]
1dd26289e5
docs: add JackieNim as a contributor (#1749)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-05-09 17:00:47 +03:00
allcontributors[bot]
241a7ad9a2
docs: add DEV-VRUPER as a contributor (#1746)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-05-07 00:01:23 +05:30
VR
32b33480dd
docs: Correcting the Hyperlink to redirect to correct URL. (#1745)
Corresponds to bug #1703

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-05-06 23:55:29 +05:30
余林颖
068fa0371e
docs: Translate some of the README docs into Chinese (#1744)
* docs: translated docs to zh

* docs: translated doc of sharding pattern to Chinese

* docs: translated doc of factory pattern to Chinese

* docs: translated doc of factory-kit pattern to Chinese

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-05-06 23:27:16 +05:30
余林颖
b5aaa94794
docs: replace more suitable translation (#1743)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-05-03 20:25:57 +05:30
余林颖
825b5a9a29
docs: translated the async method invocation pattern into Chinese (#1741) 2021-05-02 20:34:34 +03:00
Subhrodip Mohanta
31890f67e6
updated with neccessary changes (#1709) 2021-05-01 21:22:35 +03:00
dependabot-preview[bot]
41b1462eed
[Security] Bump spring-webmvc from 5.0.13.RELEASE to 5.0.17.RELEASE (#1739)
Bumps [spring-webmvc](https://github.com/spring-projects/spring-framework) from 5.0.13.RELEASE to 5.0.17.RELEASE. **This update includes a security fix.**
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.0.13.RELEASE...v5.0.17.RELEASE)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-05-01 10:29:50 +05:30
dependabot-preview[bot]
276549d156
[Security] Bump jackson.version from 2.10.2 to 2.12.3 (#1738)
Bumps `jackson.version` from 2.10.2 to 2.12.3.

Updates `jackson-core` from 2.10.2 to 2.12.3
- [Release notes](https://github.com/FasterXML/jackson-core/releases)
- [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.10.2...jackson-core-2.12.3)

Updates `jackson-databind` from 2.10.2 to 2.12.3
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

Updates `jackson-annotations` from 2.10.2 to 2.12.3
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-05-01 10:29:05 +05:30
allcontributors[bot]
d67b625a74
docs: add STudio26 as a contributor (#1735)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-04-29 18:55:41 +05:30
Alain
1b14ebcbb1
Improve french translation, fix some typographic issues. (#1730)
* Improve french translation, fix some typographic issues.

* Improve french translation.

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-04-29 18:54:03 +05:30
余林颖
a471ce25da
translated the balking pattern into Chinese (#1727)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-04-29 18:51:14 +05:30
allcontributors[bot]
74caa0c4e5
docs: add Al-assad as a contributor (#1733)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-04-29 18:49:45 +05:30
余林颖
53a294fee5
translated the business delegate pattern into Chinese (#1728)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-04-29 18:47:40 +05:30
dependabot-preview[bot]
a5062908c0
[Security] Bump commons-io from 2.6 to 2.7 (#1731)
Bumps commons-io from 2.6 to 2.7. **This update includes a security fix.**

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-04-29 18:39:54 +05:30
dependabot[bot]
076310bb79
Bump commons-io from 2.6 to 2.7 (#1729)
Bumps commons-io from 2.6 to 2.7.

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-27 13:36:24 +05:30
Kevin Lee
470d29e715
docs: Translated the strategy pattern into Korean (#1708)
* Correct README.md in Korean

Spelling correction and human-readable paraphrase on ko/README.md. Previously, it was translated using a machine translator.

* Add strategy pattern into Korean

Add and translate the strategy pattern into Korean.

* Remove source file from the translated folder

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-04-26 14:46:15 +05:30
allcontributors[bot]
74802e83b5
docs: add zWeBrain as a contributor (#1725)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-04-26 13:48:16 +05:30
zWeBrain
09b577f634
task: Add Composite Entity pattern (#1705)
* add composite entity pattern

* add composite entity pattern

* Update ReactorTest.java

* resolve some code quality problems

* modified a lot

* remove some extra codes

* modified README

* removed the author name and adjusted the spacing

Co-authored-by: zwebrain <11811721@mail.sustech.edu.cn>
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-04-26 13:45:52 +05:30
Mike Liu
2fce2e44e2
docs: Chinese translations updates (#1706)
* add state and callback pattern

* add command and template-method pattern

* add iterator pattern

* add bridege and DI pattern

* fix issue #1600

* add converter,proxy,visitor pattern

* add caching,composite,delegation,dirty-flag,interpreter patterns

* add dao and producer-consumer

* add dto and provate class data pattern

* fix #1646 png path problems

* fix #1646 composite png path case problem

* add abstract document pattern and version-number pattern

* add ambassador pattern

* add acyclic-visitor and api-gateway pattern

* add abstract-factory pattern

* add active-object pattern

* add aggregator-microservices and arrange-act-assert pattern

Co-authored-by: Mike <admin@xiaod.info>
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2021-04-26 13:28:01 +05:30
allcontributors[bot]
b3a1749bd0
docs: add eas5 as a contributor (#1711)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-04-26 13:06:33 +05:30
Elvys Soares
af0ccdc6e1
refactoring: Added parameterization to enumeration test (#1698)
Signed-off-by: Elvys Soares <eas5@cin.ufpe.br>

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-04-22 11:47:45 +05:30
Subhrodip Mohanta
323dd63e66
update distribution for java to 'adpot' (#1699) 2021-04-18 12:53:19 +03:00
Ilkka Seppälä
be3250bd0d
Set version for the next development iteration 2021-04-05 14:57:36 +03:00
Ilkka Seppälä
1222f12b99
Set version number for milestone 1.24.0 2021-04-05 14:56:36 +03:00
allcontributors[bot]
965d38f139
docs: add ohbus as a contributor (#1695)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2021-03-28 18:20:04 +03:00
Ilkka Seppälä
eb8f9db575
#590 add explanation for caching pattern (#1693)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-28 16:32:29 +05:30
Subhrodip Mohanta
6d7084f18d
remove labelling trigger (#1692) 2021-03-28 10:15:42 +03:00
allcontributors[bot]
74f5cfa670
docs: add jinishavora as a contributor (#1688)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
2021-03-23 14:12:32 +05:30
Ilkka Seppälä
b525d871b4
docs: Fix mvvm readme (#1689) 2021-03-23 11:29:20 +05:30
Ilkka Seppälä
c413e0902e
docs: #590 add explanation for bytecode pattern (#1687)
Type: docs and refactoring

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-22 12:19:46 +05:30
Ilkka Seppälä
7ac468db20
docs: #590 refactor and add explanation for business delegate (#1686)
Type: docs and refactoring

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-22 12:04:56 +05:30
jinishavora
794795acf5
task: MVVM design pattern using zkoss framework. (#1678)
* MVVM design pattern using zkoss framework.

* MVVM Design pattern updates for issues reported by SonarCloud.

* MVVM Design pattern updates for coverage issues reported by SonarCloud.

* MVVM Design pattern updates for coverage issues (removing lombok @Data)
reported by SonarCloud.

* MVVM Design pattern updates for coverage issues reported by Sonar - TEST
cases added for Equals and ToString

* MVVM Design Pattern - updating missing/todo details.

* MVVM Design Pattern - adding lombok.config

* MVVM Design Pattern - Removing xml, updating pom.xml and README as per
suggested changes in code review

* Update model-view-viewmodel/README.md

* Update model-view-viewmodel/README.md

* Update model-view-viewmodel/README.md

* Update model-view-viewmodel/README.md

* MVVM Design Pattern - Updated pom.xml and Readme based on Suggested
changes

* added type as xml

* MVVM Design Patterm - root pom.xml and module pom.xml updated

* Update pom.xml

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2021-03-22 11:43:34 +05:30
Ilkka Seppälä
2b7d181ac4
docs: add explanation for balking pattern (#1685)
* #590 explanation for balking pattern

* #590 fix checkstyle error

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-21 01:25:47 +05:30
Subhrodip Mohanta
b5ed8b2278
labeling PR should trigger builds again for all-contributors bot (#1682) 2021-03-18 22:22:37 +02:00
allcontributors[bot]
8fc64a2d38
docs: add qfxl as a contributor (#1681)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-03-18 22:13:28 +02:00
Ilkka Seppälä
7e91322a43
Add explanation to Async Method Invocation pattern (#1680)
* #590 make the example more interesting and add an explanation

* #590 fix checkstyle

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-18 11:07:34 +05:30
yonghong Xu
e9106ccfc5
fix spelling errors (#1679)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-18 10:49:45 +05:30
Ilkka Seppälä
77ffae5ecc
Format active object README.md to display correctly on the web site 2021-03-14 16:26:24 +02:00
Subhrodip Mohanta
74abc7a0d6
added license headers to active object pattern (#1676) 2021-03-14 16:08:53 +02:00
allcontributors[bot]
ccf350b611
docs: add noamgrinch as a contributor (#1675)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-03-14 16:07:39 +02:00
Noam Greenshtain
c8a2ef01d3
pattern: Active-Object pattern. (#1660)
* Closes #65.

* Removed

* Removed unnecessary files. Added logging. Closes Fixes #1660.

* Added Terminition condition.

* Logger implemented. Removed maven wrapper.

* Added module to parent POM. removed .gitignore

* Replaced tabs with whitespaces, added Javadocs.

* Fixed more whitespaces problems.

* Fixed more checkstyle errors

* More checkstyle errors.

* Checkstyle errors.

* Final checkstyle cleanup

* Added UML file. Changed System.exit() to Runtime.

* Changed buisiness logic and readme.md file

* Changed typos and readme.md file

* Fixed checkstyle errors

* Fixed grammer errors and CircleCI bugs.

* Wrong readme.md

* Added Thread.interrupt() for after catching exception.

* Fixed SonarCloud code smells.

* Removed unused brackets.

* Changed main program exit logic. Added tests.

* Reverted abstract-factory

* Cleaned code

* Added static to loggers. cleaned code smells.

* Checkstyle errors.

* Code Smells.

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-14 11:53:41 +05:30
allcontributors[bot]
cbf1847425
docs: add va1m as a contributor (#1674)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-03-13 14:31:37 +02:00
va1m
5cf2fe009b
📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code

* Fix merge conflicts and some sonar issues

Co-authored-by: va1m <va1m@email.com>
2021-03-13 14:19:21 +02:00
Subhrodip Mohanta
0e26a6adb5
Use property to set version and update dependencies (#1671)
* formatting and versioning

* updated versions

* reverted checkstyle plugin version
2021-03-07 19:16:50 +02:00
Subhrodip Mohanta
b423002e6c
updated Random() to SecureRandom() (#1670)
* updated Random() to SecureRandom()

* batch 2 of SecureRandom updates
2021-03-06 13:26:02 +02:00
CF
c150871a94
Update to JUnit5 across all modules (#1668)
* Updated saga to JUnit 5

* Update fix for CI job in trampoline module

* Updated update-method module to JUnit 5

* Upgraded to latest JUnit Jupiter
JUnit 4 is not needed when using JUnit-Vintage

* Reverted change to access modifier on Trampoline

* Cleanup to resolve code smells

* Formatting

* Formatting

* Migrating to JUnit5 and updating some Mockito patterns

* Migrating to JUnit5

* Migrating to JUnit5

* Migrating to JUnit 5

* Formatting cleanup

* Added missing scope for junit

* Fixed tests that were not running previously.

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-06 14:42:46 +05:30
Subhrodip Mohanta
e9d0b3e98c
remove labeling trigger for PR and actions set to master (#1666) 2021-03-05 19:51:09 +02:00
CF
903453229c
Updated update-method module to JUnit 5 (#1542)
* Updated saga to JUnit 5

* Update fix for CI job in trampoline module

* Updated update-method module to JUnit 5

* Upgraded to latest JUnit Jupiter
JUnit 4 is not needed when using JUnit-Vintage

* Reverted change to access modifier on Trampoline

* Cleanup to resolve code smells

* Formatting

* Formatting

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-04 10:49:31 +05:30
Subhrodip Mohanta
c3c90e2bd4
created CircleCI config for sonar analysis (#1664)
* created sonar config

#1663

* updated license headers

* xvfb to run tests

* updated circle image to enable css and JS analysis
2021-03-01 16:50:34 +02:00
Halil Demir
268e4148b4
#1625 add Turkish translation for singleton design pattern (#1665)
Co-authored-by: Halil Demir <halil.demir@zalando.de>
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
2021-03-01 19:20:06 +05:30
allcontributors[bot]
0220f3df12
docs: add richardmr36 as a contributor (#1662)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-02-28 11:51:47 +02:00
1333 changed files with 30805 additions and 12937 deletions

View File

@ -16,6 +16,17 @@
"content"
]
},
{
"login": "ohbus",
"name": "Subhrodip Mohanta",
"avatar_url": "https://avatars0.githubusercontent.com/u/13291222?v=4",
"profile": "http://subho.xyz",
"contributions": [
"code",
"review",
"maintenance"
]
},
{
"login": "amit1307",
"name": "amit1307",
@ -1125,16 +1136,6 @@
"ideas"
]
},
{
"login": "ohbus",
"name": "Subhrodip Mohanta",
"avatar_url": "https://avatars0.githubusercontent.com/u/13291222?v=4",
"profile": "http://subho.xyz",
"contributions": [
"code",
"review"
]
},
{
"login": "nahteb",
"name": "Bethan Palmer",
@ -1404,9 +1405,408 @@
"contributions": [
"translation"
]
},
{
"login": "richardmr36",
"name": "Martel Richard",
"avatar_url": "https://avatars.githubusercontent.com/u/19147333?v=4",
"profile": "https://github.com/richardmr36",
"contributions": [
"code"
]
},
{
"login": "va1m",
"name": "va1m",
"avatar_url": "https://avatars.githubusercontent.com/u/17025445?v=4",
"profile": "https://github.com/va1m",
"contributions": [
"code"
]
},
{
"login": "noamgrinch",
"name": "Noam Greenshtain",
"avatar_url": "https://avatars.githubusercontent.com/u/31648669?v=4",
"profile": "https://github.com/noamgrinch",
"contributions": [
"code"
]
},
{
"login": "qfxl",
"name": "yonghong Xu",
"avatar_url": "https://avatars.githubusercontent.com/u/14086462?v=4",
"profile": "https://xuyonghong.cn/",
"contributions": [
"doc"
]
},
{
"login": "jinishavora",
"name": "jinishavora",
"avatar_url": "https://avatars.githubusercontent.com/u/40777762?v=4",
"profile": "https://www.linkedin.com/in/jinisha-vora",
"contributions": [
"review",
"code"
]
},
{
"login": "eas5",
"name": "Elvys Soares",
"avatar_url": "https://avatars.githubusercontent.com/u/50836521?v=4",
"profile": "https://github.com/eas5",
"contributions": [
"code"
]
},
{
"login": "zWeBrain",
"name": "zWeBrain",
"avatar_url": "https://avatars.githubusercontent.com/u/46642512?v=4",
"profile": "https://github.com/zWeBrain",
"contributions": [
"code"
]
},
{
"login": "Al-assad",
"name": "余林颖",
"avatar_url": "https://avatars.githubusercontent.com/u/22493821?v=4",
"profile": "https://al-assad.github.io/notion/",
"contributions": [
"translation"
]
},
{
"login": "STudio26",
"name": "Alain",
"avatar_url": "https://avatars.githubusercontent.com/u/6988911?v=4",
"profile": "https://github.com/STudio26",
"contributions": [
"translation"
]
},
{
"login": "DEV-VRUPER",
"name": "VR",
"avatar_url": "https://avatars.githubusercontent.com/u/30525467?v=4",
"profile": "https://github.com/DEV-VRUPER",
"contributions": [
"doc"
]
},
{
"login": "JackieNim",
"name": "JackieNim",
"avatar_url": "https://avatars.githubusercontent.com/u/4138836?v=4",
"profile": "https://github.com/JackieNim",
"contributions": [
"code"
]
},
{
"login": "EdisonE3",
"name": "EdisonE3",
"avatar_url": "https://avatars.githubusercontent.com/u/52118917?v=4",
"profile": "https://github.com/EdisonE3",
"contributions": [
"code"
]
},
{
"login": "tao-sun2",
"name": "Tao",
"avatar_url": "https://avatars.githubusercontent.com/u/66189688?v=4",
"profile": "https://github.com/tao-sun2",
"contributions": [
"code"
]
},
{
"login": "JuanManuelAbate",
"name": "Juan Manuel Abate",
"avatar_url": "https://avatars.githubusercontent.com/u/16357060?v=4",
"profile": "https://github.com/JuanManuelAbate",
"contributions": [
"translation"
]
},
{
"login": "Xenilo137",
"name": "Xenilo137",
"avatar_url": "https://avatars.githubusercontent.com/u/24865069?v=4",
"profile": "https://github.com/Xenilo137",
"contributions": [
"code"
]
},
{
"login": "samuelpsouza",
"name": "Samuel Souza",
"avatar_url": "https://avatars.githubusercontent.com/u/17254162?v=4",
"profile": "https://www.linkedin.com/in/souzasamuel/",
"contributions": [
"code"
]
},
{
"login": "marlo2222",
"name": "Marlo Henrique",
"avatar_url": "https://avatars.githubusercontent.com/u/40809563?v=4",
"profile": "https://github.com/marlo2222",
"contributions": [
"translation"
]
},
{
"login": "AndriyPyzh",
"name": "AndriyPyzh",
"avatar_url": "https://avatars.githubusercontent.com/u/57706635?v=4",
"profile": "https://github.com/AndriyPyzh",
"contributions": [
"code"
]
},
{
"login": "karthikbhat13",
"name": "karthikbhat13",
"avatar_url": "https://avatars.githubusercontent.com/u/22431014?v=4",
"profile": "https://github.com/karthikbhat13",
"contributions": [
"code"
]
},
{
"login": "mortezaadi",
"name": "Morteza Adigozalpour",
"avatar_url": "https://avatars.githubusercontent.com/u/1329687?v=4",
"profile": "https://github.com/mortezaadi",
"contributions": [
"code"
]
},
{
"login": "tan31989",
"name": "Nagaraj Tantri",
"avatar_url": "https://avatars.githubusercontent.com/u/3784194?v=4",
"profile": "https://stackoverflow.com/users/308565/nagaraj-tantri",
"contributions": [
"code"
]
},
{
"login": "frascu",
"name": "Francesco Scuccimarri",
"avatar_url": "https://avatars.githubusercontent.com/u/7107651?v=4",
"profile": "http://scuccimarri.it",
"contributions": [
"code"
]
},
{
"login": "Conhan93",
"name": "Conny Hansson",
"avatar_url": "https://avatars.githubusercontent.com/u/71334757?v=4",
"profile": "https://github.com/Conhan93",
"contributions": [
"doc"
]
},
{
"login": "muklasr",
"name": "Muklas Rahmanto",
"avatar_url": "https://avatars.githubusercontent.com/u/43443753?v=4",
"profile": "http://muklasr.medium.com",
"contributions": [
"translation"
]
},
{
"login": "VxDxK",
"name": "Vadim",
"avatar_url": "https://avatars.githubusercontent.com/u/38704817?v=4",
"profile": "https://github.com/VxDxK",
"contributions": [
"translation"
]
},
{
"login": "sims-keshri",
"name": "Simran Keshri",
"avatar_url": "https://avatars.githubusercontent.com/u/62168475?v=4",
"profile": "https://github.com/sims-keshri",
"contributions": [
"code"
]
},
{
"login": "JCarlosR",
"name": "JCarlos",
"avatar_url": "https://avatars.githubusercontent.com/u/3101238?v=4",
"profile": "https://programacionymas.com",
"contributions": [
"translation"
]
},
{
"login": "Dev-AliGhasemi",
"name": "Ali Ghasemi",
"avatar_url": "https://avatars.githubusercontent.com/u/60359433?v=4",
"profile": "https://www.mrmoshkel.ir",
"contributions": [
"code"
]
},
{
"login": "carldea",
"name": "Carl Dea",
"avatar_url": "https://avatars.githubusercontent.com/u/1594624?v=4",
"profile": "http://carlfx.wordpress.com",
"contributions": [
"code"
]
},
{
"login": "Mozartuss",
"name": "Mozartus",
"avatar_url": "https://avatars.githubusercontent.com/u/32893711?v=4",
"profile": "https://github.com/Mozartuss",
"contributions": [
"translation"
]
},
{
"login": "ManviGoel26",
"name": "Manvi Goel",
"avatar_url": "https://avatars.githubusercontent.com/u/55682355?v=4",
"profile": "https://github.com/ManviGoel26",
"contributions": [
"doc"
]
},
{
"login": "blueberry404",
"name": "Anum Amin",
"avatar_url": "https://avatars.githubusercontent.com/u/39243539?v=4",
"profile": "https://github.com/blueberry404",
"contributions": [
"doc"
]
},
{
"login": "uh-zz",
"name": "Reo Uehara",
"avatar_url": "https://avatars.githubusercontent.com/u/47747828?v=4",
"profile": "https://uh-zz.github.io/blog/",
"contributions": [
"translation"
]
},
{
"login": "Fiordy",
"name": "Fiordy",
"avatar_url": "https://avatars.githubusercontent.com/u/53420573?v=4",
"profile": "https://github.com/Fiordy",
"contributions": [
"doc"
]
},
{
"login": "harshalkh",
"name": "Harshal",
"avatar_url": "https://avatars.githubusercontent.com/u/37841724?v=4",
"profile": "https://github.com/harshalkh",
"contributions": [
"code"
]
},
{
"login": "vashisthabhinav",
"name": "Abhinav Vashisth",
"avatar_url": "https://avatars.githubusercontent.com/u/89785800?v=4",
"profile": "https://www.linkedin.com/in/abhinav-vashisth-06613b208/",
"contributions": [
"doc"
]
},
{
"login": "Kevinyl3",
"name": "Kevin",
"avatar_url": "https://avatars.githubusercontent.com/u/47126749?v=4",
"profile": "http://no website",
"contributions": [
"review",
"code"
]
},
{
"login": "Shrirang97",
"name": "Shrirang",
"avatar_url": "https://avatars.githubusercontent.com/u/28738668?v=4",
"profile": "https://github.com/Shrirang97",
"contributions": [
"review",
"code"
]
},
{
"login": "interactwithankush",
"name": "interactwithankush",
"avatar_url": "https://avatars.githubusercontent.com/u/18613127?v=4",
"profile": "https://github.com/interactwithankush",
"contributions": [
"code"
]
},
{
"login": "yuhangbin",
"name": "CharlieYu",
"avatar_url": "https://avatars.githubusercontent.com/u/17566866?v=4",
"profile": "https://github.com/yuhangbin",
"contributions": [
"code"
]
},
{
"login": "Leisterbecker",
"name": "Leisterbecker",
"avatar_url": "https://avatars.githubusercontent.com/u/20650323?v=4",
"profile": "https://github.com/Leisterbecker",
"contributions": [
"code"
]
},
{
"login": "castleKing1997",
"name": "DragonDreamer",
"avatar_url": "https://avatars.githubusercontent.com/u/35420129?v=4",
"profile": "http://rosaecrucis.cn",
"contributions": [
"code"
]
},
{
"login": "ShivanshCharak",
"name": "ShivanshCharak",
"avatar_url": "https://avatars.githubusercontent.com/u/96943825?v=4",
"profile": "https://github.com/ShivanshCharak",
"contributions": [
"code"
]
},
{
"login": "HattoriHenzo",
"name": "HattoriHenzo",
"avatar_url": "https://avatars.githubusercontent.com/u/5141285?v=4",
"profile": "https://github.com/HattoriHenzo",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 4,
"contributorsPerLine": 7,
"projectName": "java-design-patterns",
"projectOwner": "iluwatar",
"repoType": "github",

52
.circleci/config.yml Normal file
View File

@ -0,0 +1,52 @@
#
# The MIT License
# Copyright © 2014-2021 Ilkka Seppälä
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
version: 2
jobs:
sonar-pr:
docker:
- image: circleci/openjdk:11-node
steps:
- checkout
- restore_cache:
key: jdp-sonar-pr-{{ checksum "pom.xml" }}
- run: |
if [ -n "${CIRCLE_PR_NUMBER}" ]; then
MAVEN_OPTS="-Xmx3000m" xvfb-run ./mvnw -B clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.pullrequest.key=${CIRCLE_PR_NUMBER} \
-Dsonar.pullrequest.branch=${CIRCLE_BRANCH} \
-Dsonar.pullrequest.base=master
else
echo "No Sonar PR analysis as this is not a pull request"
fi
- save_cache:
key: jdp-sonar-pr-{{ checksum "pom.xml" }}
paths:
- ~/.m2
workflows:
version: 2
all:
jobs:
- sonar-pr

View File

@ -24,6 +24,9 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
# We are using two jobs here for testing our code on the latest JDK 11 build as well as a more satble build version of 11.0.3
# You can see the full discussion here https://github.com/iluwatar/java-design-patterns/pull/1868#issue-1029459688
name: Java CI
on:
@ -33,10 +36,11 @@ on:
jobs:
build:
# This Workflow Job will build this project and run Sonar analysis using JDK 11.0.3
build-and-analyze:
name: Build and Run Sonar analysis on JDK 11.0.3
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
@ -45,11 +49,14 @@ jobs:
# Disabling shallow clone for improving relevancy of SonarQube reporting
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 11.0.3
uses: actions/setup-java@v2
with:
java-version: 11
java-version: 11.0.3
distribution: 'zulu'
cache: 'maven'
# Cache Sonar packages which as used to run anaylysis and collect metrics
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
@ -57,24 +64,38 @@ jobs:
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Some tests need screen access
- name: Install xvfb
run: sudo apt-get install -y xvfb
# The SonarQube analysis is only for the master branch of the main repository.
# SonarQube scan does not work for forked repositories try changing it to xvfb-run mvn clean verify
# See https://jira.sonarsource.com/browse/MMF-1371
- name: Build with Maven and run SonarQube analysis
run: xvfb-run ./mvnw clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
env:
# These two env variables are needed for sonar analysis
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# This Workflow Job is going to build the project on the latest stable JDK 11
build:
name: Build and Test on JDK 11
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up JDK 11 (Latest)
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'zulu'
cache: 'maven'
# Some tests need screen access
- name: Install xvfb
run: sudo apt-get install -y xvfb
- name: Build with Maven
run: xvfb-run ./mvnw clean verify

View File

@ -29,36 +29,31 @@ name: Java PR Builder
on:
pull_request:
branches: [ master ]
types: [ opened, reopened, synchronize, labeled, unlabeled ]
types: [ opened, reopened, synchronize ]
jobs:
build:
name: Build JDP
runs-on: ubuntu-20.04
strategy:
matrix:
java-version: [ 11.0.3, 11 ]
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v2
with:
java-version: 11
- name: Cache Maven Dependecies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
java-version: ${{ matrix.java-version }}
distribution: 'zulu'
cache: 'maven'
# Some tests need screen access
- name: Install xvfb
run: sudo apt-get install -y xvfb
# This worflow is only for building Pull Requests, the master branch runs Sonar analysis on the main repository.
# SonarQube scan does not work for forked repositories.
# See https://jira.sonarsource.com/browse/MMF-1371
- name: Build with Maven
run: xvfb-run ./mvnw clean verify

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ tmp/
local.properties
.loadpath
.recommenders
.DS_Store
####### Java annotation processor (APT) ########
.factorypath

View File

@ -1,18 +1,26 @@
/*
* Copyright 2007-present the original author or authors.
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* http://www.apache.org/licenses/LICENSE-2.0
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;

View File

@ -1,25 +1,18 @@
#
# The MIT License
# Copyright © 2014-2021 Ilkka Seppälä
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2014-2021 Ilkka Seppälä
Copyright © 2014-2021 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,3 +19,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Module Model-view-viewmodel is using ZK framework
ZK framework is licensed under LGPL and the license can be found at lgpl-3.0.txt

164
README.md
View File

@ -6,22 +6,22 @@
![Java CI](https://github.com/iluwatar/java-design-patterns/workflows/Java%20CI/badge.svg)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=ncloc)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=ncloc)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-154-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-198-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<br/>
Read in different language : [![CN](/assets/flags/CN.png)**CN**](/zh/README.md), [![KR](/assets/flags/KR.png)**KR**](/ko/README.md), [![FR](/assets/flags/FR.png)**FR**](/fr/README.md), [![TR](/assets/flags/TR.png)**TR**](/tr/README.md), [![AR](/assets/flags/AR.png)**AR**](/ar/README.md)
Read in different language : [**zh**](localization/zh/README.md), [**ko**](localization/ko/README.md), [**fr**](localization/fr/README.md), [**tr**](localization/tr/README.md), [**ar**](localization/ar/README.md), [**es**](localization/es/README.md), [**pt**](localization/pt/README.md), [**id**](localization/id/README.md), [**ru**](localization/ru/README.md), [**de**](localization/de/README.md), [**ja**](localization/ja/README.md)
<br/>
# Introduction
Design patterns are the best formalized practices a programmer can use to
Design patterns are the best, formalized practices a programmer can use to
solve common problems when designing an application or system.
Design patterns can speed up the development process by providing tested, proven
@ -34,11 +34,11 @@ are familiar with the patterns.
# Getting started
This site showcases Java Design Patterns. The solutions have been developed by
experienced programmers and architects from the open source community. The
patterns can be browsed by their high level descriptions or by looking at their
source code. The source code examples are well commented and can be thought as
experienced programmers and architects from the open-source community. The
patterns can be browsed by their high-level descriptions or by looking at their
source code. The source code examples are well commented and can be thought of as
programming tutorials on how to implement a specific pattern. We use the most
popular battle-proven open source Java technologies.
popular battle-proven open-source Java technologies.
Before you dive into the material, you should be familiar with various
[Software Design Principles](https://java-design-patterns.com/principles/).
@ -49,20 +49,20 @@ patterns should only be introduced when they are needed for practical
extensibility.
Once you are familiar with these concepts you can start drilling down into the
[available design patterns](https://java-design-patterns.com/patterns/) by any
[available design patterns](https://java-design-patterns.com/patterns/) by any
of the following approaches
- Search for a specific pattern by name. Can't find one? Please report a new pattern [here](https://github.com/iluwatar/java-design-patterns/issues).
- Using tags such as `Performance`, `Gang of Four` or `Data access`.
- Using pattern categories, `Creational`, `Behavioral`, and others.
Hopefully you find the object oriented solutions presented on this site useful
in your architectures and have as much fun learning them as we had developing them.
Hopefully, you find the object-oriented solutions presented on this site useful
in your architectures and have as much fun learning them as we had while developing them.
# How to contribute
If you are willing to contribute to the project you will find the relevant information in
our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki). We will help
If you are willing to contribute to the project you will find the relevant information in
our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki). We will help
you and answer your questions in the [Gitter chatroom](https://gitter.im/iluwatar/java-design-patterns).
# License
@ -77,29 +77,26 @@ This project is licensed under the terms of the MIT license.
<table>
<tr>
<td align="center"><a href="https://github.com/iluwatar"><img src="https://avatars1.githubusercontent.com/u/582346?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ilkka Seppälä</b></sub></a><br /><a href="#projectManagement-iluwatar" title="Project Management">📆</a> <a href="#maintenance-iluwatar" title="Maintenance">🚧</a> <a href="#content-iluwatar" title="Content">🖋</a></td>
<td align="center"><a href="http://subho.xyz"><img src="https://avatars0.githubusercontent.com/u/13291222?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Subhrodip Mohanta</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ohbus" title="Code">💻</a> <a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Aohbus" title="Reviewed Pull Requests">👀</a> <a href="#maintenance-ohbus" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/amit1307"><img src="https://avatars0.githubusercontent.com/u/23420222?v=4?s=100" width="100px;" alt=""/><br /><sub><b>amit1307</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=amit1307" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/npathai"><img src="https://avatars2.githubusercontent.com/u/1792515?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Narendra Pathai</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=npathai" title="Code">💻</a> <a href="#ideas-npathai" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Anpathai" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/fluxw42"><img src="https://avatars1.githubusercontent.com/u/1545460?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Meulemeester</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=fluxw42" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://www.joemccarthy.co.uk"><img src="https://avatars0.githubusercontent.com/u/4526195?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joseph McCarthy</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mikulucky" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/thomasoss"><img src="https://avatars1.githubusercontent.com/u/22516154?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Thomas</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=thomasoss" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/anuragagarwal561994"><img src="https://avatars1.githubusercontent.com/u/6075379?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anurag Agarwal</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=anuragagarwal561994" title="Code">💻</a></td>
<td align="center"><a href="https://markusmo3.github.io"><img src="https://avatars1.githubusercontent.com/u/3317416?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Markus Moser</b></sub></a><br /><a href="#design-markusmo3" title="Design">🎨</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=markusmo3" title="Code">💻</a> <a href="#ideas-markusmo3" title="Ideas, Planning, & Feedback">🤔</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/anuragagarwal561994"><img src="https://avatars1.githubusercontent.com/u/6075379?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anurag Agarwal</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=anuragagarwal561994" title="Code">💻</a></td>
<td align="center"><a href="https://markusmo3.github.io"><img src="https://avatars1.githubusercontent.com/u/3317416?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Markus Moser</b></sub></a><br /><a href="#design-markusmo3" title="Design">🎨</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=markusmo3" title="Code">💻</a> <a href="#ideas-markusmo3" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://twitter.com/i_sabiq"><img src="https://avatars1.githubusercontent.com/u/19510920?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sabiq Ihab</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=isabiq" title="Code">💻</a></td>
<td align="center"><a href="http://inbravo.github.io"><img src="https://avatars3.githubusercontent.com/u/5253764?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Amit Dixit</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=inbravo" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/piyushchaudhari04"><img src="https://avatars3.githubusercontent.com/u/10268029?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Piyush Kailash Chaudhari</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=piyushchaudhari04" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/joshzambales"><img src="https://avatars1.githubusercontent.com/u/8704552?v=4?s=100" width="100px;" alt=""/><br /><sub><b>joshzambales</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=joshzambales" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Crossy147"><img src="https://avatars2.githubusercontent.com/u/7272996?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kamil Pietruszka</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Crossy147" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/Crossy147"><img src="https://avatars2.githubusercontent.com/u/7272996?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kamil Pietruszka</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Crossy147" title="Code">💻</a></td>
<td align="center"><a href="http://cs.joensuu.fi/~zkhayda"><img src="https://avatars2.githubusercontent.com/u/660742?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zafar Khaydarov</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=zafarella" title="Code">💻</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=zafarella" title="Documentation">📖</a></td>
<td align="center"><a href="https://kemitix.github.io/"><img src="https://avatars1.githubusercontent.com/u/1147749?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Paul Campbell</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=kemitix" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Argyro-Sioziou"><img src="https://avatars0.githubusercontent.com/u/22822639?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Argyro Sioziou</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Argyro-Sioziou" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/TylerMcConville"><img src="https://avatars0.githubusercontent.com/u/4946449?v=4?s=100" width="100px;" alt=""/><br /><sub><b>TylerMcConville</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=TylerMcConville" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/saksham93"><img src="https://avatars1.githubusercontent.com/u/37399540?v=4?s=100" width="100px;" alt=""/><br /><sub><b>saksham93</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=saksham93" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/nikhilbarar"><img src="https://avatars2.githubusercontent.com/u/37332144?v=4?s=100" width="100px;" alt=""/><br /><sub><b>nikhilbarar</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=nikhilbarar" title="Code">💻</a></td>
@ -110,38 +107,32 @@ This project is licensed under the terms of the MIT license.
<td align="center"><a href="https://github.com/JuhoKang"><img src="https://avatars1.githubusercontent.com/u/4745294?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Juho Kang</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=JuhoKang" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/dheeraj-mummareddy"><img src="https://avatars2.githubusercontent.com/u/7002230?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dheeraj Mummareddy</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=dheeraj-mummareddy" title="Code">💻</a></td>
<td align="center"><a href="https://www.bernardosulzbach.com"><img src="https://avatars0.githubusercontent.com/u/8271090?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bernardo Sulzbach</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=bernardosulzbach" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/4lexis"><img src="https://avatars0.githubusercontent.com/u/19871727?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aleksandar Dudukovic</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=4lexis" title="Code">💻</a></td>
<td align="center"><a href="https://www.yusufaytas.com"><img src="https://avatars2.githubusercontent.com/u/1049483?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yusuf Aytaş</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=yusufaytas" title="Code">💻</a></td>
<td align="center"><a href="http://futurehomes.hu"><img src="https://avatars2.githubusercontent.com/u/1001491?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mihály Kuprivecz</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=qpi" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/kapinuss"><img src="https://avatars0.githubusercontent.com/u/17639945?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stanislav Kapinus</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=kapinuss" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/kapinuss"><img src="https://avatars0.githubusercontent.com/u/17639945?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stanislav Kapinus</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=kapinuss" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/gvsharma"><img src="https://avatars1.githubusercontent.com/u/6648152?v=4?s=100" width="100px;" alt=""/><br /><sub><b>GVSharma</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=gvsharma" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/SrdjanPaunovic"><img src="https://avatars1.githubusercontent.com/u/22815104?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Srđan Paunović</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=SrdjanPaunovic" title="Code">💻</a></td>
<td align="center"><a href="https://sideris.xyz/"><img src="https://avatars3.githubusercontent.com/u/5484694?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Petros G. Sideris</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=sideris" title="Code">💻</a></td>
<td align="center"><a href="https://www.linkedin.com/in/pramodgupta3/"><img src="https://avatars1.githubusercontent.com/u/2184241?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pramod Gupta</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3AIAmPramod" title="Reviewed Pull Requests">👀</a></td>
</tr>
<tr>
<td align="center"><a href="https://amarnath510.github.io/portfolio"><img src="https://avatars0.githubusercontent.com/u/4599623?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Amarnath Chandana</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Amarnath510" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Anurag870"><img src="https://avatars1.githubusercontent.com/u/6295975?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anurag870</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Anurag870" title="Code">💻</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=Anurag870" title="Documentation">📖</a></td>
<td align="center"><a href="http://theerroris.me"><img src="https://avatars0.githubusercontent.com/u/1685953?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wes Gilleland</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Deathnerd" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Harshrajsinh"><img src="https://avatars2.githubusercontent.com/u/22811531?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Harshraj Thakor</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Harshrajsinh" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://theerroris.me"><img src="https://avatars0.githubusercontent.com/u/1685953?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wes Gilleland</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Deathnerd" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Harshrajsinh"><img src="https://avatars2.githubusercontent.com/u/22811531?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Harshraj Thakor</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Harshrajsinh" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/MaVdbussche"><img src="https://avatars1.githubusercontent.com/u/26136934?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Martin Vandenbussche</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=MaVdbussche" title="Code">💻</a></td>
<td align="center"><a href="https://alexsomai.com"><img src="https://avatars1.githubusercontent.com/u/5720977?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alexandru Somai</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=alexsomai" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/amogozov"><img src="https://avatars3.githubusercontent.com/u/7372215?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Artur Mogozov</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=amogozov" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/anthonycampbell"><img src="https://avatars3.githubusercontent.com/u/10249255?v=4?s=100" width="100px;" alt=""/><br /><sub><b>anthony</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=anthonycampbell" title="Code">💻</a></td>
<td align="center"><a href="http://ccygnus.com/"><img src="https://avatars1.githubusercontent.com/u/9342724?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christian Cygnus</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=christophercolumbusdog" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://ccygnus.com/"><img src="https://avatars1.githubusercontent.com/u/9342724?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christian Cygnus</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=christophercolumbusdog" title="Code">💻</a></td>
<td align="center"><a href="https://about.me/dzmitryh"><img src="https://avatars2.githubusercontent.com/u/5390492?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dima Gubin</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=dzmitryh" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/jjjimenez100"><img src="https://avatars3.githubusercontent.com/u/22243493?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joshua Jimenez</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=jjjimenez100" title="Code">💻</a></td>
<td align="center"><a href="http://about.me/kaiwinter"><img src="https://avatars0.githubusercontent.com/u/110982?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kai Winter</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=kaiwinter" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/lbroman"><img src="https://avatars1.githubusercontent.com/u/86007?v=4?s=100" width="100px;" alt=""/><br /><sub><b>lbroman</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=lbroman" title="Code">💻</a></td>
<td align="center"><a href="https://przemeknowak.com"><img src="https://avatars1.githubusercontent.com/u/3254609?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Przemek</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=pnowy" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/prafful1"><img src="https://avatars0.githubusercontent.com/u/14350274?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Prafful Agarwal</b></sub></a><br /><a href="#content-prafful1" title="Content">🖋</a></td>
@ -152,38 +143,32 @@ This project is licensed under the terms of the MIT license.
<td align="center"><a href="https://github.com/valdar-hu"><img src="https://avatars3.githubusercontent.com/u/17962817?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Krisztián Nagy</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=valdar-hu" title="Code">💻</a></td>
<td align="center"><a href="https://www.vanogrid.com"><img src="https://avatars0.githubusercontent.com/u/4307918?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alexander Ivanov</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=vanogrid" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/yosfik"><img src="https://avatars3.githubusercontent.com/u/4850270?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yosfik Alqadri</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=yosfik" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/7agustibm"><img src="https://avatars0.githubusercontent.com/u/8149332?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Agustí Becerra Milà</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=7agustibm" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Juaanma"><img src="https://avatars3.githubusercontent.com/u/7390500?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Juan Manuel Suárez</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Juaanma" title="Code">💻</a></td>
<td align="center"><a href="http://www.devsedge.net/"><img src="https://avatars0.githubusercontent.com/u/9956006?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Luigi Cortese</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=LuigiCortese" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Rzeposlaw"><img src="https://avatars2.githubusercontent.com/u/18425745?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Katarzyna Rzepecka</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Rzeposlaw" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/Rzeposlaw"><img src="https://avatars2.githubusercontent.com/u/18425745?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Katarzyna Rzepecka</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Rzeposlaw" title="Code">💻</a></td>
<td align="center"><a href="http://adamski.pro"><img src="https://avatars1.githubusercontent.com/u/6537430?v=4?s=100" width="100px;" alt=""/><br /><sub><b>adamski.pro</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=akrystian" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/baislsl"><img src="https://avatars0.githubusercontent.com/u/17060584?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shengli Bai</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=baislsl" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/besok"><img src="https://avatars2.githubusercontent.com/u/29834592?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Boris</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=besok" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/dmitraver"><img src="https://avatars3.githubusercontent.com/u/1798156?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dmitry Avershin</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=dmitraver" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/fanofxiaofeng"><img src="https://avatars0.githubusercontent.com/u/3983683?v=4?s=100" width="100px;" alt=""/><br /><sub><b>靳阳</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=fanofxiaofeng" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/hoangnam2261"><img src="https://avatars2.githubusercontent.com/u/31692990?v=4?s=100" width="100px;" alt=""/><br /><sub><b>hoangnam2261</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=hoangnam2261" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/jarpit96"><img src="https://avatars2.githubusercontent.com/u/10098713?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Arpit Jain</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=jarpit96" title="Code">💻</a></td>
<td align="center"><a href="http://joningi.net"><img src="https://avatars2.githubusercontent.com/u/6115148?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jón Ingi Sveinbjörnsson</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=joningiwork" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/jarpit96"><img src="https://avatars2.githubusercontent.com/u/10098713?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Arpit Jain</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=jarpit96" title="Code">💻</a></td>
<td align="center"><a href="http://joningi.net"><img src="https://avatars2.githubusercontent.com/u/6115148?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jón Ingi Sveinbjörnsson</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=joningiwork" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/kirill-vlasov"><img src="https://avatars3.githubusercontent.com/u/16112495?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kirill Vlasov</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=kirill-vlasov" title="Code">💻</a></td>
<td align="center"><a href="http://mitchell-irvin.com"><img src="https://avatars0.githubusercontent.com/u/16233245?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mitchell Irvin</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mitchellirvin" title="Code">💻</a></td>
<td align="center"><a href="https://ranjeet-floyd.github.io"><img src="https://avatars0.githubusercontent.com/u/1992972?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ranjeet</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ranjeet-floyd" title="Code">💻</a></td>
<td align="center"><a href="https://alwayswithme.github.io"><img src="https://avatars3.githubusercontent.com/u/3234786?v=4?s=100" width="100px;" alt=""/><br /><sub><b>PhoenixYip</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Alwayswithme" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/MSaifAsif"><img src="https://avatars1.githubusercontent.com/u/6280554?v=4?s=100" width="100px;" alt=""/><br /><sub><b>M Saif Asif</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=MSaifAsif" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/MSaifAsif"><img src="https://avatars1.githubusercontent.com/u/6280554?v=4?s=100" width="100px;" alt=""/><br /><sub><b>M Saif Asif</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=MSaifAsif" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/kanwarpreet25"><img src="https://avatars0.githubusercontent.com/u/39183641?v=4?s=100" width="100px;" alt=""/><br /><sub><b>kanwarpreet25</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=kanwarpreet25" title="Code">💻</a></td>
<td align="center"><a href="http://leonmak.me"><img src="https://avatars3.githubusercontent.com/u/13071508?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Leon Mak</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=leonmak" title="Code">💻</a></td>
<td align="center"><a href="http://www.wramdemark.se"><img src="https://avatars2.githubusercontent.com/u/7052193?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Per Wramdemark</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=perwramdemark" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/waisuan"><img src="https://avatars2.githubusercontent.com/u/10975700?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Evan Sia Wai Suan</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=waisuan" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/AnaghaSasikumar"><img src="https://avatars2.githubusercontent.com/u/42939261?v=4?s=100" width="100px;" alt=""/><br /><sub><b>AnaghaSasikumar</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=AnaghaSasikumar" title="Code">💻</a></td>
<td align="center"><a href="https://christofferh.com"><img src="https://avatars1.githubusercontent.com/u/767643?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christoffer Hamberg</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=christofferh" title="Code">💻</a></td>
@ -194,38 +179,32 @@ This project is licensed under the terms of the MIT license.
<td align="center"><a href="https://github.com/leogtzr"><img src="https://avatars0.githubusercontent.com/u/1211969?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Leo Gutiérrez Ramírez</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=leogtzr" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/npczwh"><img src="https://avatars0.githubusercontent.com/u/14066422?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zhang WH</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=npczwh" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/oconnelc"><img src="https://avatars0.githubusercontent.com/u/1112973?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christopher O'Connell</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=oconnelc" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/giorgosmav21"><img src="https://avatars2.githubusercontent.com/u/22855493?v=4?s=100" width="100px;" alt=""/><br /><sub><b>George Mavroeidis</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=giorgosmav21" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/hbothra15"><img src="https://avatars1.githubusercontent.com/u/7418012?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hemant Bothra</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=hbothra15" title="Code">💻</a> <a href="#design-hbothra15" title="Design">🎨</a></td>
<td align="center"><a href="https://www.kevinpeters.net/about/"><img src="https://avatars1.githubusercontent.com/u/12736734?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Peters</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=igeligel" title="Code">💻</a></td>
<td align="center"><a href="https://llorllale.github.io/"><img src="https://avatars1.githubusercontent.com/u/2019896?v=4?s=100" width="100px;" alt=""/><br /><sub><b>George Aristy</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=llorllale" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://llorllale.github.io/"><img src="https://avatars1.githubusercontent.com/u/2019896?v=4?s=100" width="100px;" alt=""/><br /><sub><b>George Aristy</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=llorllale" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/mookkiah"><img src="https://avatars1.githubusercontent.com/u/8975264?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mahendran Mookkiah</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mookkiah" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Azureyjt"><img src="https://avatars2.githubusercontent.com/u/18476317?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Azureyjt</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Azureyjt" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/vehpsr"><img src="https://avatars2.githubusercontent.com/u/3133265?v=4?s=100" width="100px;" alt=""/><br /><sub><b>gans</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=vehpsr" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ThatGuyWithTheHat"><img src="https://avatars0.githubusercontent.com/u/24470582?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matt</b></sub></a><br /><a href="#content-ThatGuyWithTheHat" title="Content">🖋</a></td>
</tr>
<tr>
<td align="center"><a href="https://www.linkedin.com/in/gopinathlangote/"><img src="https://avatars2.githubusercontent.com/u/10210778?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gopinath Langote</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=gopinath-langote" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/hoswey"><img src="https://avatars3.githubusercontent.com/u/3689445?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hoswey</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=hoswey" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/amit2103"><img src="https://avatars3.githubusercontent.com/u/7566692?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Amit Pandey</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=amit2103" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/gwildor28"><img src="https://avatars0.githubusercontent.com/u/16000365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>gwildor28</b></sub></a><br /><a href="#content-gwildor28" title="Content">🖋</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/amit2103"><img src="https://avatars3.githubusercontent.com/u/7566692?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Amit Pandey</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=amit2103" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/gwildor28"><img src="https://avatars0.githubusercontent.com/u/16000365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>gwildor28</b></sub></a><br /><a href="#content-gwildor28" title="Content">🖋</a></td>
<td align="center"><a href="https://t.me/paul_docker"><img src="https://avatars1.githubusercontent.com/u/2404785?v=4?s=100" width="100px;" alt=""/><br /><sub><b>田浩</b></sub></a><br /><a href="#content-llitfkitfk" title="Content">🖋</a></td>
<td align="center"><a href="https://twitter.com/StPitsios"><img src="https://avatars1.githubusercontent.com/u/6773603?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stamatis Pitsios</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=pitsios-s" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/qza"><img src="https://avatars3.githubusercontent.com/u/233149?v=4?s=100" width="100px;" alt=""/><br /><sub><b>qza</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=qza" title="Code">💻</a></td>
<td align="center"><a href="http://tschis.github.io"><img src="https://avatars1.githubusercontent.com/u/20662669?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rodolfo Forte</b></sub></a><br /><a href="#content-Tschis" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/ankurkaushal"><img src="https://avatars2.githubusercontent.com/u/2236616?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ankur Kaushal</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ankurkaushal" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/ankurkaushal"><img src="https://avatars2.githubusercontent.com/u/2236616?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ankur Kaushal</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ankurkaushal" title="Code">💻</a></td>
<td align="center"><a href="https://www.linkedin.com/in/ovidijus-okinskas/"><img src="https://avatars0.githubusercontent.com/u/20372387?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ovidijus Okinskas</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=okinskas" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/robertt240"><img src="https://avatars1.githubusercontent.com/u/9137432?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Robert Kasperczyk</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=robertt240" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/trautonen"><img src="https://avatars3.githubusercontent.com/u/1641063?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tapio Rautonen</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=trautonen" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://vk.com/yuri.orlov"><img src="https://avatars0.githubusercontent.com/u/1595733?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yuri Orlov</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=yorlov" title="Code">💻</a></td>
<td align="center"><a href="https://www.linkedin.com/in/varunu28/"><img src="https://avatars0.githubusercontent.com/u/7676016?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Varun Upadhyay</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=varunu28" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/PalAditya"><img src="https://avatars2.githubusercontent.com/u/25523604?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aditya Pal</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=PalAditya" title="Code">💻</a></td>
@ -236,50 +215,41 @@ This project is licensed under the terms of the MIT license.
<td align="center"><a href="https://github.com/d4gg4d"><img src="https://avatars2.githubusercontent.com/u/99457?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sami Airaksinen</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=d4gg4d" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/vertti"><img src="https://avatars0.githubusercontent.com/u/557751?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Janne Sinivirta</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=vertti" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Bobo1239"><img src="https://avatars1.githubusercontent.com/u/2302947?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Boris-Chengbiao Zhou</b></sub></a><br /><a href="#content-Bobo1239" title="Content">🖋</a></td>
</tr>
<tr>
<td align="center"><a href="https://jahhein.github.io"><img src="https://avatars2.githubusercontent.com/u/10779515?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jacob Hein</b></sub></a><br /><a href="#content-Jahhein" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/iamrichardjones"><img src="https://avatars3.githubusercontent.com/u/14842151?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Richard Jones</b></sub></a><br /><a href="#content-iamrichardjones" title="Content">🖋</a></td>
<td align="center"><a href="https://rachelcarmena.github.io"><img src="https://avatars0.githubusercontent.com/u/22792183?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rachel M. Carmena</b></sub></a><br /><a href="#content-rachelcarmena" title="Content">🖋</a></td>
<td align="center"><a href="https://zd-zero.github.io"><img src="https://avatars0.githubusercontent.com/u/21978370?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zaerald Denze Lungos</b></sub></a><br /><a href="#content-zd-zero" title="Content">🖋</a></td>
</tr>
<tr>
<td align="center"><a href="https://zd-zero.github.io"><img src="https://avatars0.githubusercontent.com/u/21978370?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zaerald Denze Lungos</b></sub></a><br /><a href="#content-zd-zero" title="Content">🖋</a></td>
<td align="center"><a href="https://webpro.nl"><img src="https://avatars1.githubusercontent.com/u/456426?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lars Kappert</b></sub></a><br /><a href="#content-webpro" title="Content">🖋</a></td>
<td align="center"><a href="https://xiaod.info"><img src="https://avatars2.githubusercontent.com/u/21277644?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mike Liu</b></sub></a><br /><a href="#translation-xiaod-dev" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/charlesfinley"><img src="https://avatars1.githubusercontent.com/u/6307904?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matt Dolan</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=charlesfinley" title="Code">💻</a> <a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Acharlesfinley" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/MananS77"><img src="https://avatars3.githubusercontent.com/u/21033516?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Manan</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3AMananS77" title="Reviewed Pull Requests">👀</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/nishant"><img src="https://avatars2.githubusercontent.com/u/15331971?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nishant Arora</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=nishant" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/raja-peeyush-kumar-singh"><img src="https://avatars0.githubusercontent.com/u/5496024?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Peeyush</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=raja-peeyush-kumar-singh" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ravening"><img src="https://avatars1.githubusercontent.com/u/10645273?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rakesh</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ravening" title="Code">💻</a> <a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Aravening" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/vINCENT8888801"><img src="https://avatars0.githubusercontent.com/u/8037883?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wei Seng</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=vINCENT8888801" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/ravening"><img src="https://avatars1.githubusercontent.com/u/10645273?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rakesh</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ravening" title="Code">💻</a> <a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Aravening" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/vINCENT8888801"><img src="https://avatars0.githubusercontent.com/u/8037883?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wei Seng</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=vINCENT8888801" title="Code">💻</a></td>
<td align="center"><a href="https://www.linkedin.com/in/ashish-trivedi-218379135/"><img src="https://avatars3.githubusercontent.com/u/23194128?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ashish Trivedi</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ashishtrivedi16" title="Code">💻</a></td>
<td align="center"><a href="https://rayyounghong.com"><img src="https://avatars1.githubusercontent.com/u/41055099?v=4?s=100" width="100px;" alt=""/><br /><sub><b>洪月阳</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=RayYH" title="Code">💻</a></td>
<td align="center"><a href="https://xdvrx1.github.io/"><img src="https://avatars0.githubusercontent.com/u/47092464?v=4?s=100" width="100px;" alt=""/><br /><sub><b>xdvrx1</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Axdvrx1" title="Reviewed Pull Requests">👀</a> <a href="#ideas-xdvrx1" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="http://subho.xyz"><img src="https://avatars0.githubusercontent.com/u/13291222?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Subhrodip Mohanta</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ohbus" title="Code">💻</a> <a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Aohbus" title="Reviewed Pull Requests">👀</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/nahteb"><img src="https://avatars3.githubusercontent.com/u/13121570?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bethan Palmer</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=nahteb" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ToxicDreamz"><img src="https://avatars0.githubusercontent.com/u/45225562?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Toxic Dreamz</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ToxicDreamz" title="Code">💻</a></td>
<td align="center"><a href="http://www.edycutjong.com"><img src="https://avatars1.githubusercontent.com/u/1098102?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Edy Cu Tjong</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=edycutjong" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/mkrzywanski"><img src="https://avatars0.githubusercontent.com/u/15279585?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Michał Krzywański</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mkrzywanski" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://www.edycutjong.com"><img src="https://avatars1.githubusercontent.com/u/1098102?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Edy Cu Tjong</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=edycutjong" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/mkrzywanski"><img src="https://avatars0.githubusercontent.com/u/15279585?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Michał Krzywański</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mkrzywanski" title="Code">💻</a></td>
<td align="center"><a href="https://www.stefan-birkner.de"><img src="https://avatars1.githubusercontent.com/u/711349?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefan Birkner</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=stefanbirkner" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/fedorskvorcov"><img src="https://avatars3.githubusercontent.com/u/43882212?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Fedor Skvorcov</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=fedorskvorcov" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/samilAyoub"><img src="https://avatars0.githubusercontent.com/u/61546990?v=4?s=100" width="100px;" alt=""/><br /><sub><b>samilAyoub</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=samilAyoub" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/vdlald"><img src="https://avatars0.githubusercontent.com/u/29997701?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vladislav Golubinov</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=vdlald" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/swarajsaaj"><img src="https://avatars2.githubusercontent.com/u/6285049?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Swaraj</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=swarajsaaj" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/swarajsaaj"><img src="https://avatars2.githubusercontent.com/u/6285049?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Swaraj</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=swarajsaaj" title="Code">💻</a></td>
<td align="center"><a href="http://christophflick.de"><img src="https://avatars0.githubusercontent.com/u/4465376?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christoph Flick</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ChFlick" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/Ascenio"><img src="https://avatars1.githubusercontent.com/u/7662016?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ascênio</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3AAscenio" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://www.linkedin.com/in/domenico-sibilio/"><img src="https://avatars2.githubusercontent.com/u/24280982?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Domenico Sibilio</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=dsibilio" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/akashchandwani"><img src="https://avatars2.githubusercontent.com/u/3483277?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Akash Chandwani</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Aakashchandwani" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="http://www.linkedin.com/in/manannikov"><img src="https://avatars2.githubusercontent.com/u/7019769?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pavlo Manannikov</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=manannikov" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/eimanip"><img src="https://avatars0.githubusercontent.com/u/20307301?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eiman</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=eimanip" title="Code">💻</a></td>
@ -290,23 +260,77 @@ This project is licensed under the terms of the MIT license.
<td align="center"><a href="https://github.com/gkulkarni2020"><img src="https://avatars3.githubusercontent.com/u/5161548?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Girish Kulkarni</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=gkulkarni2020" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/omk13"><img src="https://avatars0.githubusercontent.com/u/59054172?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Omar Karazoun</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=omk13" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/jeff303"><img src="https://avatars0.githubusercontent.com/u/3521562?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeff Evans</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=jeff303" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://viveksb007.github.io"><img src="https://avatars1.githubusercontent.com/u/12713808?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vivek Singh</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=viveksb007" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/siavashsoleymani"><img src="https://avatars2.githubusercontent.com/u/18074419?v=4?s=100" width="100px;" alt=""/><br /><sub><b>siavash</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=siavashsoleymani" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ruchpeanuts"><img src="https://avatars0.githubusercontent.com/u/29301900?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ruchpeanuts</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ruchpeanuts" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/warp125"><img src="https://avatars1.githubusercontent.com/u/48073115?v=4?s=100" width="100px;" alt=""/><br /><sub><b>warp125</b></sub></a><br /><a href="#translation-warp125" title="Translation">🌍</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/warp125"><img src="https://avatars1.githubusercontent.com/u/48073115?v=4?s=100" width="100px;" alt=""/><br /><sub><b>warp125</b></sub></a><br /><a href="#translation-warp125" title="Translation">🌍</a></td>
<td align="center"><a href="http://libkhadir.fr"><img src="https://avatars1.githubusercontent.com/u/45130488?v=4?s=100" width="100px;" alt=""/><br /><sub><b>KHADIR Tayeb</b></sub></a><br /><a href="#translation-tkhadir" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/ignite1771"><img src="https://avatars2.githubusercontent.com/u/59446563?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ignite1771</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ignite1771" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/demirhalil"><img src="https://avatars1.githubusercontent.com/u/22895118?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Halil Demir</b></sub></a><br /><a href="#translation-demirhalil" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/rohit10000"><img src="https://avatars.githubusercontent.com/u/20845565?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rohit Singh</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=rohit10000" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/byoungju94"><img src="https://avatars.githubusercontent.com/u/42516378?v=4?s=100" width="100px;" alt=""/><br /><sub><b>byoungju94</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=byoungju94" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/moustafafarhat"><img src="https://avatars.githubusercontent.com/u/38836727?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Moustafa Farhat</b></sub></a><br /><a href="#translation-moustafafarhat" title="Translation">🌍</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/richardmr36"><img src="https://avatars.githubusercontent.com/u/19147333?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Martel Richard</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=richardmr36" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/va1m"><img src="https://avatars.githubusercontent.com/u/17025445?v=4?s=100" width="100px;" alt=""/><br /><sub><b>va1m</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=va1m" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/noamgrinch"><img src="https://avatars.githubusercontent.com/u/31648669?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Noam Greenshtain</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=noamgrinch" title="Code">💻</a></td>
<td align="center"><a href="https://xuyonghong.cn/"><img src="https://avatars.githubusercontent.com/u/14086462?v=4?s=100" width="100px;" alt=""/><br /><sub><b>yonghong Xu</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=qfxl" title="Documentation">📖</a></td>
<td align="center"><a href="https://www.linkedin.com/in/jinisha-vora"><img src="https://avatars.githubusercontent.com/u/40777762?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jinishavora</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Ajinishavora" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=jinishavora" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/eas5"><img src="https://avatars.githubusercontent.com/u/50836521?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elvys Soares</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=eas5" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/zWeBrain"><img src="https://avatars.githubusercontent.com/u/46642512?v=4?s=100" width="100px;" alt=""/><br /><sub><b>zWeBrain</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=zWeBrain" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://al-assad.github.io/notion/"><img src="https://avatars.githubusercontent.com/u/22493821?v=4?s=100" width="100px;" alt=""/><br /><sub><b>余林颖</b></sub></a><br /><a href="#translation-Al-assad" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/STudio26"><img src="https://avatars.githubusercontent.com/u/6988911?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alain</b></sub></a><br /><a href="#translation-STudio26" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/DEV-VRUPER"><img src="https://avatars.githubusercontent.com/u/30525467?v=4?s=100" width="100px;" alt=""/><br /><sub><b>VR</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=DEV-VRUPER" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/JackieNim"><img src="https://avatars.githubusercontent.com/u/4138836?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JackieNim</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=JackieNim" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/EdisonE3"><img src="https://avatars.githubusercontent.com/u/52118917?v=4?s=100" width="100px;" alt=""/><br /><sub><b>EdisonE3</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=EdisonE3" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/tao-sun2"><img src="https://avatars.githubusercontent.com/u/66189688?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tao</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=tao-sun2" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/JuanManuelAbate"><img src="https://avatars.githubusercontent.com/u/16357060?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Juan Manuel Abate</b></sub></a><br /><a href="#translation-JuanManuelAbate" title="Translation">🌍</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/Xenilo137"><img src="https://avatars.githubusercontent.com/u/24865069?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Xenilo137</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Xenilo137" title="Code">💻</a></td>
<td align="center"><a href="https://www.linkedin.com/in/souzasamuel/"><img src="https://avatars.githubusercontent.com/u/17254162?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Samuel Souza</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=samuelpsouza" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/marlo2222"><img src="https://avatars.githubusercontent.com/u/40809563?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marlo Henrique</b></sub></a><br /><a href="#translation-marlo2222" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/AndriyPyzh"><img src="https://avatars.githubusercontent.com/u/57706635?v=4?s=100" width="100px;" alt=""/><br /><sub><b>AndriyPyzh</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=AndriyPyzh" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/karthikbhat13"><img src="https://avatars.githubusercontent.com/u/22431014?v=4?s=100" width="100px;" alt=""/><br /><sub><b>karthikbhat13</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=karthikbhat13" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/mortezaadi"><img src="https://avatars.githubusercontent.com/u/1329687?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Morteza Adigozalpour</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mortezaadi" title="Code">💻</a></td>
<td align="center"><a href="https://stackoverflow.com/users/308565/nagaraj-tantri"><img src="https://avatars.githubusercontent.com/u/3784194?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nagaraj Tantri</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=tan31989" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://scuccimarri.it"><img src="https://avatars.githubusercontent.com/u/7107651?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Francesco Scuccimarri</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=frascu" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Conhan93"><img src="https://avatars.githubusercontent.com/u/71334757?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Conny Hansson</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Conhan93" title="Documentation">📖</a></td>
<td align="center"><a href="http://muklasr.medium.com"><img src="https://avatars.githubusercontent.com/u/43443753?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Muklas Rahmanto</b></sub></a><br /><a href="#translation-muklasr" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/VxDxK"><img src="https://avatars.githubusercontent.com/u/38704817?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vadim</b></sub></a><br /><a href="#translation-VxDxK" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/sims-keshri"><img src="https://avatars.githubusercontent.com/u/62168475?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Simran Keshri</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=sims-keshri" title="Code">💻</a></td>
<td align="center"><a href="https://programacionymas.com"><img src="https://avatars.githubusercontent.com/u/3101238?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JCarlos</b></sub></a><br /><a href="#translation-JCarlosR" title="Translation">🌍</a></td>
<td align="center"><a href="https://www.mrmoshkel.ir"><img src="https://avatars.githubusercontent.com/u/60359433?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ali Ghasemi</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Dev-AliGhasemi" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://carlfx.wordpress.com"><img src="https://avatars.githubusercontent.com/u/1594624?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Carl Dea</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=carldea" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Mozartuss"><img src="https://avatars.githubusercontent.com/u/32893711?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mozartus</b></sub></a><br /><a href="#translation-Mozartuss" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/ManviGoel26"><img src="https://avatars.githubusercontent.com/u/55682355?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Manvi Goel</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ManviGoel26" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/blueberry404"><img src="https://avatars.githubusercontent.com/u/39243539?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anum Amin</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=blueberry404" title="Documentation">📖</a></td>
<td align="center"><a href="https://uh-zz.github.io/blog/"><img src="https://avatars.githubusercontent.com/u/47747828?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Reo Uehara</b></sub></a><br /><a href="#translation-uh-zz" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/Fiordy"><img src="https://avatars.githubusercontent.com/u/53420573?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Fiordy</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Fiordy" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/harshalkh"><img src="https://avatars.githubusercontent.com/u/37841724?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Harshal</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=harshalkh" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://www.linkedin.com/in/abhinav-vashisth-06613b208/"><img src="https://avatars.githubusercontent.com/u/89785800?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Abhinav Vashisth</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=vashisthabhinav" title="Documentation">📖</a></td>
<td align="center"><a href="http://no website"><img src="https://avatars.githubusercontent.com/u/47126749?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3AKevinyl3" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=Kevinyl3" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Shrirang97"><img src="https://avatars.githubusercontent.com/u/28738668?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shrirang</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3AShrirang97" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=Shrirang97" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/interactwithankush"><img src="https://avatars.githubusercontent.com/u/18613127?v=4?s=100" width="100px;" alt=""/><br /><sub><b>interactwithankush</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=interactwithankush" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/yuhangbin"><img src="https://avatars.githubusercontent.com/u/17566866?v=4?s=100" width="100px;" alt=""/><br /><sub><b>CharlieYu</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=yuhangbin" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Leisterbecker"><img src="https://avatars.githubusercontent.com/u/20650323?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Leisterbecker</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Leisterbecker" title="Code">💻</a></td>
<td align="center"><a href="http://rosaecrucis.cn"><img src="https://avatars.githubusercontent.com/u/35420129?v=4?s=100" width="100px;" alt=""/><br /><sub><b>DragonDreamer</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=castleKing1997" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/ShivanshCharak"><img src="https://avatars.githubusercontent.com/u/96943825?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ShivanshCharak</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=ShivanshCharak" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/HattoriHenzo"><img src="https://avatars.githubusercontent.com/u/5141285?v=4?s=100" width="100px;" alt=""/><br /><sub><b>HattoriHenzo</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=HattoriHenzo" title="Code">💻</a></td>
</tr>
</table>
<!-- markdownlint-restore -->

View File

@ -4,6 +4,7 @@ title: Abstract Document
folder: abstract-document
permalink: /patterns/abstract-document/
categories: Structural
language: en
tags:
- Extensibility
---

View File

@ -23,42 +23,40 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<artifactId>abstract-document</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven assembly plugin is invoked with default setting which we have
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<artifactId>abstract-document</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven assembly plugin is invoked with default setting which we have
in parent pom and specifying the class having main method -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.abstractdocument.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.abstractdocument.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -27,8 +27,7 @@ import com.iluwatar.abstractdocument.domain.Car;
import com.iluwatar.abstractdocument.domain.enums.Property;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* The Abstract Document pattern enables handling additional, non-static properties. This pattern
@ -38,10 +37,9 @@ import org.slf4j.LoggerFactory;
* <p>In Abstract Document pattern,({@link AbstractDocument}) fully implements {@link Document})
* interface. Traits are then defined to enable access to properties in usual, static way.
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point.
*

View File

@ -23,19 +23,18 @@
package com.iluwatar.abstractdocument;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
* AbstractDocument test class
*/
public class AbstractDocumentTest {
class AbstractDocumentTest {
private static final String KEY = "key";
private static final String VALUE = "value";
@ -50,13 +49,13 @@ public class AbstractDocumentTest {
private final DocumentImplementation document = new DocumentImplementation(new HashMap<>());
@Test
public void shouldPutAndGetValue() {
void shouldPutAndGetValue() {
document.put(KEY, VALUE);
assertEquals(VALUE, document.get(KEY));
}
@Test
public void shouldRetrieveChildren() {
void shouldRetrieveChildren() {
var children = List.of(Map.of(), Map.of());
document.put(KEY, children);
@ -67,14 +66,14 @@ public class AbstractDocumentTest {
}
@Test
public void shouldRetrieveEmptyStreamForNonExistingChildren() {
void shouldRetrieveEmptyStreamForNonExistingChildren() {
var children = document.children(KEY, DocumentImplementation::new);
assertNotNull(children);
assertEquals(0, children.count());
}
@Test
public void shouldIncludePropsInToString() {
void shouldIncludePropsInToString() {
var props = Map.of(KEY, (Object) VALUE);
var document = new DocumentImplementation(props);
assertTrue(document.toString().contains(KEY));

View File

@ -23,19 +23,20 @@
package com.iluwatar.abstractdocument;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.iluwatar.abstractdocument.domain.Car;
import com.iluwatar.abstractdocument.domain.Part;
import com.iluwatar.abstractdocument.domain.enums.Property;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Part and Car
*/
public class DomainTest {
class DomainTest {
private static final String TEST_PART_TYPE = "test-part-type";
private static final String TEST_PART_MODEL = "test-part-model";
@ -45,7 +46,7 @@ public class DomainTest {
private static final long TEST_CAR_PRICE = 1L;
@Test
public void shouldConstructPart() {
void shouldConstructPart() {
var partProperties = Map.of(
Property.TYPE.toString(), TEST_PART_TYPE,
Property.MODEL.toString(), TEST_PART_MODEL,
@ -58,7 +59,7 @@ public class DomainTest {
}
@Test
public void shouldConstructCar() {
void shouldConstructCar() {
var carProperties = Map.of(
Property.MODEL.toString(), TEST_CAR_MODEL,
Property.PRICE.toString(), TEST_CAR_PRICE,

View File

@ -4,6 +4,7 @@ title: Abstract Factory
folder: abstract-factory
permalink: /patterns/abstract-factory/
categories: Creational
language: en
tags:
- Gang of Four
---
@ -19,9 +20,9 @@ objects without specifying their concrete classes.
## Explanation
Real world example
Real-world example
> To create a kingdom we need objects with a common theme. Elven kingdom needs an Elven king, Elven castle and Elven army whereas Orcish kingdom needs an Orcish king, Orcish castle and Orcish army. There is a dependency between the objects in the kingdom.
> To create a kingdom we need objects with a common theme. The elven kingdom needs an elven king, elven castle, and elven army whereas the orcish kingdom needs an orcish king, orcish castle, and orcish army. There is a dependency between the objects in the kingdom.
In plain words
@ -33,7 +34,7 @@ Wikipedia says
**Programmatic Example**
Translating the kingdom example above. First of all we have some interfaces and implementation for the objects in the
Translating the kingdom example above. First of all, we have some interfaces and implementation for the objects in the
kingdom.
```java
@ -51,21 +52,21 @@ public interface Army {
// Elven implementations ->
public class ElfCastle implements Castle {
static final String DESCRIPTION = "This is the Elven castle!";
static final String DESCRIPTION = "This is the elven castle!";
@Override
public String getDescription() {
return DESCRIPTION;
}
}
public class ElfKing implements King {
static final String DESCRIPTION = "This is the Elven king!";
static final String DESCRIPTION = "This is the elven king!";
@Override
public String getDescription() {
return DESCRIPTION;
}
}
public class ElfArmy implements Army {
static final String DESCRIPTION = "This is the Elven Army!";
static final String DESCRIPTION = "This is the elven Army!";
@Override
public String getDescription() {
return DESCRIPTION;
@ -76,7 +77,7 @@ public class ElfArmy implements Army {
```
Then we have the abstraction and implementations for the kingdom factory
Then we have the abstraction and implementations for the kingdom factory.
```java
public interface KingdomFactory {
@ -86,31 +87,43 @@ public interface KingdomFactory {
}
public class ElfKingdomFactory implements KingdomFactory {
@Override
public Castle createCastle() {
return new ElfCastle();
}
@Override
public King createKing() {
return new ElfKing();
}
@Override
public Army createArmy() {
return new ElfArmy();
}
}
public class OrcKingdomFactory implements KingdomFactory {
@Override
public Castle createCastle() {
return new OrcCastle();
}
@Override
public King createKing() {
return new OrcKing();
}
@Override
public Army createArmy() {
return new OrcArmy();
}
}
```
Now we have our abstract factory that lets us make family of related objects i.e. Elven kingdom factory creates Elven castle, king and army etc.
Now we have the abstract factory that lets us make a family of related objects i.e. elven kingdom factory creates elven castle, king and army, etc.
```java
var factory = new ElfKingdomFactory();
@ -126,13 +139,13 @@ army.getDescription();
Program output:
```java
This is the Elven castle!
This is the Elven king!
This is the Elven Army!
This is the elven castle!
This is the elven king!
This is the elven Army!
```
Now, we can design a factory for our different kingdom factories. In this example, we created FactoryMaker, responsible for returning an instance of either ElfKingdomFactory or OrcKingdomFactory.
The client can use FactoryMaker to create the desired concrete factory which, in turn, will produce different concrete objects (Army, King, Castle).
Now, we can design a factory for our different kingdom factories. In this example, we created `FactoryMaker`, responsible for returning an instance of either `ElfKingdomFactory` or `OrcKingdomFactory`.
The client can use `FactoryMaker` to create the desired concrete factory which, in turn, will produce different concrete objects (derived from `Army`, `King`, `Castle`).
In this example, we also used an enum to parameterize which type of kingdom factory the client will ask for.
```java
@ -178,8 +191,8 @@ public static void main(String[] args) {
Use the Abstract Factory pattern when
* The system should be independent of how its products are created, composed and represented
* The system should be configured with one of multiple families of products
* The system should be independent of how its products are created, composed, and represented
* The system should be configured with one of the multiple families of products
* The family of related product objects is designed to be used together, and you need to enforce this constraint
* You want to provide a class library of products, and you want to reveal just their interfaces, not their implementations
* The lifetime of the dependency is conceptually shorter than the lifetime of the consumer.
@ -195,13 +208,13 @@ Example use cases
* Unit test case writing becomes much easier
* UI tools for different OS
## Consequences:
## Consequences
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time.
* While the pattern is great when creating predefined objects, adding the new ones might be challenging.
* The code becomes more complicated than it should be, since a lot of new interfaces and classes are introduced along with the pattern.
* The code becomes more complicated than it should be since a lot of new interfaces and classes are introduced along with the pattern.
## Tutorial
## Tutorials
* [Abstract Factory Pattern Tutorial](https://www.journaldev.com/1418/abstract-factory-design-pattern-in-java)

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
@ -23,43 +23,40 @@
THE SOFTWARE.
-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<artifactId>abstract-factory</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven assembly plugin is invoked with default setting which we have
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<artifactId>abstract-factory</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven assembly plugin is invoked with default setting which we have
in parent pom and specifying the class having main method -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.abstractfactory.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.abstractfactory.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -23,8 +23,7 @@
package com.iluwatar.abstractfactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* The Abstract Factory pattern provides a way to encapsulate a group of individual factories that
@ -38,12 +37,11 @@ import org.slf4j.LoggerFactory;
*
* <p>The essence of the Abstract Factory pattern is a factory interface ({@link KingdomFactory})
* and its implementations ( {@link ElfKingdomFactory}, {@link OrcKingdomFactory}). The example uses
* both concrete implementations to create a king, a castle and an army.
* both concrete implementations to create a king, a castle, and an army.
*/
@Slf4j
public class App implements Runnable {
private static Logger log = LoggerFactory.getLogger(App.class);
private final Kingdom kingdom = new Kingdom();
public Kingdom getKingdom() {
@ -62,17 +60,17 @@ public class App implements Runnable {
@Override
public void run() {
log.info("Elf Kingdom");
LOGGER.info("elf kingdom");
createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
log.info(kingdom.getArmy().getDescription());
log.info(kingdom.getCastle().getDescription());
log.info(kingdom.getKing().getDescription());
LOGGER.info(kingdom.getArmy().getDescription());
LOGGER.info(kingdom.getCastle().getDescription());
LOGGER.info(kingdom.getKing().getDescription());
log.info("Orc Kingdom");
LOGGER.info("orc kingdom");
createKingdom(Kingdom.FactoryMaker.KingdomType.ORC);
log.info(kingdom.getArmy().getDescription());
log.info(kingdom.getCastle().getDescription());
log.info(kingdom.getKing().getDescription());
LOGGER.info(kingdom.getArmy().getDescription());
LOGGER.info(kingdom.getCastle().getDescription());
LOGGER.info(kingdom.getKing().getDescription());
}
/**

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class ElfArmy implements Army {
static final String DESCRIPTION = "This is the Elven Army!";
static final String DESCRIPTION = "This is the elven army!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class ElfCastle implements Castle {
static final String DESCRIPTION = "This is the Elven castle!";
static final String DESCRIPTION = "This is the elven castle!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class ElfKing implements King {
static final String DESCRIPTION = "This is the Elven king!";
static final String DESCRIPTION = "This is the elven king!";
@Override
public String getDescription() {

View File

@ -23,36 +23,17 @@
package com.iluwatar.abstractfactory;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Kingdom {
private King king;
private Castle castle;
private Army army;
public King getKing() {
return king;
}
public Castle getCastle() {
return castle;
}
public Army getArmy() {
return army;
}
public void setKing(King king) {
this.king = king;
}
public void setCastle(Castle castle) {
this.castle = castle;
}
public void setArmy(Army army) {
this.army = army;
}
/**
* The factory of kingdom factories.
*/

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class OrcArmy implements Army {
static final String DESCRIPTION = "This is the Orc Army!";
static final String DESCRIPTION = "This is the orc army!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class OrcCastle implements Castle {
static final String DESCRIPTION = "This is the Orc castle!";
static final String DESCRIPTION = "This is the orc castle!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class OrcKing implements King {
static final String DESCRIPTION = "This is the Orc king!";
static final String DESCRIPTION = "This is the orc king!";
@Override
public String getDescription() {

View File

@ -29,14 +29,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test for abstract factory.
* Tests for abstract factory.
*/
public class AbstractFactoryTest {
class AbstractFactoryTest {
private final App app = new App();
@Test
public void king() {
void verifyKingCreation() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
final var kingdom = app.getKingdom();
@ -51,7 +51,7 @@ public class AbstractFactoryTest {
}
@Test
public void castle() {
void verifyCastleCreation() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
final var kingdom = app.getKingdom();
@ -66,7 +66,7 @@ public class AbstractFactoryTest {
}
@Test
public void army() {
void verifyArmyCreation() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
final var kingdom = app.getKingdom();
@ -81,7 +81,7 @@ public class AbstractFactoryTest {
}
@Test
public void createElfKingdom() {
void verifyElfKingdomCreation() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
final var kingdom = app.getKingdom();
@ -97,7 +97,7 @@ public class AbstractFactoryTest {
}
@Test
public void createOrcKingdom() {
void verifyOrcKingdomCreation() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ORC);
final var kingdom = app.getKingdom();

View File

@ -28,20 +28,13 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
/**
* Tests that Abstract Factory example runs without errors.
* Check whether the execution of the main method in {@link App} throws an exception.
*/
class AppTest {
/**
* Issue: Add at least one assertion to this test case.
*
* Solution: Inserted assertion to check whether the execution of the main method in {@link App}
* throws an exception.
*/
@Test
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[]{}));
}
}

130
active-object/README.md Normal file
View File

@ -0,0 +1,130 @@
---
layout: pattern
title: Active Object
folder: active-object
permalink: /patterns/active-object/
categories: Concurrency
language: en
tags:
- Performance
---
## Intent
The active object design pattern decouples method execution from method invocation for objects that each reside in their thread of control. The goal is to introduce concurrency, by using asynchronous method invocation, and a scheduler for handling requests.
## Explanation
The class that implements the active object pattern will contain a self-synchronization mechanism without using 'synchronized' methods.
Real-world example
>The Orcs are known for their wildness and untameable soul. It seems like they have their own thread of control based on previous behavior.
To implement a creature that has its own thread of control mechanism and expose its API only and not the execution itself, we can use the Active Object pattern.
**Programmatic Example**
```java
public abstract class ActiveCreature{
private final Logger logger = LoggerFactory.getLogger(ActiveCreature.class.getName());
private BlockingQueue<Runnable> requests;
private String name;
private Thread thread;
public ActiveCreature(String name) {
this.name = name;
this.requests = new LinkedBlockingQueue<Runnable>();
thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
requests.take().run();
} catch (InterruptedException e) {
logger.error(e.getMessage());
}
}
}
}
);
thread.start();
}
public void eat() throws InterruptedException {
requests.put(new Runnable() {
@Override
public void run() {
logger.info("{} is eating!",name());
logger.info("{} has finished eating!",name());
}
}
);
}
public void roam() throws InterruptedException {
requests.put(new Runnable() {
@Override
public void run() {
logger.info("{} has started to roam the wastelands.",name());
}
}
);
}
public String name() {
return this.name;
}
}
```
We can see that any class that will extend the ActiveCreature class will have its own thread of control to invoke and execute methods.
For example, the Orc class:
```java
public class Orc extends ActiveCreature {
public Orc(String name) {
super(name);
}
}
```
Now, we can create multiple creatures such as Orcs, tell them to eat and roam, and they will execute it on their own thread of control:
```java
public static void main(String[] args) {
var app = new App();
app.run();
}
@Override
public void run() {
ActiveCreature creature;
try {
for (int i = 0;i < creatures;i++) {
creature = new Orc(Orc.class.getSimpleName().toString() + i);
creature.eat();
creature.roam();
}
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.error(e.getMessage());
}
Runtime.getRuntime().exit(1);
}
```
## Class diagram
![alt text](./etc/active-object.urm.png "Active Object class diagram")
## Tutorials
* [Android and Java Concurrency: The Active Object Pattern](https://www.youtube.com/watch?v=Cd8t2u5Qmvc)

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -0,0 +1,25 @@
@startuml
package com.iluwatar.activeobject {
abstract class ActiveCreature {
- logger : Logger
- name : String
- requests : BlockingQueue<Runnable>
- thread : Thread
+ ActiveCreature(name : String)
+ eat()
+ name() : String
+ roam()
}
class App {
- creatures : Integer
- logger : Logger
+ App()
+ main(args : String[]) {static}
+ run()
}
class Orc {
+ Orc(name : String)
}
}
Orc --|> ActiveCreature
@enduml

62
active-object/pom.xml Normal file
View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright © 2014-2021 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<artifactId>active-object</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven assembly plugin is invoked with default setting which we have
in parent pom and specifying the class having main method -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.activeobject.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,118 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.activeobject;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ActiveCreature class is the base of the active object example.
* @author Noam Greenshtain
*
*/
public abstract class ActiveCreature {
private static final Logger logger = LoggerFactory.getLogger(ActiveCreature.class.getName());
private BlockingQueue<Runnable> requests;
private String name;
private Thread thread; // Thread of execution.
private int status; // status of the thread of execution.
/**
* Constructor and initialization.
*/
protected ActiveCreature(String name) {
this.name = name;
this.status = 0;
this.requests = new LinkedBlockingQueue<>();
thread = new Thread(() -> {
boolean infinite = true;
while (infinite) {
try {
requests.take().run();
} catch (InterruptedException e) {
if (this.status != 0) {
logger.error("Thread was interrupted. --> {}", e.getMessage());
}
infinite = false;
Thread.currentThread().interrupt();
}
}
});
thread.start();
}
/**
* Eats the porridge.
* @throws InterruptedException due to firing a new Runnable.
*/
public void eat() throws InterruptedException {
requests.put(() -> {
logger.info("{} is eating!",name());
logger.info("{} has finished eating!",name());
});
}
/**
* Roam the wastelands.
* @throws InterruptedException due to firing a new Runnable.
*/
public void roam() throws InterruptedException {
requests.put(() ->
logger.info("{} has started to roam in the wastelands.",name())
);
}
/**
* Returns the name of the creature.
* @return the name of the creature.
*/
public String name() {
return this.name;
}
/**
* Kills the thread of execution.
* @param status of the thread of execution. 0 == OK, the rest is logging an error.
*/
public void kill(int status) {
this.status = status;
this.thread.interrupt();
}
/**
* Returns the status of the thread of execution.
* @return the status of the thread of execution.
*/
public int getStatus() {
return this.status;
}
}

View File

@ -0,0 +1,75 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.activeobject;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Active Object pattern helps to solve synchronization difficulties without using
* 'synchronized' methods. The active object will contain a thread-safe data structure
* (such as BlockingQueue) and use to synchronize method calls by moving the logic of the method
* into an invocator(usually a Runnable) and store it in the DSA.
*
* <p>In this example, we fire 20 threads to modify a value in the target class.
*/
public class App implements Runnable {
private static final Logger logger = LoggerFactory.getLogger(App.class.getName());
private static final int NUM_CREATURES = 3;
/**
* Program entry point.
*
* @param args command line arguments.
*/
public static void main(String[] args) {
var app = new App();
app.run();
}
@Override
public void run() {
List<ActiveCreature> creatures = new ArrayList<>();
try {
for (int i = 0;i < NUM_CREATURES;i++) {
creatures.add(new Orc(Orc.class.getSimpleName() + i));
creatures.get(i).eat();
creatures.get(i).roam();
}
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.error(e.getMessage());
Thread.currentThread().interrupt();
} finally {
for (int i = 0;i < NUM_CREATURES;i++) {
creatures.get(i).kill(0);
}
}
}
}

View File

@ -0,0 +1,37 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.activeobject;
/**
* An implementation of the ActiveCreature class.
* @author Noam Greenshtain
*
*/
public class Orc extends ActiveCreature {
public Orc(String name) {
super(name);
}
}

View File

@ -0,0 +1,42 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.activeobject;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class ActiveCreatureTest {
@Test
void executionTest() throws InterruptedException {
ActiveCreature orc = new Orc("orc1");
assertEquals("orc1",orc.name());
assertEquals(0,orc.getStatus());
orc.eat();
orc.roam();
orc.kill(0);
}
}

View File

@ -0,0 +1,37 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.activeobject;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import org.junit.jupiter.api.Test;
class AppTest {
@Test
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
}
}

View File

@ -4,6 +4,7 @@ title: Acyclic Visitor
folder: acyclic-visitor
permalink: /patterns/acyclic-visitor/
categories: Behavioral
language: en
tags:
- Extensibility
---
@ -137,6 +138,10 @@ This pattern can be used:
* When the visited class hierarchy will be frequently extended with new derivatives of the Element class.
* When the recompilation, relinking, retesting or redistribution of the derivatives of Element is very expensive.
## Tutorial
* [Acyclic Visitor Pattern Example](https://codecrafter.blogspot.com/2012/12/the-acyclic-visitor-pattern.html)
## Consequences
The good:

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
@ -22,53 +23,47 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<artifactId>acyclic-visitor</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.9.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/uk.org.lidalia/slf4j-test -->
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<artifactId>acyclic-visitor</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.9.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/uk.org.lidalia/slf4j-test -->
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven assembly plugin is invoked with default setting which we have
in parent pom and specifying the class having main method -->

View File

@ -23,17 +23,15 @@
package com.iluwatar.acyclicvisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* ConfigureForDosVisitor class implements both zoom's and hayes' visit method for Dos
* manufacturer.
*/
@Slf4j
public class ConfigureForDosVisitor implements AllModemVisitor {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class);
@Override
public void visit(Hayes hayes) {
LOGGER.info(hayes + " used with Dos configurator.");

View File

@ -23,17 +23,15 @@
package com.iluwatar.acyclicvisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* ConfigureForUnixVisitor class implements zoom's visit method for Unix manufacturer, unlike
* traditional visitor pattern, this class may selectively implement visit for other modems.
*/
@Slf4j
public class ConfigureForUnixVisitor implements ZoomVisitor {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForUnixVisitor.class);
@Override
public void visit(Zoom zoom) {
LOGGER.info(zoom + " used with Unix configurator.");

View File

@ -23,15 +23,13 @@
package com.iluwatar.acyclicvisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* Hayes class implements its accept method.
*/
public class Hayes extends Modem {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class);
@Slf4j
public class Hayes implements Modem {
/**
* Accepts all visitors but honors only HayesVisitor.

View File

@ -24,8 +24,9 @@
package com.iluwatar.acyclicvisitor;
/**
* Modem abstract class.
* //Modem abstract class.
* converted to an interface
*/
public abstract class Modem {
public abstract void accept(ModemVisitor modemVisitor);
public interface Modem {
void accept(ModemVisitor modemVisitor);
}

View File

@ -23,15 +23,13 @@
package com.iluwatar.acyclicvisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* Zoom class implements its accept method.
*/
public class Zoom extends Modem {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class);
@Slf4j
public class Zoom implements Modem {
/**
* Accepts all visitors but honors only ZoomVisitor.

View File

@ -35,34 +35,34 @@ import uk.org.lidalia.slf4jtest.TestLoggerFactory;
/**
* ConfigureForDosVisitor test class
*/
public class ConfigureForDosVisitorTest {
class ConfigureForDosVisitorTest {
private final TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForDosVisitor.class);
@Test
public void testVisitForZoom() {
void testVisitForZoom() {
var conDos = new ConfigureForDosVisitor();
var zoom = new Zoom();
conDos.visit(zoom);
assertThat(logger.getLoggingEvents())
.extracting("level", "message")
.contains(tuple(INFO, zoom + " used with Dos configurator."));
}
@Test
public void testVisitForHayes() {
void testVisitForHayes() {
var conDos = new ConfigureForDosVisitor();
var hayes = new Hayes();
conDos.visit(hayes);
assertThat(logger.getLoggingEvents())
.extracting("level", "message")
.contains(tuple(INFO, hayes + " used with Dos configurator."));
}
@AfterEach
public void clearLoggers() {
TestLoggerFactory.clear();

View File

@ -23,35 +23,34 @@
package com.iluwatar.acyclicvisitor;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import uk.org.lidalia.slf4jtest.TestLogger;
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.tuple;
import static uk.org.lidalia.slf4jext.Level.INFO;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import uk.org.lidalia.slf4jtest.TestLogger;
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
/**
* ConfigureForUnixVisitor test class
*/
public class ConfigureForUnixVisitorTest {
class ConfigureForUnixVisitorTest {
private static final TestLogger LOGGER = TestLoggerFactory.getTestLogger(ConfigureForUnixVisitor.class);
@AfterEach
public void clearLoggers() {
TestLoggerFactory.clear();
}
@Test
public void testVisitForZoom() {
void testVisitForZoom() {
var conUnix = new ConfigureForUnixVisitor();
var zoom = new Zoom();
conUnix.visit(zoom);
assertThat(LOGGER.getLoggingEvents())
.extracting("level", "message")
.contains(tuple(INFO, zoom + " used with Unix configurator."));

View File

@ -23,34 +23,32 @@
package com.iluwatar.acyclicvisitor;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import org.junit.jupiter.api.Test;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
/**
* Hayes test class
*/
public class HayesTest {
class HayesTest {
@Test
public void testAcceptForDos() {
void testAcceptForDos() {
var hayes = new Hayes();
var mockVisitor = mock(ConfigureForDosVisitor.class);
hayes.accept(mockVisitor);
verify((HayesVisitor)mockVisitor).visit(eq(hayes));
verify((HayesVisitor) mockVisitor).visit(eq(hayes));
}
@Test
public void testAcceptForUnix() {
void testAcceptForUnix() {
var hayes = new Hayes();
var mockVisitor = mock(ConfigureForUnixVisitor.class);
hayes.accept(mockVisitor);
verifyZeroInteractions(mockVisitor);
}
}

View File

@ -24,32 +24,32 @@
package com.iluwatar.acyclicvisitor;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.mock;
import org.junit.jupiter.api.Test;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Zoom test class
*/
public class ZoomTest {
class ZoomTest {
@Test
public void testAcceptForDos() {
void testAcceptForDos() {
var zoom = new Zoom();
var mockVisitor = mock(ConfigureForDosVisitor.class);
zoom.accept(mockVisitor);
verify((ZoomVisitor)mockVisitor).visit(eq(zoom));
verify((ZoomVisitor) mockVisitor).visit(eq(zoom));
}
@Test
public void testAcceptForUnix() {
void testAcceptForUnix() {
var zoom = new Zoom();
var mockVisitor = mock(ConfigureForUnixVisitor.class);
zoom.accept(mockVisitor);
verify((ZoomVisitor)mockVisitor).visit(eq(zoom));
verify((ZoomVisitor) mockVisitor).visit(eq(zoom));
}
}

View File

@ -4,6 +4,7 @@ title: Adapter
folder: adapter
permalink: /patterns/adapter/
categories: Structural
language: en
tags:
- Gang of Four
---
@ -17,10 +18,10 @@ couldn't otherwise because of incompatible interfaces.
## Explanation
Real world example
Real-world example
> Consider that you have some pictures in your memory card and you need to transfer them to your computer. In order to transfer them you need some kind of adapter that is compatible with your computer ports so that you can attach memory card to your computer. In this case card reader is an adapter.
> Another example would be the famous power adapter; a three legged plug can't be connected to a two pronged outlet, it needs to use a power adapter that makes it compatible with the two pronged outlet.
> Consider that you have some pictures on your memory card and you need to transfer them to your computer. To transfer them, you need some kind of adapter that is compatible with your computer ports so that you can attach a memory card to your computer. In this case card reader is an adapter.
> Another example would be the famous power adapter; a three-legged plug can't be connected to a two-pronged outlet, it needs to use a power adapter that makes it compatible with the two-pronged outlets.
> Yet another example would be a translator translating words spoken by one person to another
In plain words
@ -35,15 +36,15 @@ Wikipedia says
Consider a captain that can only use rowing boats and cannot sail at all.
First we have interfaces `RowingBoat` and `FishingBoat`
First, we have interfaces `RowingBoat` and `FishingBoat`
```java
public interface RowingBoat {
void row();
}
@Slf4j
public class FishingBoat {
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoat.class);
public void sail() {
LOGGER.info("The fishing boat is sailing");
}
@ -67,13 +68,12 @@ public class Captain {
}
```
Now let's say the pirates are coming and our captain needs to escape but there is only fishing boat available. We need to create an adapter that allows the captain to operate the fishing boat with his rowing boat skills.
Now let's say the pirates are coming and our captain needs to escape but there is only a fishing boat available. We need to create an adapter that allows the captain to operate the fishing boat with his rowing boat skills.
```java
@Slf4j
public class FishingBoatAdapter implements RowingBoat {
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoatAdapter.class);
private final FishingBoat boat;
public FishingBoatAdapter() {
@ -100,25 +100,31 @@ captain.row();
## Applicability
Use the Adapter pattern when
* you want to use an existing class, and its interface does not match the one you need
* you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces
* 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.
* most of the applications using third party libraries use adapters as a middle layer between the application and the 3rd party library to decouple the application from the library. If another library has to be used only an adapter for the new library is required without having to change the application code.
* You want to use an existing class, and its interface does not match the one you need
* You want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces
* You need to use several existing subclasses, but it's impractical to adapt their interface by subclassing everyone. An object adapter can adapt the interface of its parent class.
* Most of the applications using third-party libraries use adapters as a middle layer between the application and the 3rd party library to decouple the application from the library. If another library has to be used only an adapter for the new library is required without having to change the application code.
## Consequences:
## Tutorials
* [Dzone](https://dzone.com/articles/adapter-design-pattern-in-java)
* [Refactoring Guru](https://refactoring.guru/design-patterns/adapter/java/example)
* [Baeldung](https://www.baeldung.com/java-adapter-pattern)
## Consequences
Class and object adapters have different trade-offs. A class adapter
* adapts Adaptee to Target by committing to a concrete Adaptee class. As a consequence, a class adapter wont work when we want to adapt a class and all its subclasses.
* lets Adapter override some of Adaptees behavior, since Adapter is a subclass of Adaptee.
* introduces only one object, and no additional pointer indirection is needed to get to the adaptee.
* Adapts Adaptee to Target by committing to a concrete Adaptee class. As a consequence, a class adapter wont work when we want to adapt a class and all its subclasses.
* Lets Adapter override some of Adaptees behavior since Adapter is a subclass of Adaptee.
* Introduces only one object, and no additional pointer indirection is needed to get to the adaptee.
An object adapter
* lets a single Adapter work with many Adaptees—that is, the Adaptee itself and all of its subclasses (if any). The Adapter can also add functionality to all Adaptees at once.
* makes it harder to override Adaptee behavior. It will require subclassing Adaptee and making Adapter refer to the subclass rather than the Adaptee itself.
* Lets a single Adapter work with many Adaptees—that is, the Adaptee itself and all of its subclasses (if any). The Adapter can also add functionality to all Adaptees at once.
* Makes it harder to override Adaptee behavior. It will require subclassing Adaptee and making the Adapter refer to the subclass rather than the Adaptee itself.
## Real world examples
## Real-world examples
* [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29)
* [java.util.Collections#list()](https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#list-java.util.Enumeration-)

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
@ -23,48 +23,45 @@
THE SOFTWARE.
-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<artifactId>adapter</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven assembly plugin is invoked with default setting which we have
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<artifactId>adapter</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven assembly plugin is invoked with default setting which we have
in parent pom and specifying the class having main method -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.adapter.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.adapter.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -23,24 +23,20 @@
package com.iluwatar.adapter;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* The Captain uses {@link RowingBoat} to sail. <br> This is the client in the pattern.
*/
@Setter
@NoArgsConstructor
@AllArgsConstructor
public final class Captain {
private RowingBoat rowingBoat;
public Captain() {
}
public Captain(final RowingBoat boat) {
this.rowingBoat = boat;
}
void setRowingBoat(final RowingBoat boat) {
this.rowingBoat = boat;
}
void row() {
rowingBoat.row();
}

View File

@ -23,18 +23,15 @@
package com.iluwatar.adapter;
import static org.slf4j.LoggerFactory.getLogger;
import org.slf4j.Logger;
import lombok.extern.slf4j.Slf4j;
/**
* Device class (adaptee in the pattern). We want to reuse this class. Fishing boat moves by
* sailing.
*/
@Slf4j
final class FishingBoat {
private static final Logger LOGGER = getLogger(FishingBoat.class);
void sail() {
LOGGER.info("The fishing boat is sailing");
}

View File

@ -29,11 +29,7 @@ package com.iluwatar.adapter;
*/
public class FishingBoatAdapter implements RowingBoat {
private final FishingBoat boat;
public FishingBoatAdapter() {
boat = new FishingBoat();
}
private final FishingBoat boat = new FishingBoat();
public final void row() {
boat.sail();

View File

@ -23,18 +23,19 @@
package com.iluwatar.adapter;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
/**
* Test class
* Tests for the adapter pattern.
*/
public class AdapterPatternTest {
class AdapterPatternTest {
private Map<String, Object> beans;
@ -64,7 +65,7 @@ public class AdapterPatternTest {
* by the client ({@link Captain} ).
*/
@Test
public void testAdapter() {
void testAdapter() {
var captain = (Captain) beans.get(ROWING_BEAN);
// when captain moves

View File

@ -33,9 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
class AppTest {
/**
* Issue: Add at least one assertion to this test case.
*
* Solution: Inserted assertion to check whether the execution of the main method in {@link App}
* Check whether the execution of the main method in {@link App}
* throws an exception.
*/

View File

@ -4,6 +4,7 @@ title: Aggregator Microservices
folder: aggregator-microservices
permalink: /patterns/aggregator-microservices/
categories: Architectural
language: en
tags:
- Cloud distributed
- Decoupling

View File

@ -23,68 +23,65 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-service</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Maven assembly plugin is invoked with default setting which we have
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-service</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Maven assembly plugin is invoked with default setting which we have
in parent pom and specifying the class having main method -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.aggregator.microservices.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.aggregator.microservices.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -26,8 +26,7 @@ package com.iluwatar.aggregator.microservices;
import static java.util.Objects.requireNonNullElse;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
@ -37,20 +36,18 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class Aggregator {
@Resource
private ProductInformationClient informationClient;
@Resource
private ProductInventoryClient inventoryClient;
/**
* Retrieves product data.
*
* @return a Product.
*/
@RequestMapping(path = "/product", method = RequestMethod.GET)
@GetMapping("/product")
public Product getProduct() {
var product = new Product();

View File

@ -23,9 +23,14 @@
package com.iluwatar.aggregator.microservices;
import lombok.Getter;
import lombok.Setter;
/**
* Encapsulates all the data for a Product that clients will request.
*/
@Getter
@Setter
public class Product {
/**
@ -39,20 +44,4 @@ public class Product {
*/
private int productInventories;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getProductInventories() {
return productInventories;
}
public void setProductInventories(int productInventories) {
this.productInventories = productInventories;
}
}

View File

@ -28,18 +28,16 @@ import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* An adapter to communicate with information micro-service.
*/
@Slf4j
@Component
public class ProductInformationClientImpl implements ProductInformationClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInformationClientImpl.class);
@Override
public String getProductTitle() {
var request = HttpRequest.newBuilder()
@ -54,6 +52,7 @@ public class ProductInformationClientImpl implements ProductInformationClient {
LOGGER.error("IOException Occurred", ioe);
} catch (InterruptedException ie) {
LOGGER.error("InterruptedException Occurred", ie);
Thread.currentThread().interrupt();
}
return null;
}

View File

@ -28,18 +28,16 @@ import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* An adapter to communicate with inventory micro-service.
*/
@Slf4j
@Component
public class ProductInventoryClientImpl implements ProductInventoryClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInventoryClientImpl.class);
@Override
public Integer getProductInventories() {
var response = "";
@ -56,6 +54,7 @@ public class ProductInventoryClientImpl implements ProductInventoryClient {
LOGGER.error("IOException Occurred", ioe);
} catch (InterruptedException ie) {
LOGGER.error("InterruptedException Occurred", ie);
Thread.currentThread().interrupt();
}
if ("".equalsIgnoreCase(response)) {
return null;

View File

@ -23,19 +23,19 @@
package com.iluwatar.aggregator.microservices;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
/**
* Test Aggregation of domain objects
*/
public class AggregatorTest {
class AggregatorTest {
@InjectMocks
private Aggregator aggregator;
@ -48,14 +48,14 @@ public class AggregatorTest {
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
}
/**
* Tests getting the data for a desktop client
*/
@Test
public void testGetProduct() {
void testGetProduct() {
var title = "The Product Title.";
var inventories = 5;

View File

@ -23,63 +23,58 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>information-microservice</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.information.microservices.InformationApplication</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>information-microservice</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.information.microservices.InformationApplication</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -23,8 +23,7 @@
package com.iluwatar.information.microservice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
@ -38,7 +37,7 @@ public class InformationController {
*
* @return product inventory.
*/
@RequestMapping(value = "/information", method = RequestMethod.GET)
@GetMapping("/information")
public String getProductTitle() {
return "The Product Title.";
}

View File

@ -23,17 +23,17 @@
package com.iluwatar.information.microservice;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Information Rest Controller
*/
public class InformationControllerTest {
class InformationControllerTest {
@Test
public void shouldGetProductTitle() {
void shouldGetProductTitle() {
var infoController = new InformationController();
var title = infoController.getProductTitle();
assertEquals("The Product Title.", title);

View File

@ -23,62 +23,58 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>inventory-microservice</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.inventory.microservices.InventoryApplication</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>inventory-microservice</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.inventory.microservices.InventoryApplication</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -23,8 +23,7 @@
package com.iluwatar.inventory.microservice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
@ -38,7 +37,7 @@ public class InventoryController {
*
* @return product inventory.
*/
@RequestMapping(value = "/inventories", method = RequestMethod.GET)
@GetMapping("/inventories")
public int getProductInventories() {
return 5;
}

View File

@ -23,16 +23,17 @@
package com.iluwatar.inventory.microservice;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test Inventory Rest Controller
*/
public class InventoryControllerTest {
class InventoryControllerTest {
@Test
public void testGetProductInventories() {
void testGetProductInventories() {
var inventoryController = new InventoryController();
var numberOfInventories = inventoryController.getProductInventories();
assertEquals(5, numberOfInventories);

View File

@ -23,20 +23,18 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-microservices</artifactId>
<packaging>pom</packaging>
<modules>
<module>information-microservice</module>
<module>aggregator-service</module>
<module>inventory-microservice</module>
</modules>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-microservices</artifactId>
<packaging>pom</packaging>
<modules>
<module>information-microservice</module>
<module>aggregator-service</module>
<module>inventory-microservice</module>
</modules>
</project>

View File

@ -4,6 +4,7 @@ title: Ambassador
folder: ambassador
permalink: /patterns/ambassador/
categories: Structural
language: en
tags:
- Decoupling
- Cloud distributed
@ -48,9 +49,8 @@ interface RemoteServiceInterface {
A remote services represented as a singleton.
```java
@Slf4j
public class RemoteService implements RemoteServiceInterface {
private static final Logger LOGGER = LoggerFactory.getLogger(RemoteService.class);
private static RemoteService service = null;
static synchronized RemoteService getRemoteService() {
@ -80,9 +80,8 @@ public class RemoteService implements RemoteServiceInterface {
A service ambassador adding additional features such as logging, latency checks
```java
@Slf4j
public class ServiceAmbassador implements RemoteServiceInterface {
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceAmbassador.class);
private static final int RETRIES = 3;
private static final int DELAY_MS = 3000;
@ -132,9 +131,8 @@ public class ServiceAmbassador implements RemoteServiceInterface {
A client has a local service ambassador used to interact with the remote service:
```java
@Slf4j
public class Client {
private static final Logger LOGGER = LoggerFactory.getLogger(Client.class);
private final ServiceAmbassador serviceAmbassador = new ServiceAmbassador();
long useService(int value) {

View File

@ -23,40 +23,38 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ambassador</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.ambassador.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ambassador</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.ambassador.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -23,20 +23,19 @@
package com.iluwatar.ambassador;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* A simple Client.
*/
@Slf4j
public class Client {
private static final Logger LOGGER = LoggerFactory.getLogger(Client.class);
private final ServiceAmbassador serviceAmbassador = new ServiceAmbassador();
long useService(int value) {
var result = serviceAmbassador.doRemoteFunction(value);
LOGGER.info("Service result: " + result);
LOGGER.info("Service result: {}", result);
return result;
}
}

View File

@ -26,15 +26,14 @@ package com.iluwatar.ambassador;
import static java.lang.Thread.sleep;
import com.iluwatar.ambassador.util.RandomProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* A remote legacy application represented by a Singleton implementation.
*/
@Slf4j
public class RemoteService implements RemoteServiceInterface {
private static final int THRESHOLD = 200;
private static final Logger LOGGER = LoggerFactory.getLogger(RemoteService.class);
private static RemoteService service = null;
private final RandomProvider randomProvider;
@ -73,8 +72,9 @@ public class RemoteService implements RemoteServiceInterface {
sleep(waitTime);
} catch (InterruptedException e) {
LOGGER.error("Thread sleep state interrupted", e);
Thread.currentThread().interrupt();
}
return waitTime <= THRESHOLD ? value * 10
: RemoteServiceStatus.FAILURE.getRemoteServiceStatusValue();
: RemoteServiceStatus.FAILURE.getRemoteServiceStatusValue();
}
}

View File

@ -33,8 +33,7 @@ package com.iluwatar.ambassador;
*/
public enum RemoteServiceStatus {
FAILURE(-1)
;
FAILURE(-1);
private final long remoteServiceStatusValue;

View File

@ -26,17 +26,16 @@ package com.iluwatar.ambassador;
import static com.iluwatar.ambassador.RemoteServiceStatus.FAILURE;
import static java.lang.Thread.sleep;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* ServiceAmbassador provides an interface for a ({@link Client}) to access ({@link RemoteService}).
* The interface adds logging, latency testing and usage of the service in a safe way that will not
* add stress to the remote service when connectivity issues occur.
*/
@Slf4j
public class ServiceAmbassador implements RemoteServiceInterface {
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceAmbassador.class);
private static final int RETRIES = 3;
private static final int DELAY_MS = 3000;
@ -53,7 +52,7 @@ public class ServiceAmbassador implements RemoteServiceInterface {
var result = RemoteService.getRemoteService().doRemoteFunction(value);
var timeTaken = System.currentTimeMillis() - startTime;
LOGGER.info("Time taken (ms): " + timeTaken);
LOGGER.info("Time taken (ms): {}", timeTaken);
return result;
}
@ -67,12 +66,13 @@ public class ServiceAmbassador implements RemoteServiceInterface {
}
if ((result = checkLatency(value)) == FAILURE.getRemoteServiceStatusValue()) {
LOGGER.info("Failed to reach remote: (" + (i + 1) + ")");
LOGGER.info("Failed to reach remote: ({})", i + 1);
retries++;
try {
sleep(DELAY_MS);
} catch (InterruptedException e) {
LOGGER.error("Thread sleep state interrupted", e);
Thread.currentThread().interrupt();
}
} else {
break;

View File

@ -4,6 +4,7 @@ title: API Gateway
folder: api-gateway
permalink: /patterns/api-gateway/
categories: Architectural
language: en
tags:
- Cloud distributed
- Decoupling

View File

@ -23,13 +23,11 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway-service</artifactId>
@ -54,7 +52,6 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View File

@ -24,8 +24,7 @@
package com.iluwatar.api.gateway;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
@ -45,7 +44,7 @@ public class ApiGateway {
*
* @return Product information for clients on a desktop
*/
@RequestMapping(path = "/desktop", method = RequestMethod.GET)
@GetMapping("/desktop")
public DesktopProduct getProductDesktop() {
var desktopProduct = new DesktopProduct();
desktopProduct.setImagePath(imageClient.getImagePath());
@ -58,7 +57,7 @@ public class ApiGateway {
*
* @return Product information for clients on a mobile device
*/
@RequestMapping(path = "/mobile", method = RequestMethod.GET)
@GetMapping("/mobile")
public MobileProduct getProductMobile() {
var mobileProduct = new MobileProduct();
mobileProduct.setPrice(priceClient.getPrice());

View File

@ -23,10 +23,16 @@
package com.iluwatar.api.gateway;
import lombok.Getter;
import lombok.Setter;
/**
* Encapsulates all of the information that a desktop client needs to display a product.
*/
@Getter
@Setter
public class DesktopProduct {
/**
* The price of the product.
*/
@ -37,19 +43,4 @@ public class DesktopProduct {
*/
private String imagePath;
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getImagePath() {
return imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
}

View File

@ -23,24 +23,21 @@
package com.iluwatar.api.gateway;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import org.slf4j.Logger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* An adapter to communicate with the Image microservice.
*/
@Slf4j
@Component
public class ImageClientImpl implements ImageClient {
private static final Logger LOGGER = getLogger(ImageClientImpl.class);
/**
* Makes a simple HTTP Get request to the Image microservice.
@ -60,8 +57,11 @@ public class ImageClientImpl implements ImageClient {
var httpResponse = httpClient.send(httpGet, BodyHandlers.ofString());
logResponse(httpResponse);
return httpResponse.body();
} catch (IOException | InterruptedException e) {
LOGGER.error("Failure occurred while getting image path", e);
} catch (IOException ioe) {
LOGGER.error("Failure occurred while getting image path", ioe);
} catch (InterruptedException ie) {
LOGGER.error("Failure occurred while getting image path", ie);
Thread.currentThread().interrupt();
}
return null;

View File

@ -23,20 +23,17 @@
package com.iluwatar.api.gateway;
import lombok.Getter;
import lombok.Setter;
/**
* Encapsulates all of the information that mobile client needs to display a product.
*/
@Getter
@Setter
public class MobileProduct {
/**
* The price of the product.
*/
private String price;
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
}

View File

@ -23,25 +23,22 @@
package com.iluwatar.api.gateway;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import org.slf4j.Logger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* An adapter to communicate with the Price microservice.
*/
@Slf4j
@Component
public class PriceClientImpl implements PriceClient {
private static final Logger LOGGER = getLogger(PriceClientImpl.class);
/**
* Makes a simple HTTP Get request to the Price microservice.
@ -61,8 +58,11 @@ public class PriceClientImpl implements PriceClient {
var httpResponse = httpClient.send(httpGet, BodyHandlers.ofString());
logResponse(httpResponse);
return httpResponse.body();
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
LOGGER.error("Failure occurred while getting price info", e);
} catch (InterruptedException e) {
LOGGER.error("Failure occurred while getting price info", e);
Thread.currentThread().interrupt();
}
return null;

View File

@ -35,7 +35,7 @@ import org.mockito.MockitoAnnotations;
/**
* Test API Gateway Pattern
*/
public class ApiGatewayTest {
class ApiGatewayTest {
@InjectMocks
private ApiGateway apiGateway;
@ -48,14 +48,14 @@ public class ApiGatewayTest {
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
}
/**
* Tests getting the data for a desktop client
*/
@Test
public void testGetProductDesktop() {
void testGetProductDesktop() {
var imagePath = "/product-image.png";
var price = "20";
when(imageClient.getImagePath()).thenReturn(imagePath);
@ -71,7 +71,7 @@ public class ApiGatewayTest {
* Tests getting the data for a mobile client
*/
@Test
public void testGetProductMobile() {
void testGetProductMobile() {
var price = "20";
when(priceClient.getPrice()).thenReturn(price);

View File

@ -23,13 +23,11 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>image-microservice</artifactId>
@ -49,7 +47,6 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View File

@ -23,27 +23,24 @@
package com.iluwatar.image.microservice;
import static org.slf4j.LoggerFactory.getLogger;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Exposes the Image microservice's endpoints.
*/
@Slf4j
@RestController
public class ImageController {
private static final Logger LOGGER = getLogger(ImageController.class);
/**
* An endpoint for a user to retrieve an image path.
*
* @return An image path
*/
@RequestMapping(value = "/image-path", method = RequestMethod.GET)
@GetMapping("/image-path")
public String getImagePath() {
LOGGER.info("Successfully found image path");
return "/product-image.png";

View File

@ -23,16 +23,17 @@
package com.iluwatar.image.microservice;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Image Rest Controller
*/
public class ImageControllerTest {
class ImageControllerTest {
@Test
public void testGetImagePath() {
void testGetImagePath() {
var imageController = new ImageController();
var imagePath = imageController.getImagePath();
assertEquals("/product-image.png", imagePath);

View File

@ -23,13 +23,11 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway</artifactId>

View File

@ -23,19 +23,15 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>price-microservice</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
@ -51,7 +47,6 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View File

@ -23,27 +23,24 @@
package com.iluwatar.price.microservice;
import static org.slf4j.LoggerFactory.getLogger;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Exposes the Price microservice's endpoints.
*/
@Slf4j
@RestController
public class PriceController {
private static final Logger LOGGER = getLogger(PriceController.class);
/**
* An endpoint for a user to retrieve a product's price.
*
* @return A product's price
*/
@RequestMapping(value = "/price", method = RequestMethod.GET)
@GetMapping("/price")
public String getPrice() {
LOGGER.info("Successfully found price info");
return "20";

View File

@ -23,16 +23,17 @@
package com.iluwatar.price.microservice;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Price Rest Controller
*/
public class PriceControllerTest {
class PriceControllerTest {
@Test
public void testgetPrice() {
void testgetPrice() {
var priceController = new PriceController();
var price = priceController.getPrice();
assertEquals("20", price);

View File

@ -4,6 +4,7 @@ title: Arrange/Act/Assert
folder: arrange-act-assert
permalink: /patterns/arrange-act-assert/
categories: Idiom
language: en
tags:
- Testing
---
@ -81,10 +82,10 @@ Then we write our unit tests according to Arrange/Act/Assert pattern. Notice the
separated steps for each unit test.
```java
public class CashAAATest {
class CashAAATest {
@Test
public void testPlus() {
void testPlus() {
//Arrange
var cash = new Cash(3);
//Act
@ -94,7 +95,7 @@ public class CashAAATest {
}
@Test
public void testMinus() {
void testMinus() {
//Arrange
var cash = new Cash(8);
//Act
@ -105,7 +106,7 @@ public class CashAAATest {
}
@Test
public void testInsufficientMinus() {
void testInsufficientMinus() {
//Arrange
var cash = new Cash(1);
//Act
@ -116,7 +117,7 @@ public class CashAAATest {
}
@Test
public void testUpdate() {
void testUpdate() {
//Arrange
var cash = new Cash(5);
//Act

View File

@ -23,22 +23,19 @@
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.24.0-SNAPSHOT</version>
<version>1.26.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>arrange-act-assert</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>

View File

@ -23,18 +23,17 @@
package com.iluwatar.arrangeactassert;
import lombok.AllArgsConstructor;
/**
* Arrange/Act/Assert (AAA) is a unit test pattern. In this simple example, we have a ({@link Cash})
* object for plus, minus and counting amount.
*/
@AllArgsConstructor
public class Cash {
private int amount;
Cash(int amount) {
this.amount = amount;
}
//plus
void plus(int addend) {
amount += addend;

View File

@ -23,11 +23,11 @@
package com.iluwatar.arrangeactassert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Arrange/Act/Assert (AAA) is a pattern for organizing unit tests. It is a way to structure your
@ -51,10 +51,11 @@ import org.junit.Test;
* change and one reason to fail. In a large and complicated code base, tests that honor the single
* responsibility principle are much easier to troubleshoot.
*/
public class CashAAATest {
class CashAAATest {
@Test
public void testPlus() {
void testPlus() {
//Arrange
var cash = new Cash(3);
//Act
@ -64,7 +65,7 @@ public class CashAAATest {
}
@Test
public void testMinus() {
void testMinus() {
//Arrange
var cash = new Cash(8);
//Act
@ -75,7 +76,7 @@ public class CashAAATest {
}
@Test
public void testInsufficientMinus() {
void testInsufficientMinus() {
//Arrange
var cash = new Cash(1);
//Act
@ -86,7 +87,7 @@ public class CashAAATest {
}
@Test
public void testUpdate() {
void testUpdate() {
//Arrange
var cash = new Cash(5);
//Act

View File

@ -23,23 +23,24 @@
package com.iluwatar.arrangeactassert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* ({@link CashAAATest}) is an anti-example of AAA pattern. This test is functionally correct, but
* with the addition of new feature, it needs refactoring. There are an awful lot of steps in that
* with the addition of a new feature, it needs refactoring. There are an awful lot of steps in that
* test method, but it verifies the class' important behavior in just eleven lines. It violates the
* single responsibility principle. If this test method failed after a small code change, it might
* take some digging to discover why.
*/
public class CashAntiAAATest {
class CashAntiAAATest {
@Test
public void testCash() {
void testCash() {
//initialize
var cash = new Cash(3);
//test plus

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 802 B

View File

@ -4,26 +4,166 @@ title: Async Method Invocation
folder: async-method-invocation
permalink: /patterns/async-method-invocation/
categories: Concurrency
language: en
tags:
- Reactive
---
## Intent
Asynchronous method invocation is pattern where the calling thread
Asynchronous method invocation is a pattern where the calling thread
is not blocked while waiting results of tasks. The pattern provides parallel
processing of multiple independent tasks and retrieving the results via
callbacks or waiting until everything is done.
## Explanation
Real world example
> Launching space rockets is an exciting business. The mission command gives an order to launch and
> after some undetermined time, the rocket either launches successfully or fails miserably.
In plain words
> Asynchronous method invocation starts task processing and returns immediately before the task is
> ready. The results of the task processing are returned to the caller later.
Wikipedia says
> In multithreaded computer programming, asynchronous method invocation (AMI), also known as
> asynchronous method calls or the asynchronous pattern is a design pattern in which the call site
> is not blocked while waiting for the called code to finish. Instead, the calling thread is
> notified when the reply arrives. Polling for a reply is an undesired option.
**Programmatic Example**
In this example, we are launching space rockets and deploying lunar rovers.
The application demonstrates the async method invocation pattern. The key parts of the pattern are
`AsyncResult` which is an intermediate container for an asynchronously evaluated value,
`AsyncCallback` which can be provided to be executed on task completion and `AsyncExecutor` that
manages the execution of the async tasks.
```java
public interface AsyncResult<T> {
boolean isCompleted();
T getValue() throws ExecutionException;
void await() throws InterruptedException;
}
```
```java
public interface AsyncCallback<T> {
void onComplete(T value, Optional<Exception> ex);
}
```
```java
public interface AsyncExecutor {
<T> AsyncResult<T> startProcess(Callable<T> task);
<T> AsyncResult<T> startProcess(Callable<T> task, AsyncCallback<T> callback);
<T> T endProcess(AsyncResult<T> asyncResult) throws ExecutionException, InterruptedException;
}
```
`ThreadAsyncExecutor` is an implementation of `AsyncExecutor`. Some of its key parts are highlighted
next.
```java
public class ThreadAsyncExecutor implements AsyncExecutor {
@Override
public <T> AsyncResult<T> startProcess(Callable<T> task) {
return startProcess(task, null);
}
@Override
public <T> AsyncResult<T> startProcess(Callable<T> task, AsyncCallback<T> callback) {
var result = new CompletableResult<>(callback);
new Thread(
() -> {
try {
result.setValue(task.call());
} catch (Exception ex) {
result.setException(ex);
}
},
"executor-" + idx.incrementAndGet())
.start();
return result;
}
@Override
public <T> T endProcess(AsyncResult<T> asyncResult)
throws ExecutionException, InterruptedException {
if (!asyncResult.isCompleted()) {
asyncResult.await();
}
return asyncResult.getValue();
}
}
```
Then we are ready to launch some rockets to see how everything works together.
```java
public static void main(String[] args) throws Exception {
// construct a new executor that will run async tasks
var executor = new ThreadAsyncExecutor();
// start few async tasks with varying processing times, two last with callback handlers
final var asyncResult1 = executor.startProcess(lazyval(10, 500));
final var asyncResult2 = executor.startProcess(lazyval("test", 300));
final var asyncResult3 = executor.startProcess(lazyval(50L, 700));
final var asyncResult4 = executor.startProcess(lazyval(20, 400), callback("Deploying lunar rover"));
final var asyncResult5 =
executor.startProcess(lazyval("callback", 600), callback("Deploying lunar rover"));
// emulate processing in the current thread while async tasks are running in their own threads
Thread.sleep(350); // Oh boy, we are working hard here
log("Mission command is sipping coffee");
// wait for completion of the tasks
final var result1 = executor.endProcess(asyncResult1);
final var result2 = executor.endProcess(asyncResult2);
final var result3 = executor.endProcess(asyncResult3);
asyncResult4.await();
asyncResult5.await();
// log the results of the tasks, callbacks log immediately when complete
log("Space rocket <" + result1 + "> launch complete");
log("Space rocket <" + result2 + "> launch complete");
log("Space rocket <" + result3 + "> launch complete");
}
```
Here's the program console output.
```java
21:47:08.227 [executor-2] INFO com.iluwatar.async.method.invocation.App - Space rocket <test> launched successfully
21:47:08.269 [main] INFO com.iluwatar.async.method.invocation.App - Mission command is sipping coffee
21:47:08.318 [executor-4] INFO com.iluwatar.async.method.invocation.App - Space rocket <20> launched successfully
21:47:08.335 [executor-4] INFO com.iluwatar.async.method.invocation.App - Deploying lunar rover <20>
21:47:08.414 [executor-1] INFO com.iluwatar.async.method.invocation.App - Space rocket <10> launched successfully
21:47:08.519 [executor-5] INFO com.iluwatar.async.method.invocation.App - Space rocket <callback> launched successfully
21:47:08.519 [executor-5] INFO com.iluwatar.async.method.invocation.App - Deploying lunar rover <callback>
21:47:08.616 [executor-3] INFO com.iluwatar.async.method.invocation.App - Space rocket <50> launched successfully
21:47:08.617 [main] INFO com.iluwatar.async.method.invocation.App - Space rocket <10> launch complete
21:47:08.617 [main] INFO com.iluwatar.async.method.invocation.App - Space rocket <test> launch complete
21:47:08.618 [main] INFO com.iluwatar.async.method.invocation.App - Space rocket <50> launch complete
```
# Class diagram
![alt text](./etc/async-method-invocation.png "Async Method Invocation")
## Applicability
Use async method invocation pattern when
Use the async method invocation pattern when
* You have multiple independent tasks that can run in parallel
* You need to improve the performance of a group of sequential tasks
* You have limited amount of processing capacity or long running tasks and the
caller should not wait the tasks to be ready
* You have a limited amount of processing capacity or long-running tasks and the caller should not wait for the tasks to be ready
## Real world examples

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
@ -23,51 +23,43 @@
THE SOFTWARE.
-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.24.0-SNAPSHOT</version>
</parent>
<artifactId>async-method-invocation</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.async.method.invocation.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.26.0-SNAPSHOT</version>
</parent>
<artifactId>async-method-invocation</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.async.method.invocation.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Some files were not shown because too many files have changed in this diff Show More