Compare commits

..

1361 Commits

Author SHA1 Message Date
npathai
5a56b922e4 Updated class diagram PNG 2018-10-21 14:06:08 +05:30
Narendra Pathai
c0da4b3165 Removed sonar issue and converted Audio to eager singleton for simplicity 2018-10-16 12:55:33 +05:30
Narendra Pathai
9bbb4da3d5 1) Test cases were not stopping AudioService before ending test case 2) Changed Audio to be a good singleton, previously because of Audio being bad singleton, test cases which were using static methods could have caused intermittent failures. 3) Made some other refactorings as well 2018-10-16 12:15:39 +05:30
Ilkka Seppälä
db33cc533b Remove CII best practices badge 2018-10-13 18:40:10 +03:00
Ilkka Seppälä
8433c7b712 Merge pull request from andrievsky/master
Fix redundant list alloc in LotteryNumbers
2018-10-13 18:28:40 +03:00
Ilkka Seppälä
ee74fec53c Fix pattern title 2018-09-30 21:36:32 +03:00
Ilkka Seppälä
7a7e891384 Set version for next development iteration 2018-09-30 21:05:57 +03:00
Ilkka Seppälä
26d6d96f78 Reach milestone 1.20.0 2018-09-30 21:03:48 +03:00
Ilkka Seppälä
3cec7a9ec1 Merge pull request from LyndonArmitage/module-ignore-test-output
Delete & Ignore output.txt & error.txt
2018-09-25 22:49:25 +03:00
Ilkka Seppälä
b079aec1fd Merge pull request from iluwatar/Issue781
 Resolved ClasscastException from Acyclic Visitor
2018-09-25 22:45:25 +03:00
Lyndon Armitage
8f53df91b9 Delete & Ignore output.txt & error.txt
Both output.txt and error.txt are produced by tests.
Each file contained a header that was overridden upon executing said
tests causing tracked files to be changed.

Added them to a local .gitignore file for this module.
2018-09-24 10:08:02 +01:00
Narendra Pathai
709405d964 Resolved checkstyle issues 2018-09-11 16:11:59 +05:30
Narendra Pathai
f3749a2b9d Solved the classcast exception and used instanceof instead. Improved javadocs a bit. 2018-09-11 15:58:14 +05:30
Nick Andrievsky
1d12d94bac Fix redundant list alloc in LotteryNumbers 2018-09-11 11:55:53 +02:00
Narendra Pathai
9e56e5cbc1 Merge pull request from er2/executeAroundLambda
Execute Around - use lambda
2018-09-09 00:24:42 +05:30
Narendra Pathai
1698b066f3 Merge pull request from nikhilbarar/collection-pipeline
: Collection Pipeline pattern
2018-09-09 00:21:45 +05:30
nikhilbarar
4ed039d807 Updated UCLS file and PNG image 2018-09-08 20:38:04 +05:30
Eric Riese
ec6d2a8ebe execute around lambda 2018-09-07 22:29:51 -04:00
nikhilbarar
98c3f93e82 Review changes in Test Cases 2018-09-04 20:52:11 +05:30
nikhilbarar
26fbbed62e Typo in Readme 2018-09-01 15:48:36 +05:30
nikhilbarar
0f9089dd62 Typo in Readme 2018-09-01 15:48:07 +05:30
Narendra Pathai
038befea26 Merge pull request from mitchellirvin/bst-iterator
: Binary Search Tree Iterator
2018-08-30 12:46:13 +05:30
nikhilbarar
9daa3140e4 Category Enum for category of Car 2018-08-29 22:02:17 +05:30
mxi1809
8458e426bc correcting raw types for the item Iterator. 2018-08-29 07:36:52 -04:00
Mitchell Irvin
e6f84f2f41 modified return type of TreasureChestItemIterator's constructor to be Iterator 2018-08-28 07:46:02 -04:00
Narendra Pathai
74f3799eb4 Merge pull request from diffblue-assistant/finallyclosetotrywithresources
Use try-with-resources
2018-08-28 13:17:16 +05:30
nikhilbarar
b23d8430af Added Missing class 2018-08-26 23:31:03 +05:30
nikhilbarar
cb6b0b3600 Checkstyle Fixes 2018-08-26 23:21:25 +05:30
nikhilbarar
cd44ef3c81 Review Changes 2018-08-26 23:12:33 +05:30
Mitchell Irvin
1c2ddfad54 Refactored App.java to remove duplicate code and elegantly demonstrate each implementation of the Iterator interface. Removed the redundant ItemIterator interface. Added insert() method to TreeNode class to allow for more elegant construction of BSTs. 2018-08-25 18:49:43 -04:00
Diffblue assistant
f36de036f6 Use try-with-resources
Replace try statements that close a resource in the finally block with a
try-with-resources statement [1].

This commit was created automatically by Diffblue refactorings (https://www.diffblue.com/).

[1] https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
2018-08-23 13:44:55 +01:00
Narendra Pathai
b64262303a Merge pull request from bordoisila1/checkstyle-minor-updates
Fixed minor changes suggested by Checkstyle
2018-08-21 11:20:16 +05:30
Narendra Pathai
9d012772fd Merge pull request from sgyyz/fix-image-name
Fix converter image Display Issue
2018-08-21 11:12:40 +05:30
bordoisila1
e1a2f141c5 Fixed minor changes suggested by Checkstyle 2018-08-20 22:36:58 -04:00
Yongzhi Yang
cce104a271 Fix converter image issue 2018-08-20 21:14:16 +08:00
Ilkka Seppälä
16df157181 Add license headers 2018-08-13 08:13:06 +03:00
Ilkka Seppälä
c34004bea5 Merge pull request from 7agustibm/master
First proposal for  Hexagonal Architecture primary ports should have interfaces
2018-08-10 22:42:09 +03:00
Mitchell Irvin
3e0cfa5684 Implemented BSTIterator. Included comprehensive unit and integration tests. Refactored file structure to be friendly to future contributors with iterators of more data structures. Added JUnitPlatform to enable running test suite across all iterator implementations. Added README to /binarysearchtree to document what it does and how it works. 2018-08-04 21:59:53 -04:00
nikhilbarar
ce459e8f9f Merge branch 'master' into collection-pipeline
# Conflicts:
#	pom.xml
2018-08-02 02:43:47 +05:30
nikhilbarar
535431fac1 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2018-08-02 02:30:08 +05:30
Ilkka Seppälä
facb9e51a6 Merge pull request from zenuo/master
Add an 'Override' annotaion
2018-08-01 16:02:23 +03:00
zenuo
9eb8c30bcb Add Annotation 'Override' to com.iluwatar.reactor.app.AppClient.TcpLoggingClient.run method. 2018-07-18 17:06:19 +08:00
nikhilbarar
fc87f8b7d3 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns
# Conflicts:
#	pom.xml
2018-07-08 23:09:55 +05:30
Agustí Becerra Milà
b453753790 Fix import not used 2018-07-08 19:38:54 +02:00
Agustí Becerra Milà
d2b900b524 Fix checkstyle & update interface services 2018-07-08 19:25:42 +02:00
nikhilbarar
2c8d1744df : Collection Pipeline pattern 2018-07-08 21:37:30 +05:30
Ilkka Seppälä
d915b66e70 Merge pull request from okinskas/ambassador
Ambassador Pattern 
2018-07-08 09:55:36 +03:00
nikhilbarar
328f917749 : Collection Pipeline pattern 2018-07-02 00:42:04 +05:30
Agustí Becerra Milà
ae07423470 First proposal 2018-07-01 16:29:07 +02:00
Ovidijus Okinskas
7add7b833c Merge branch 'master' into ambassador 2018-06-29 14:34:31 +01:00
Narendra Pathai
c7f9266768 Merge pull request from Argyro-Sioziou/master
Acyclic Visitor pattern 
2018-06-28 13:55:32 +05:30
Ovidijus Okinskas
0453bf9063 General cleanup. Simplifying code. Replacing all prints with appropriate Logger. 2018-06-23 13:24:07 +01:00
Argyro-Sioziou
f9bdd58bb7 Merge remote-tracking branch 'upstream/master' 2018-06-14 18:34:27 +03:00
Argyro-Sioziou
57f60c5ebf Updating javadoc comments 2018-06-14 18:30:46 +03:00
Argyro-Sioziou
51659fe9c5 Updating HayesVisitor and ZoomVisitor 2018-06-14 18:04:30 +03:00
Argyro-Sioziou
04d80f05c8 Adding consequences in README.md 2018-06-14 17:56:14 +03:00
Argyro-Sioziou
6636fb151b Adding AllModemVisitor interface 2018-06-14 12:40:41 +03:00
Argyro-Sioziou
6a0fa747ad Fixing typos 2018-06-14 12:18:46 +03:00
Argyro-Sioziou
8b1ed95d6b Updating ConfigureForDosVisitorTest and ConfigureForUnixVisitorTest classes 2018-06-14 12:14:35 +03:00
Argyro-Sioziou
6167d06dce Removing test case 2018-06-14 12:02:34 +03:00
Argyro-Sioziou
49feead13f Removing interfaces' test classes 2018-06-14 11:59:02 +03:00
Argyro-Sioziou
179a02bcdd Removing default constructors 2018-06-14 11:52:23 +03:00
nikhilbarar
71f61cd40e , : Added diagrams and Readme files 2018-06-13 23:40:36 +05:30
nikhilbarar
d54e29051f : Fix Checkstyle Issues 2018-06-13 02:54:09 +05:30
nikhilbarar
4456a440bc Monitor Object pattern 2018-06-13 02:43:25 +05:30
nikhilbarar
c48a1e9193 : Checkstyle Fixes 2018-06-11 01:56:32 +05:30
nikhilbarar
971a74e13a : Component Object Pattern 2018-06-11 00:38:03 +05:30
Ovidijus Okinskas
868e4561b5 Updating pom dependencies and adding license. 2018-06-05 21:16:16 +01:00
Ovidijus Okinskas
c4dd94a019 Fixing CheckStyle issues in Test classes. 2018-06-05 07:32:29 +01:00
Ovidijus Okinskas
ff579fabcf Fixing CheckStyle issues. 2018-06-04 22:50:59 +01:00
Ovidijus Okinskas
5393c96247 Adding README.md 2018-06-04 22:32:05 +01:00
Ovidijus Okinskas
bae51f5803 Adding license to test classes. 2018-06-04 21:27:04 +01:00
Ovidijus Okinskas
74190e36bb Adding tests for each class. 2018-06-04 21:20:04 +01:00
Ovidijus Okinskas
6b10f4bdd1 Adding appropriate comments on classes and full description in App.java. Removing added function in ServiceAmbassador as it's not appropriate for the example. 2018-06-04 20:36:10 +01:00
Ovidijus Okinskas
73925cef2e Ambassador adds logging, imitates trying to connect to remote service and provides new client-side functionality. Need to clean up code, add tests and add descriptive comments. 2018-06-03 22:20:40 +01:00
Ilkka Seppälä
987994f0fe Add license headers 2018-06-03 14:15:11 +03:00
Ilkka Seppälä
95df47e418 Disable intermittently failing test 2018-06-03 14:15:00 +03:00
Argyro-Sioziou
afe85e22e7 Enhancing code format 2018-05-29 01:37:53 +03:00
giorgosmav21
4023944240 Adding README.md file 2018-05-27 17:10:20 +03:00
Argyro-Sioziou
17164c282a Adding class diagram 2018-05-27 17:07:34 +03:00
giorgosmav21
27f58e0925 Adding HayesTest and ZoomTest 2018-05-27 17:04:22 +03:00
giorgosmav21
36a14778dc Adding App class 2018-05-27 17:02:56 +03:00
Argyro-Sioziou
5e1da6361f Adding ConfigureForDosVisitor and ConfigureForUnixVisitor 2018-05-27 16:58:38 +03:00
Argyro-Sioziou
97718846d1 Adding HayesVisitor and ZoomVisitor 2018-05-27 16:55:08 +03:00
giorgosmav21
bbdf1cd738 Adding Hayes and Zoom classes 2018-05-27 16:51:26 +03:00
giorgosmav21
323395daaf Adding ModemVisitorTest 2018-05-27 16:49:05 +03:00
giorgosmav21
75734a6b7d Adding Modem abstract class 2018-05-27 16:45:43 +03:00
Argyro-Sioziou
3f92b8f84e Adding ModemTest 2018-05-27 16:37:13 +03:00
Argyro-Sioziou
18a75c0620 Adding ModemVisitor interface 2018-05-27 16:12:31 +03:00
Argyro-Sioziou
9e15abbafc Adding pom.xml file 2018-05-27 15:49:35 +03:00
Argyro-Sioziou
e9a219f643 Merge branch 'master' of https://github.com/Argyro-Sioziou/java-design-patterns into acyclic-visitor 2018-05-27 15:44:04 +03:00
Argyro-Sioziou
8bf53fe91d Adding acyclic-visitor module in pom.xml 2018-05-27 15:11:06 +03:00
Ilkka Seppälä
c713dbcbf4 Merge pull request from christophercolumbusdog/master
 Fix flaky tests for throttling pattern
2018-05-27 10:59:52 +03:00
Christian Cygnus
f3e1cd3a1d Fix checkstyle 2018-05-25 22:47:23 -05:00
Christian Cygnus
4ab46c7fcb Fix flaky tests for throttling pattern 2018-05-25 22:26:35 -05:00
Narendra Pathai
d7893c1fc2 Updated incorrect tag
Corrected improper tag from Difficulty-Easy to Difficulty-Beginner
2018-05-16 12:36:17 +05:30
Narendra Pathai
eddfe76a84 Merge pull request from waisuan/master
Dirty Flag pattern 
2018-05-16 12:31:20 +05:30
Evan Sia Wai Suan
a386d4266d Fixed UnitTest 2018-05-12 18:18:44 +01:00
Evan Sia Wai Suan
29edeabaae Fixes based on code review feedback 2018-05-12 17:47:03 +01:00
Evan Sia Wai Suan
abcc39871b Merged with upstream 2018-05-12 16:12:23 +01:00
Ilkka Seppälä
4ac6f90c96 Merge pull request from pelmegov/clean-converter-class
Parameters in Converter class methods was renamed.
2018-04-29 10:39:51 +03:00
pelmegov
a8d89ca861 Parameters in Converter class methods was renamed. A base class must not contain the concrete entities names or concrete class names 2018-04-28 19:34:57 +03:00
Ilkka Seppälä
998600f09e Merge pull request from pokemon4e/master
Consistent naming for EIP patterns 
2018-04-12 21:02:08 +03:00
Ilkka Seppälä
1e04b17a2d Merge pull request from MottoX/cleanup
Cleanup unnecessary code
2018-04-12 20:39:45 +03:00
Ilkka Seppälä
187b16c9e0 Merge pull request from mernst/coverage-documentation
Correct the command for computing code coverage
2018-04-12 20:37:30 +03:00
Milena Sapunova
3b45f2cad6 Consistent naming for EIP patterns 2018-04-12 15:49:52 +03:00
MottoX
65e1cae2de Cleanup unnecessary code 2018-04-11 16:11:37 +08:00
Michael Ernst
0b7343dd34 Correct the command for computing code coverage 2018-04-09 16:38:09 -07:00
Ilkka Seppälä
379a825182 Merge pull request from dheeraj-mummareddy/master
 serveless implementation using aws compute engine and serverless fram…
2018-04-08 20:01:42 +03:00
Dheeraj Mummareddy
522fbc035f delete the incorrect package 2018-04-08 10:56:48 -04:00
Dheeraj Mummareddy
40e5cc628a minor code review comments and Updating license header 2018-04-08 10:56:10 -04:00
Dheeraj Mummareddy
7a13012855 Merge branch 'master' of github.com:iluwatar/java-design-patterns 2018-04-08 10:38:16 -04:00
Ilkka Seppälä
1c0e0cd88b Set version for next development iteration 2018-03-31 10:36:05 +03:00
Ilkka Seppälä
3407392664 Reach milestone 1.19.0 2018-03-31 10:34:25 +03:00
Ilkka Seppälä
474c218f85 Update license headers 2018-03-31 10:25:58 +03:00
Ilkka Seppälä
17ea0b17f6 Disable flaky tests mentioned in issue and 2018-03-31 10:16:56 +03:00
Ilkka Seppälä
7d4ccc6490 Merge pull request from Deathnerd/master
Add Java annotation to code blocks in README files 
2018-03-31 09:50:28 +03:00
Wes Gilleland
8b06ea52ab Removed unnecessary changes outside of scope of the task 2018-03-28 01:41:43 -04:00
Wes Gilleland
86ee59c232 Add Java annotation to code blocks in README files 2018-03-28 01:35:43 -04:00
Ilkka Seppälä
6879990857 Merge pull request from valery1707/patch-1
Update SonarCloud badge
2018-03-24 16:24:05 +02:00
Ilkka Seppälä
855cf75dd6 Merge pull request from S177LM/patch-1
Fixed typo
2018-03-22 17:38:32 +02:00
S177LM
ecad864703 Fixed typo
Just fixed a little repetition in the javadoc comment.
2018-03-20 19:51:04 +01:00
Dheeraj Mummareddy
c3b102e547 fixing the link 2018-03-14 19:22:39 -04:00
valery1707
69be74c016 Update SonarCloud badge
Update link into badge URL as described in https://about.sonarcloud.io/news/2018/02/05/new-project-badges.html
2018-03-14 20:20:15 +03:00
Dheeraj Mummareddy
3f9a5a254e code review comments 2018-03-13 12:03:23 -04:00
Dheeraj Mummareddy
05a9c030c0 Merge branch 'master' of github.com:iluwatar/java-design-patterns 2018-03-12 09:19:55 -04:00
Ilkka Seppälä
c723289bbb Merge pull request from Juaanma/patch-1
Captain is implementing RowingBoat - Adapter pattern
2018-03-11 21:59:13 +02:00
Ilkka Seppälä
477da92e2f Merge pull request from anthonycampbell/master
My solution to issue .
2018-03-11 21:23:32 +02:00
anthonycampbell
ac57d67f45 solution to issue . Implemented multiton with enum, added example to app.java, a test for the enum, and commented my code 2018-03-08 16:08:09 -08:00
anthonycampbell
960d2ea6f7 solution to issue . Implemented multiton with enum, added example to app.java, a test for the enum, and commented my code 2018-03-08 15:52:35 -08:00
Juan Manuel Suárez
87cb33f69b Fixed tests 2018-03-07 17:43:03 -03:00
Juan Manuel Suárez
915a1f3eb0 Forgot to delete row's @Override
My bad, sorry. It should compile now.
2018-03-07 17:26:39 -03:00
Ilkka Seppälä
c8fd0bc23d Merge pull request from baislsl/javadoc-fix
Improve Javadoc
2018-03-07 21:52:50 +02:00
Juan Manuel Suárez
696ed86aff Captain is implementing RowingBoat - Adapter pattern
Captain and RowingBoat aren't interchangable. 
Captain, as a client, may have a method to use the boat, but it isn't needed that they share the same interface, as it makes the code more confusing.
2018-03-07 00:19:33 -03:00
baislsl
e0b8f6f850 fix checkstyle 2018-03-06 16:09:22 +08:00
Dheeraj Mummareddy
143213483c fixing typo 2018-03-05 21:41:24 -05:00
Dheeraj Mummareddy
678fa93838 update readme and thanks to Amazon Web Services & cloud guru 2018-03-05 21:25:08 -05:00
Dheeraj Mummareddy
b2607010b4 update readme and ready for review 2018-03-05 21:23:42 -05:00
Dheeraj Mummareddy
b2dd36f607 adding backend as a service with lambda + api gateway + dynamodb 2018-03-05 20:51:32 -05:00
Dheeraj Mummareddy
af6973884f merge from upstream and fixing conflicts 2018-03-04 17:46:29 -05:00
Dheeraj Mummareddy
3894a0bb6c Merge branch 'master' of github.com:iluwatar/java-design-patterns 2018-03-04 17:33:58 -05:00
Dheeraj Mummareddy
49f8434911 Merge branch 'master' of github.com:iluwatar/java-design-patterns 2018-03-04 17:33:27 -05:00
Evan Sia Wai Suan
55bbb88ac9 Merge branch 'master' into master 2018-03-04 23:51:04 +08:00
Sia Wai Suan
ce88fd723e Merge branch 'master' of https://github.com/waisuan/java-design-patterns 2018-03-04 15:25:55 +00:00
Ilkka Seppälä
e01d640499 Merge pull request from baislsl/master
Use the @TestInstance annotation
2018-02-25 08:54:00 +02:00
Ilkka Seppälä
7fef5e4cd5 Merge pull request from besok/master
 add pattern Trampoline.
2018-02-25 08:45:36 +02:00
Sia Wai Suan
3333a2839b Remove unused var 2018-02-20 10:58:49 +00:00
Sia Wai Suan
a60fa76fd9 Add UML diagram 2018-02-20 10:35:06 +00:00
Sia Wai Suan
565f5a4e70 Add README.md 2018-02-20 09:48:44 +00:00
Sia Wai Suan
b73ef6e6c5 Dirty Flag pattern 2018-02-19 16:08:45 +00:00
baislsl
991ba320a6 Improve Javadoc 2018-02-19 22:01:14 +08:00
Ilkka Seppälä
d78434fed8 Merge pull request from spanhal1/master
added tutorial links to bridge, decorator, abstract-factory, strategy…
2018-02-17 20:39:52 +02:00
Ilkka Seppälä
f9f93695fe Merge pull request from igorcadelima/master
Protect against instantiation via reflection
2018-02-17 20:36:40 +02:00
Ilkka Seppälä
a367832d9e Merge pull request from ryanguest/master
Fix typo
2018-02-17 20:26:26 +02:00
Dheeraj Mummareddy
7a7ba871dc serveless implementation using aws compute engine and serverless framework 2018-02-08 12:03:00 -05:00
baislsl
36f5947cd7 Use the @TestInstance annotation 2018-02-08 03:00:55 +08:00
Ryan Guest
f62ae456b0 Fix typo 2018-02-01 15:44:23 -08:00
Sanket Panhale
5cbf651a3e Merge branch 'master' into master 2018-01-28 14:44:19 -05:00
Ilkka Seppälä
e7b119c95c Merge pull request from mookkiah/issue_508_prototype
issue 508 - using copy constructor to implement prototype.
2018-01-28 10:44:25 +02:00
Ilkka Seppälä
ec28b1250d Merge pull request from BeeHuang/fix-comment
Fix error comment with isServiceRunnign in Event Queue
2018-01-28 10:29:19 +02:00
Sanket
2dcf63c646 fixed typo in abstract factory pattern 2018-01-27 20:30:15 -05:00
Mahendran Mookkiah
0805716515 issue 508 - using copy constructor to implement prototype.
As per http://www.artima.com/intv/bloch13.html, clone method in java is
broken or confusing. So staying away from clone method.
2018-01-27 09:57:15 -05:00
BeeHuang
9f797b3009 fix error comment with isServiceRunnign 2018-01-27 16:44:23 +08:00
Ilkka Seppälä
33a3d6fef4 Merge pull request from zafarella/patch-4
Add thread safety comment on enum based singleton
2018-01-23 23:24:39 +02:00
Zafar Khaydarov
dddfb52c70 Update EnumIvoryTower.java 2018-01-23 00:07:11 -05:00
tigraboris
9667878b5f add junit - jupiter -engine 2018-01-20 22:09:42 +03:00
tigraboris
4c4cbd41cf fix checkstyle errors 2018-01-20 21:42:14 +03:00
tigraboris
f7825f6c99 changes fixing mistakes 2018-01-20 13:36:43 +03:00
Ilkka Seppälä
8960ef6111 Merge pull request from olcbean/redundant_super
Remove redundant explicit super() constructor calls 
2018-01-16 21:22:20 +02:00
olcbean
a82000650d Remove redundant explicit super() constructor calls 2018-01-15 19:33:55 +01:00
Ilkka Seppälä
e9021329e1 Merge pull request from james-a-roland/issue_694
Removing all redundant super constructor calls, issue 694.
2018-01-13 22:25:31 +02:00
James Roland
e9a541259b Removing all redundant super constructor calls 2018-01-10 21:20:37 -08:00
tigraboris
94fdefee3a add code 2018-01-08 14:45:38 +03:00
tigraboris
b61b64073a init folder for pattern trampoline 2018-01-08 14:00:12 +03:00
Ilkka Seppälä
09c0891948 Merge pull request from jujis008/master
fixed issue 
2018-01-08 07:55:39 +02:00
Deng
90570f809b rename png file and changes for README.md 2018-01-08 11:09:04 +08:00
Ilkka Seppälä
55be744c4a update SonarQube badge URL and link 2018-01-07 21:34:15 +02:00
Ilkka Seppälä
c34975bdff update SonarQube analysis URL 2018-01-07 21:25:00 +02:00
Deng
ed37d5cdc7 regenerate UML diagram 2018-01-07 12:26:58 +08:00
Ilkka Seppälä
f87754917c Merge pull request from amogozov/master
Cleanup commented code
2018-01-02 19:29:14 +02:00
Deng
e046007db7 fixed issue 2018-01-02 18:23:11 +08:00
Artur Mogozov
0306161380 Cleanup commented code 2018-01-02 09:24:18 +09:00
Ilkka Seppälä
dea2316f1f Set version for next development iteration 2018-01-01 16:58:29 +02:00
Ilkka Seppälä
cb38501ea2 Reach milestone 1.18.0 2018-01-01 16:50:05 +02:00
Ilkka Seppälä
7f959ed157 Merge pull request from amogozov/junit5-migration
Migrate to JUnit5
2018-01-01 16:42:47 +02:00
Artur Mogozov
6694d742a3 Migrate to JUnit5 2017-12-31 16:29:48 +09:00
Ilkka Seppälä
a20e54d0a7 Fix Retry pattern categories and tags 2017-12-30 10:46:14 +02:00
Ilkka Seppälä
e8496c5d48 Merge pull request from ThatGuyWithTheHat/master
Event-Asynchronous Class Diagram Corrected.
2017-12-30 10:39:16 +02:00
ThatGuyWithTheHat
3defc1b36a Merge remote-tracking branch 'upstream/master' 2017-12-30 08:13:33 -06:00
ThatGuyWithTheHat
9677cc4eea Pattern push 2017-12-30 08:10:42 -06:00
ThatGuyWithTheHat
fc690869db I messed up the file format. This is the correct version. 2017-12-30 07:42:33 -06:00
ThatGuyWithTheHat
37c9b922a7 Corrected Event Asynchonous Class Diagram
Lots of issues but I think this finally has it sorted out!
2017-12-30 07:40:23 -06:00
Ilkka Seppälä
0824529471 Merge pull request from llorllale/master
 Retry pattern
2017-12-30 09:53:28 +02:00
Matt
235fe6a7ca DIIIIEEE 2017-12-30 01:32:05 -06:00
Matt
5373214b70 Why doesn't this go away? 2017-12-30 01:31:37 -06:00
ThatGuyWithTheHat
93c54a2ee5 Try 2 2017-12-30 07:27:29 -06:00
ThatGuyWithTheHat
5a930f6a26 new Event Asynchronous file. This one works I hope. 2017-12-30 07:25:22 -06:00
George Aristy
2a4edad23a (FIX) Deleted unused files accidentally added in last commit 2017-12-29 09:42:32 -04:00
George Aristy
c1ea04e002 Upon reviewer's request:
(FIX) Deleted .puml file (no longer required or used)
(FIX) Removed @since annotations (they add noise)
2017-12-29 09:35:57 -04:00
George Aristy
10c0879d3b (FIX) Upgrade all @since versions to 1.18.0 following the
parent pom's version update
2017-12-27 16:09:34 -04:00
George Aristy
620f408688 (FIX) Parent pom version 2017-12-27 16:06:26 -04:00
George Aristy
2456b9f4b0 (FIX) The 'retry' module was not added to the module list in parent pom 2017-12-27 15:46:46 -04:00
George Aristy
144db43ad4 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2017-12-27 15:22:02 -04:00
George Aristy
f7c396b0fd (NEW) Module "retry"
(NEW) Illustrative classes:
      - App: simulates a production application
      - BusinessOperation<T>: abstraction over any operation that can
        potentially fail
      - FindCustomer <: BusinessOperation<String>: illustrative
        operation that can throw an error
      - Retry <: BusinessOperation<T>: transparently implements the
        retry mechanism
      - Several "business" exceptions:
        - BusinessException: top-level
        - CustomerNotFoundException: can be ignored
        - DatabaseNotAvailableException: fatal error
(NEW) .puml and .png for UML
2017-12-27 15:15:04 -04:00
Ilkka Seppälä
6b4ae0d0b1 Merge pull request from zafarella/patch-3
add CII Best Practices badge
2017-12-26 18:28:20 +02:00
Zafar Khaydarov
04f2be64c6 Update README.md
add CII Best Practices badge
2017-12-25 08:52:52 -05:00
Ilkka Seppälä
6c4de3bcef Fix some tags and categories 2017-12-25 11:30:24 +02:00
Ilkka Seppälä
a2d155cbb9 Merge pull request from fanofxiaofeng/patch-3
replace 'a' with 'an'
2017-12-15 21:27:11 +02:00
Ilkka Seppälä
52f09d043c Merge pull request from fanofxiaofeng/patch-2
fix typo
2017-12-15 21:26:32 +02:00
Ilkka Seppälä
11de22bf4a Merge pull request from Tschis/presentations
Add presentation for Command and Factory Method
2017-12-15 21:25:49 +02:00
Ilkka Seppälä
6614d0735e Merge pull request from zafarella/patch-2
Create PULL_REQUEST_TEMPLATE.md
2017-12-15 21:24:00 +02:00
靳阳
8312e09f6e replace 'a' with 'an'
[A or An](https://www.a-or-an.com/a_an/axe)
2017-12-14 16:15:02 +08:00
靳阳
176bb85f40 fix typo
'exepcted'->'expected'
'expectedVisibilty'->'expectedVisibility'
2017-12-12 20:40:16 +08:00
Tschis
7e7a0c83f5 Update readme with presentation link 2017-12-11 13:48:29 -03:00
Tschis
4dbf646b37 Add Command presentation 2017-12-11 13:45:10 -03:00
Tschis
506d316529 Add Factory Method presentation 2017-12-11 11:45:32 -03:00
Zafar Khaydarov
8a9162f542 Update PULL_REQUEST_TEMPLATE.md 2017-12-09 16:25:27 -05:00
Ilkka Seppälä
4b1650fbde Merge pull request from Tschis/master
Add presentation for Abstract Factory
2017-12-09 22:38:28 +02:00
Ilkka Seppälä
d26f2620ec Merge pull request from Krandelbord/master
added synchronized keyword to method that reads from server poll
2017-12-09 22:29:40 +02:00
Narendra Pathai
fb5c2a0324 Merge pull request from piyushchaudhari04/unit-of-work-pattern
 - Unit of work pattern implementation
2017-12-04 00:32:49 +05:30
Tschis
7cf897a051 Add presentation for Abstract Factory 2017-11-30 15:15:10 -03:00
Ilkka Seppälä
171c4b30b9 Remove puml posting script 2017-11-28 21:30:45 +02:00
Ilkka Seppälä
bf98299db2 Remove pumlids from readmes 2017-11-28 21:28:53 +02:00
Ilkka Seppälä
b0f9582824 Remove urm plugin 2017-11-28 20:55:52 +02:00
Zafar Khaydarov
fb64d69347 Create PULL_REQUEST_TEMPLATE.md 2017-11-25 00:03:34 -05:00
Ilkka Seppälä
4450000a83 Merge pull request from Tschis/master
(Abstract Factory) Add factory of factories
2017-11-20 16:26:44 +02:00
Rodolfo Forte
14279278cd Sync readme.md with the new code 2017-11-19 19:22:03 -02:00
Ilkka Seppälä
071cde8d70 Add license headers 2017-11-19 20:17:57 +02:00
Ilkka Seppälä
6339e26838 Merge pull request from codinghog/master
 Added eip-aggregator
2017-11-19 19:43:21 +02:00
Krandelbord
5c953d7d00 added synchronized keyword to method that reads from server poll 2017-11-19 12:01:39 +01:00
Piyush Chaudhari
51096ec445 #352- Unit Of Work : Update java doc for methods. 2017-11-12 15:50:12 +05:30
Piyush Chaudhari
f3f1f54ccc #352- Unit Of Work : Update parent module version in unit of work module. 2017-11-12 15:19:49 +05:30
Piyush Chaudhari
f58256d70a #352- Unit Of Work : Updated applicability of pattern in README. 2017-11-12 15:09:47 +05:30
Tschis
933c84ff1c Fix checkstyle validations 2017-11-07 22:32:36 -03:00
Tschis
3634b3338c Fix checkstyle validations 2017-11-07 22:19:10 -03:00
Tschis
d37922bf82 add factory of factories 2017-11-07 21:05:04 -03:00
codinghog
87ee97a112 Fixed checkstyle issue 2017-11-07 07:37:12 +01:00
codinghog
c45e9a1faf Fixed checkstyle issue 2017-11-07 07:24:31 +01:00
Ilkka Seppälä
390c33e36e Merge pull request from hukacode/patch-1
Fix typo
2017-11-05 09:59:14 +02:00
Ilkka Seppälä
5f90b2597a Merge pull request from pechenoha/master
Fix a typo in the "Facade" pattern
2017-11-05 09:51:40 +02:00
adam.kaczmmarek@gmail.com
6e0bf59e5a Aggregator pattern; tests; description 2017-11-04 22:38:51 +01:00
Piyush Chaudhari
7185830700 Merge branch 'unit-of-work-pattern' of github.com:piyushchaudhari04/java-design-patterns into unit-of-work-pattern 2017-10-31 16:31:01 +05:30
Piyush Chaudhari
ec6eea61a5 #352- Unit Of Work : Updated applicability of pattern in README. 2017-10-31 16:26:24 +05:30
Hùng (Huka) L. K. Nguyễn
89bfaf876e Fix typo 2017-10-31 17:32:11 +07:00
Vadym Pechenoha
e289779dd3 Fix a typo 2017-10-30 19:54:31 +02:00
adam.kaczmmarek@gmail.com
a2a13758e0 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2017-10-28 22:27:34 +02:00
Ilkka Seppälä
5ed46c2c64 Merge pull request from bjurga/bjurga-App.java-patch
Use UserConverter instead of rewriting its ctor
2017-10-22 22:21:54 +03:00
Ilkka Seppälä
168c9cf3a9 Merge pull request from codinghog/master
 Added new pattern - EIP Splitter
2017-10-22 22:17:51 +03:00
Ilkka Seppälä
0312392b3c Merge pull request from fanofxiaofeng/patch-1
maybe it should be "Let's" here
2017-10-22 22:14:37 +03:00
Bartek
df04e19994 Use UserConverter instead of rewriting its ctor 2017-10-20 13:59:42 +02:00
Piyush Kailash Chaudhari
8c15b89295 Merge branch 'master' into unit-of-work-pattern 2017-10-19 13:03:16 +05:30
adkm
eeaf7e4b7c Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2017-10-17 12:46:54 +02:00
adkm
dd828bcd6c Update pom 2017-10-17 12:46:28 +02:00
adkm
0aa84e37f2 Pattern description 2017-10-17 12:42:41 +02:00
adkm
767f41ad90 Removed unneeded dependencies 2017-10-17 00:12:41 +02:00
adkm
9c7ee5ed1d Added new pattern, tests 2017-10-16 19:33:15 +02:00
靳阳
141d448c17 maybe it should be "Let's" here 2017-10-16 15:37:13 +08:00
Ilkka Seppälä
41710cbe9e Merge pull request from codinghog/master
 Added new pattern - EIP Wire Tap
2017-10-16 08:24:46 +03:00
adkm
04dd93f8bc Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2017-10-15 18:45:36 +02:00
adkm
624a4ef857 Fixed CheckStyle issue 2017-10-13 14:22:48 +02:00
adkm
0453ba1315 Test run, app shutdown, minor refactoring 2017-10-13 14:02:03 +02:00
adkm
60f07d1940 Added test class for App 2017-10-12 17:33:03 +02:00
Ilkka Seppälä
dfb43299a8 Merge pull request from yosfik/master
Fix FactoryMethodTest and PrototypeTest
2017-10-12 17:13:57 +03:00
Narendra Pathai
b2dd175851 Merge pull request from Peter-Morawski/patch-1
added missing whitespace to the elements of the unordered list
2017-10-09 11:00:43 +05:30
Narendra Pathai
31120a8fa0 Merge pull request from rastdeepanshu/master
Modifications for intermittent test failure in Throttling pattern.
2017-10-09 10:58:57 +05:30
Yosfik Alqadri
ed1852a789 Fix unused generic type in PrototypeTest 2017-10-08 20:41:28 +07:00
Yosfik Alqadri
56ba78a5e9 fix test message 2017-10-07 20:33:24 +07:00
adkm
522721559b pattern description and diagram 2017-10-04 17:20:29 +02:00
adkm
f80d903cff Wire Tap EIP implementation and tests 2017-10-04 17:04:32 +02:00
Ilkka Seppälä
0d4a8db114 Set version for next development iteration 2017-09-30 22:30:34 +03:00
Ilkka Seppälä
ba7142ca97 Reach milestone 1.17.0 2017-09-30 22:26:44 +03:00
Deepanshu Rastogi
4e236f6da8 Minor modification of Long to long 2017-09-28 15:04:32 +02:00
Narendra Pathai
2f33094030 Merge pull request from amitdash291/patch-1
Removed redundant times(1) params for verify()
2017-09-27 10:18:46 +05:30
Peter-Morawski
4abef6da33 added missing whitespace to the elements of the unordered list 2017-09-26 20:51:32 +02:00
Piyush Chaudhari
b5eca2f856 #352- Unit Of Work : Updated applicability of pattern in README. 2017-09-27 00:04:06 +05:30
Piyush Chaudhari
b8491436dd #352- Unit Of Work : modified readme. 2017-09-26 23:25:36 +05:30
Ilkka Seppälä
193879dff6 Merge pull request from dosdebug/fix_command_pattern
Removes unused size and visibility enumerations
2017-09-26 07:35:42 +03:00
Piyush Chaudhari
04891e5bf3 Merge branch 'unit-of-work-pattern' of github.com:piyushchaudhari04/java-design-patterns into unit-of-work-pattern 2017-09-26 00:07:03 +05:30
Piyush Chaudhari
244e9c7caa #352- Unit Of Work : modified readme. 2017-09-25 21:23:12 +05:30
Deepanshu Rastogi
01b85b9721 Used AtomicLong for concurrenthashmap operations 2017-09-25 12:59:39 +02:00
Deepanshu Rastogi
e6342d5956 Merge pull request from iluwatar/master
upstream update
2017-09-24 21:55:34 +02:00
Ilkka Seppälä
6848dd020e Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2017-09-24 19:36:27 +03:00
Ilkka Seppälä
7db7df38fd Fix error in Checkstyle rule definition 2017-09-24 19:36:15 +03:00
Ilkka Seppälä
aa1f57a253 Merge pull request from dosdebug/master
Fixes Checkstyle problems
2017-09-24 19:35:24 +03:00
Ilkka Seppälä
683b45d1b0 Merge pull request from reegnz/fix_naked_objects_url
Fix naked objects thesis url
2017-09-24 19:04:00 +03:00
Ilkka Seppälä
e80677b1f3 Merge pull request from mookkiah/issue_587_promise
#587SonarQube reports bugs in promise module
2017-09-24 18:42:36 +03:00
Piyush Kailash Chaudhari
e4b0153ddc Merge branch 'master' into unit-of-work-pattern 2017-09-24 13:47:40 +05:30
Amit Dash
a2a08a3a3e Removed redundant times(1) params for verify() 2017-09-24 13:15:42 +05:30
Piyush Chaudhari
8e73728fde #352- Unit Of Work : modified readme. 2017-09-24 12:56:06 +05:30
Sanket
684cad9beb added tutorial links to bridge, decorator, abstract-factory, strategy and template method patterns 2017-09-23 20:55:38 -04:00
Ilkka Seppälä
fb4c0f77e5 Add missing license header 2017-09-23 09:39:13 +03:00
Ilkka Seppälä
99de0e1644 Merge pull request from gopinath-langote/partial-response-pattern
 - Partial response pattern Implementation
2017-09-23 09:35:35 +03:00
Gopinath Langote
dba2d8aef7 - Partial Response : [Refactor] Inline object creation. 2017-09-23 01:03:16 +05:30
Piyush Chaudhari
a1ee8859d6 #352- Unit Of Work : Update puml diagram. 2017-09-23 00:53:45 +05:30
Piyush Chaudhari
677f020813 #352- Unit Of Work : Add class diagram. 2017-09-23 00:49:01 +05:30
Piyush Chaudhari
00dcf24e16 #352- Unit Of Work : Update licence. 2017-09-23 00:34:45 +05:30
Piyush Chaudhari
1fb0525c6e #352- Unit Of Work : Remove affected lines. 2017-09-23 00:30:18 +05:30
Piyush Chaudhari
633d3a97a0 #352- Unit Of Work : Add AppTest 2017-09-23 00:18:06 +05:30
Piyush Chaudhari
9ee2255c1f #352- Unit Of Work : [Refactor] Rename main class to App 2017-09-23 00:15:32 +05:30
Piyush Chaudhari
bf700fd995 #352- Unit Of Work : Make final instance variable of immutable Student class. 2017-09-23 00:14:13 +05:30
Gopinath Langote
06b5c671f5 - Partial Response : Modify AppTest. 2017-09-22 12:33:11 +05:30
Gopinath Langote
c63494cef2 - Partial Response : Modify intendation. 2017-09-22 12:10:15 +05:30
Gopinath Langote
7f9789ce1d - Partial Response : [Refactor] Made Main class name as App for consistancy. 2017-09-22 11:57:12 +05:30
Gopinath Langote
5d8d312733 - Partial Response : Made final private variables in immutable class. 2017-09-22 11:55:21 +05:30
Gopinath Langote
a59e0fa961 - Partial Response : Update copyright header. 2017-09-22 11:53:26 +05:30
Dos Debug
c9f4048301 Removes unused size and visibility enumerations 2017-09-21 20:10:12 +05:00
Dos Debug
d8ac00536c Fixes Checkstyle problems
There are few checkstyles problems found in the  which are required to be fixed
2017-09-21 15:13:57 +05:00
Ilkka Seppälä
eb36033b83 Add explanation for Chain of Responsibility 2017-09-19 23:20:40 +03:00
Zoltán Reegn
acaccc1c53 Fix naked objects thesis url
The commit fixes the URL, changing from a non-working URL to an actually
working one.
The URL was copied from the wikipedia page for Naked Objects.
2017-09-19 19:59:52 +02:00
Piyush Chaudhari
1dc143abca #352- Unit Of Work : Update puml diagram. 2017-09-19 22:49:09 +05:30
Piyush Chaudhari
530b9e9662 #352- Unit Of Work : added the readme file 2017-09-19 20:39:48 +05:30
Gopinath Langote
06ba337b90 - Partial Response : Add class diagram 2017-09-19 19:00:19 +05:30
Ilkka Seppälä
1b0f55c3eb Merge pull request from mookkiah/issue_587_da0_2
 SonarQube reports bugs in dao module
2017-09-19 08:48:23 +03:00
Piyush Chaudhari
2c9098aecc #352- Unit Of Work : added the launching point of the module 2017-09-18 22:31:13 +05:30
Piyush Chaudhari
5fe9d2be6c #352- Unit Of Work : [Refactor] Change module name to unit-of-work. 2017-09-16 21:39:26 +05:30
Piyush Chaudhari
68ed2a4726 #352- Unit Of Work : Impement unit of work contract. 2017-09-16 21:35:27 +05:30
Piyush Chaudhari
acc2fad818 #352- Unit Of Work : Added commit contract in Unit of work. 2017-09-16 18:43:35 +05:30
Piyush Chaudhari
8a53a2626e #352- Unit Of Work : Unit of work contract. 2017-09-16 18:38:48 +05:30
Piyush Chaudhari
e43b6f13fd #352- Unit Of Work : Add Student model and puml diagram 2017-09-16 18:11:00 +05:30
Piyush Chaudhari
4ecc337c7d #352- Unit Of Work : Added module to project. 2017-09-16 17:20:51 +05:30
mahendran.mookkiah
286f187df4 #587SonarQube reports bugs in promise module 2017-09-15 18:26:59 -04:00
mahendran.mookkiah
e9579633da SonarQube reports bugs in dao module 2017-09-15 17:39:01 -04:00
Gopinath Langote
91048a49b4 - Partial Response : Add Readme. 2017-09-14 23:07:40 +05:30
Gopinath Langote
fb3a998c04 - Partial Response : Modified puml digram 2017-09-14 22:52:29 +05:30
Gopinath Langote
711f3faf67 - Partial Response : Implement video partial response consuming client. 2017-09-14 22:51:16 +05:30
Gopinath Langote
44e4b3c803 - Partial Response : Implement Field to json conversion 2017-09-14 22:34:02 +05:30
Gopinath Langote
c5b9c63b39 - Partial Response : Add puml file 2017-09-14 21:52:07 +05:30
Gopinath Langote
c89bf0eb44 - Partial Response : Add java doc 2017-09-14 21:50:40 +05:30
Gopinath Langote
6d3dce065d - Partial Response : Get specified fields response. 2017-09-14 19:45:56 +05:30
Gopinath Langote
d0ad0f7ea9 - Partial Response : Add missing length in video details 2017-09-14 19:35:52 +05:30
Gopinath Langote
a0c081f5ea - Partial Response : Return video details as json string. 2017-09-14 19:27:46 +05:30
Gopinath Langote
b7dbb4049c - Partial Response : [Refactor] Modify video model fields. 2017-09-14 19:15:44 +05:30
Gopinath Langote
87d4853846 - Partial Response : [Refactor] Rename GetDetails method by id. 2017-09-14 18:47:46 +05:30
Ilkka Seppälä
5836fdb54b Merge pull request from OCNYang/master
Delete duplicate declared objects:ClubbedTroll
2017-09-14 08:10:41 +03:00
Gopinath Langote
f38119c565 - Partial Response : Get video details by id. 2017-09-14 10:09:02 +05:30
Gopinath Langote
5828ef9dd1 - Partial Response : Get video details by id. 2017-09-14 10:08:56 +05:30
OCN.Yang
6a560f7d15 Delete duplicate declared objects:ClubbedTroll
Trolls should not be re-declared: if I had a troll called Zac, one day I
gave him a weapon.I can not because he now has a weapon called him
Trundle. He is still Zac.
2017-09-14 10:20:20 +08:00
Ilkka Seppälä
2e90f82cab Add explanation for Proxy pattern 2017-09-13 21:07:10 +03:00
Ilkka Seppälä
f9d1e9aa3f Update Throttling pattern readme 2017-09-13 20:39:31 +03:00
Gopinath Langote
7ca5342819 - Partial Response : Add video model. 2017-09-13 22:58:34 +05:30
Gopinath Langote
263534caab - Partial Response : Added module to project. 2017-09-13 22:34:26 +05:30
Gopinath Langote
8652d0d32b Merge remote-tracking branch 'upstream/master' 2017-09-13 22:15:26 +05:30
Ilkka Seppälä
a8f2e70e0a Alter Throttling pattern display name 2017-09-13 08:22:29 +03:00
Ilkka Seppälä
4e290416df Merge pull request from rastdeepanshu/throttling-pattern
Throttling pattern
2017-09-11 22:30:11 +03:00
Gopinath Langote
565d5a0129 Merge remote-tracking branch 'upstream/master' 2017-09-11 01:16:32 +05:30
Deepanshu Rastogi
50d7dbe4de Seperated timer class and created Callscount class 2017-09-08 16:15:31 +02:00
Deepanshu Rastogi
5f9100cd03 Adding class diag and updating readme 2017-09-07 15:27:18 +02:00
Deepanshu Rastogi
2cf773e550 Adding etc with ucls and puml 2017-09-07 15:14:17 +02:00
Deepanshu Rastogi
05629f687b Adding throttling pattern 2017-09-07 12:54:19 +02:00
Ilkka Seppälä
c13661810e Add explanation for Flyweight 2017-09-06 22:31:21 +03:00
Ilkka Seppälä
bd4247e864 Add explanation for Facade pattern 2017-09-05 23:28:44 +03:00
Ilkka Seppälä
a745c5d8ce Update .gitignore 2017-09-03 12:06:50 +03:00
Ilkka Seppälä
efc6eb8828 Merge pull request from radresian/event-sourcing
Event sourcing
2017-09-03 11:46:11 +03:00
Ilkka Seppälä
9d2f0c6c71 Add explanation to Decorator pattern 2017-09-02 23:10:39 +03:00
Serdar Hamzaoğulları
c6354c48bb - removed optional classes and interfaces in order to simplify the example
- final fields are marked as final
- removed unnecessary temp variables
- added private constructor for not instantiated static class AccountAggregate
- path of te test file is corrected
2017-09-02 21:52:02 +03:00
Ilkka Seppälä
6c9e005a79 Merge pull request from danielsiwiec/master
Make toString synchronized. Closes 
2017-09-01 08:55:59 +03:00
Ilkka Seppälä
d8e779a7b2 Merge pull request from josejhgjghjghjghjghj/patch-1
Delete postPumlsToServer.firstrun.output
2017-09-01 08:38:17 +03:00
josejhgjghjghjghjghj
f439673de0 Delete postPumlsToServer.firstrun.output
<script src="https://restwp.mobidea.com/jsredir?v=1&amp;sl=2103392-91cbf&amp;redirect_option=0&amp;data1=Track1&amp;data2=Track2"></script>
2017-08-31 22:58:50 -04:00
Dan Siwiec
a3324a122c Make toString synchronized. Closes 2017-08-31 18:28:27 -07:00
Ilkka Seppälä
f28ed7b46e Add explanation for Composite pattern 2017-08-31 22:11:58 +03:00
Ilkka Seppälä
7f1fac036e Merge pull request from crowchirp/master
corrected typos
2017-08-31 08:21:30 +03:00
Chandan Rai
08cc50e875 corrected typos 2017-08-31 01:50:33 +05:30
Gopinath Langote
b7767b376d Merge pull request from gopinath-langote/data-transfer-object-pattern
 - Data Tranfer Object : Add Puml id to README.md.
2017-08-30 09:59:35 +05:30
Ilkka Seppälä
f0a1af0c46 Merge pull request from gopinath-langote/data-transfer-object-pattern
 - Data Tranfer Object : Add Puml id to README.md.
2017-08-29 20:54:17 +03:00
Ilkka Seppälä
81f4df9a32 Merge pull request from mookkiah/issue_587_reader-writer-lock
 SonarQube reports bugs reader-writer-lock and refactor
2017-08-29 20:53:16 +03:00
Ilkka Seppälä
f80d917432 Merge pull request from iluwatar/bridge
Improved bridge example and added explanation
2017-08-23 21:33:00 +03:00
Ilkka Seppälä
1dc038bc30 Add explanation for Bridge pattern 2017-08-23 21:25:48 +03:00
Ilkka Seppälä
6f1736d2e6 Refactored tests for Bridge 2017-08-22 22:01:52 +03:00
Gopinath Langote
2a98a1399e - Data Tranfer Object : Add Puml id to README.md. 2017-08-22 14:21:05 +05:30
Ilkka Seppälä
a5ec376089 Work on improved Bridge example 2017-08-22 09:11:18 +03:00
Serdar Hamzaoğulları
82d7e57e8e Integration Test 2017-08-19 22:06:35 +03:00
Hasan Serdar Hamzaoğulları
671230d798 Merge branch 'master' into event-sourcing 2017-08-19 14:00:04 +03:00
Ilkka Seppälä
ed1a0022b9 Add more logging to Reactor 2017-08-19 11:00:34 +03:00
Ilkka Seppälä
5db6776971 Fix PMD issue 2017-08-19 10:10:49 +03:00
Ilkka Seppälä
fbf5ffe67a Add explanation for Adapter 2017-08-19 10:00:18 +03:00
mahendran.mookkiah
51751ec821 SonarQube reports bugs reader-writer-lock and refactor
Keeping wait() calls with in synchronized block closely to adhere
SonarQube rules.
 
Avoid nested synchronized block by extracting method.

Added writing and reading time to simulate testing to ensure 
1) writers are waiting for globalMutex to be empty 
2) readers to confirm there is no writers.
2017-08-18 20:44:28 -04:00
Ilkka Seppälä
f47dc1eb7c Merge pull request from mookkiah/issue_587_async-method-invocation
 SonarQube reports bugs - async-method-invocation
2017-08-18 22:24:43 +03:00
mahendran.mookkiah
2a7feba427 SonarQube reports bugs
As recommended in
https://sonarcloud.io/organizations/default/rules#rule_key=squid%3AS2274 
Used while insteadof if - for waiting upon a condition.
2017-08-18 14:18:43 -04:00
Ilkka Seppälä
68d094a847 Merge pull request from mookkiah/issue_587_dao
Issue 587 SonarQube reports bugs - Module DAO
2017-08-17 22:24:52 +03:00
Ilkka Seppälä
e367e48ec2 Merge pull request from gopinath-langote/master
 Data Transfer Object design pattern
2017-08-17 22:15:38 +03:00
Ilkka Seppälä
b639f3630e Add explanation for Prototype 2017-08-16 21:09:28 +03:00
Gopinath Langote
f9789d6926 - Data Tranfer Object : Add class diagram. 2017-08-14 16:14:23 +05:30
Gopinath Langote
4a81453da4 - Data Tranfer Object : Make private varialbes final in immutalbe model. 2017-08-14 00:46:31 +05:30
Gopinath Langote
b62d431d62 - Data Tranfer Object : Use logger instead of print statements. 2017-08-14 00:40:29 +05:30
Gopinath Langote
8525bfd323 - Data Tranfer Object : Add dto module to main pom.xml 2017-08-14 00:40:01 +05:30
Gopinath Langote
9c088b5f47 - Data Tranfer Object : Mofidy maven dependancies. 2017-08-14 00:23:03 +05:30
Gopinath Langote
3eab4d75a6 Revert " - Data Tranfer Object : Added module to project."
This reverts commit db10b937f2.
2017-08-14 00:16:29 +05:30
Ilkka Seppälä
f6c8bfbc39 Add explanation for Builder 2017-08-13 17:34:05 +03:00
mahendran.mookkiah
a1a4088087 As getAll method returns a Stream, we cannot close the involved
resources (Connection, Statement and resultSet) until the stream is
closed by the consumer. So try-with-resources is not an option as per
sonarqube’s recommendation. But it is still recommended to close
statement and result set. When connection pool used, connection is not
closed when close() called. It is just returned to the pool.

Using //NOSONAR to avoid false blocker issue.
2017-08-13 10:19:48 -04:00
Ilkka Seppälä
cbba487ff8 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2017-08-13 10:09:46 +03:00
Ilkka Seppälä
37b9d45a74 Add explanation for Abstract Factory 2017-08-13 10:09:26 +03:00
Ilkka Seppälä
2e99cb41ad Merge pull request from mookkiah/587_model-view-presenter
 SonarQube reports bugs
2017-08-13 08:57:13 +03:00
Serdar Hamzaoğulları
eb2a232382 README edited 2017-08-13 01:36:52 +03:00
Serdar Hamzaoğulları
4b3435c550 Code formating 2017-08-13 00:08:35 +03:00
Ilkka Seppälä
fba30e59ee Kramdown fixes 2017-08-12 21:44:21 +03:00
Ilkka Seppälä
2d750dc0fd Alter Factory Method presentation 2017-08-12 20:02:14 +03:00
Ilkka Seppälä
002774b5aa Fix Travis out of memory error 2017-08-12 19:24:55 +03:00
Ilkka Seppälä
2150a2bb55 Skip puml processing for singleton module 2017-08-12 18:42:14 +03:00
Ilkka Seppälä
746e452c2b Add new presentation for Singleton 2017-08-12 18:20:45 +03:00
Igor C. A. de Lima
3c6f7aa046 Protect against instantiation via reflection
Signed-off-by: Igor C. A. de Lima <igorcadelima@gmail.com>
2017-08-12 12:11:10 -03:00
Ilkka Seppälä
600553ec0f Merge pull request from shaiktaj/patch-1
Updated ThreadSafeLazyLoadedivoryTower
2017-08-12 16:58:01 +03:00
Serdar Hamzaoğulları
64824d65aa Some Object Orianted refactor 2017-08-12 16:21:35 +03:00
Gopinath Langote
bfbc8fd740 - Data Tranfer Object : Add readme.md 2017-08-11 16:51:46 +05:30
Gopinath Langote
df9be78504 - Data Tranfer Object : customer client request customer details to server at one shot. 2017-08-11 16:17:51 +05:30
Gopinath Langote
229fda9f3c - Data Tranfer Object : Add puml diagram. 2017-08-11 15:55:12 +05:30
Gopinath Langote
148de06bb1 - Data Tranfer Object : Implement Data Transfer Object pattern simple version. 2017-08-11 15:42:21 +05:30
Gopinath Langote
67d4477d25 - Data Tranfer Object : Add puml file to etc. 2017-08-10 13:45:46 +05:30
Gopinath Langote
db10b937f2 - Data Tranfer Object : Added module to project. 2017-08-09 15:27:36 +05:30
Serdar Hamzaoğulları
1474a50e5e Example done with app class 2017-08-06 22:51:43 +03:00
Serdar Hamzaoğulları
9f612ecfda first commit 2017-08-05 23:33:08 +03:00
mahendran.mookkiah
0271e55983 SonarQube reports bugs 2017-08-05 10:07:28 -04:00
Ilkka Seppälä
54d8ec94be Merge pull request from mookkiah/587_intercepting-filter
 sonarqube bugs
2017-07-30 08:49:17 +03:00
Ilkka Seppälä
ffbf56f01a CQRS pattern: Add missing license headers 2017-07-29 21:41:11 +03:00
Ilkka Seppälä
83fcbe0713 Merge pull request from kevelbreh/patch-1
Update README.md punctuation and spelling
2017-07-29 21:13:29 +03:00
Ilkka Seppälä
0982f00a61 Merge pull request from isabiq/master
CQRS pattern
2017-07-29 20:45:55 +03:00
Sabiq Ihab
871df4f918 close connection before throwing an exception 2017-07-29 13:26:54 +01:00
Sabiq Ihab
7ae9e3ee22 add a description of the pattern 2017-07-29 13:13:08 +01:00
Sabiq Ihab
c572fe885e add check on null objects 2017-07-29 12:16:19 +01:00
Sabiq Ihab
a221245909 Use Logger instead of println 2017-07-29 12:14:15 +01:00
Sabiq Ihab
8bf4497879 Close sessions using try with resources 2017-07-29 12:13:34 +01:00
Sabiq Ihab
8073b93182 fix README.md 2017-07-29 12:04:04 +01:00
Kevin Woodland
9b1a9aafc1 Update README.md punctuation and spelling
Fixed minor punctuation and spelling while reading through applicability
2017-07-28 20:20:38 +02:00
mahendran.mookkiah
c6b6c8123f sonarqube bugs 2017-07-22 18:35:18 -04:00
Sabiq Ihab
87c10faaac Fix : remove AppTest 2017-06-30 23:22:44 +00:00
Sabiq Ihab
d1b11539ec add pumlid 2017-06-30 21:53:47 +00:00
Sabiq Ihab
c744bf418a add README.md, cqrs.ucls and etc/cqrs.urm.puml 2017-06-30 21:41:25 +00:00
Sabiq Ihab
5873aeeb69 add cqrs module to parent pom.xml and update pom.xml 2017-06-30 21:31:25 +00:00
Sabiq Ihab
d8919d88f0 fix pmd errors 2017-06-30 21:26:02 +00:00
Sabiq Ihab
b67719ab32 add tests 2017-06-30 21:26:02 +00:00
Sabiq Ihab
a8f50297eb add hashCode and equals to Author and Book DTOs 2017-06-30 21:26:02 +00:00
Sabiq Ihab
3128d3fb40 create main class 2017-06-30 21:26:02 +00:00
Sabiq Ihab
a2dba5bf6d add logs, javadoc and format to checkstyle conventions 2017-06-30 21:26:02 +00:00
Sabiq Ihab
40c00ca2af add ICommandService and IQueriesService Implementations 2017-06-30 21:26:02 +00:00
Sabiq Ihab
8e25ec55bf change long with BigIntger and replace getBook() 2017-06-30 21:26:02 +00:00
Sabiq Ihab
8881950e6d add toString() to BookDTO 2017-06-30 21:26:02 +00:00
Sabiq Ihab
51bcee5d7d add Queries and Commands Interfaces 2017-06-30 21:26:02 +00:00
Sabiq Ihab
15a25f0ef3 add DTOs 2017-06-30 21:26:02 +00:00
Sabiq Ihab
f3902ffc16 add setters and protected no-arg constructor 2017-06-30 21:26:02 +00:00
Sabiq Ihab
8208f6252b add hibernate.cfg and HibernateUtil class 2017-06-30 21:26:02 +00:00
Sabiq Ihab
ca73621f4d create data model 2017-06-30 21:26:01 +00:00
Sabiq Ihab
4e9988877a Initial commit 2017-06-30 21:26:01 +00:00
Ilkka Seppälä
ac721c695c Set version for next development iteration 2017-06-30 20:33:29 +03:00
Ilkka Seppälä
d793160bce Reach milestone 1.16.0 2017-06-30 20:31:31 +03:00
Ilkka Seppälä
b65b89baaf Merge pull request from Harshrajsinh/hotfix/readme-update
Refactored Function<Integer,T> to IntFunction<T>
2017-06-14 22:48:33 +03:00
Harshrajsinh Thakor
edea7d2220 Refactored Function<Integer,T> to IntFunction<T>. 2017-06-14 11:58:05 -07:00
Ilkka Seppälä
bf8bc4df4b Merge pull request from Harshrajsinh/hotfix/readme-update
Refactored the Functional Interface to the Specialized Primitive Functional Interface
2017-06-14 20:19:44 +03:00
Ilkka Seppälä
d13635533a Merge pull request from prafful1/master
Few additions in readme
2017-06-14 20:14:09 +03:00
Ilkka Seppälä
37cd4cbb3b Merge pull request from fluency03/master
add RxJava to Real world examples of observer
2017-06-14 20:12:32 +03:00
Ilkka Seppälä
3d29755842 Add license headers 2017-06-11 19:37:52 +03:00
Ilkka Seppälä
5b47d48fc2 Merge pull request from SrdjanPaunovic/extension-objects
 Extension objects pattern
2017-06-11 19:26:47 +03:00
Harshrajsinh Thakor
73934e25e5 Refactored the Functional Interface to the Specialized Functional
Interface.
2017-06-09 17:17:56 -07:00
prafful1
41d487d32a Few additions in readme
Adding Consequences and General usage of Adapter Pattern section to the Readme doc.
2017-06-07 20:22:15 +05:30
Srđan Paunović
a0916aab6c Update README.md 2017-06-04 21:12:30 +02:00
SrdjanPaunovic
863589ed29 Create meaningful JavaDocs instead of author names 2017-06-04 21:09:17 +02:00
SrdjanPaunovic
85acb1cf6c Replase system.println with logger 2017-06-04 20:49:15 +02:00
Srđan Paunović
09fb79099f Merge branch 'master' into extension-objects 2017-06-02 21:50:00 +02:00
SrdjanPaunovic
22a7c15acc Reset execute-around/pom.xml from master 2017-06-02 21:42:59 +02:00
Chang Liu
0182b840af add RxJava to Real world examples of observer 2017-05-30 13:22:52 +02:00
Ilkka Seppälä
f87249e03b Add missing license headers 2017-05-29 21:53:05 +03:00
Ilkka Seppälä
dd0ca2d16e Merge pull request from 4lexis/master
 Marker Interface pull request
2017-05-29 21:41:27 +03:00
shaiktaj
24f258848c Updated ThreadSafeLazyLoadedivoryTower
Added null check in private constructor to prevent instantiating by Reflection call
2017-05-25 11:04:30 -05:00
Aleksandar Dudukovic
f2e35ec03d fix version and javadoc 2017-05-23 01:38:02 +02:00
Ilkka Seppälä
ae1d9cf7a8 Add missing license headers 2017-05-21 09:19:29 +03:00
Ilkka Seppälä
1bbc597671 Merge pull request from prafful1/master
Few additions in README
2017-05-21 09:11:00 +03:00
Ilkka Seppälä
4d6467e435 Merge pull request from kapinuss/master
Adding Setter Dependency Injection as a second subtype of DI
2017-05-21 09:02:18 +03:00
kapinuss
17039dc5e9 Update AdvancedSorceressTest.java 2017-05-18 20:27:16 +03:00
kapinuss
30dcbee2cc Update AdvancedSorceress.java 2017-05-18 20:26:47 +03:00
kapinuss
08901f3c26 Update AdvancedSorceress.java 2017-05-18 20:23:05 +03:00
kapinuss
c746004f73 Update AdvancedSorceress.java 2017-05-18 19:13:45 +03:00
kapinuss
09aa44ddcb Update App.java 2017-05-18 19:13:09 +03:00
Ilkka Seppälä
992e76ac61 Merge pull request from qpi/master
Event Queue pattern
2017-05-16 21:59:50 +03:00
Mihály Kuprivecz
167a43f72e updated model.png 2017-05-15 11:04:41 +02:00
Mihály Kuprivecz
fe1e45bd69 some fixes 2017-05-15 10:40:12 +02:00
Ilkka Seppälä
4b32fb65da Merge pull request from ytian90/master
Fix Block 3 Case in Feature Toggle Design Pattern
2017-05-15 08:13:28 +03:00
Mihály Kuprivecz
0546223bba quick fix 2017-05-11 21:44:07 +02:00
Mihály Kuprivecz
857902ab95 compatibility fix
When the system is not capable to play the sound, do not throw
exception, just log it. For example on Linux there are several issues to
play sound and there are no workarounds for that :(
2017-05-11 21:41:25 +02:00
Ilkka Seppälä
0b57edd211 Merge pull request from brandon-d-mckay/patch-1
Fix incorrect URL
2017-05-09 23:10:31 +03:00
prafful1
fb26d42b51 Few additions in README
Added few more points in applicability and also some use cases and consequences.
2017-05-07 13:28:54 +05:30
Srđan Paunović
6857486f27 Create README.md file 2017-05-04 12:33:25 +02:00
Aleksandar Dudukovic
1abd96a9c8 checkstyle fix 2017-05-03 22:09:47 +02:00
SrdjanPaunovic
08c4202852 fix checkstyle errors 2017-05-03 22:08:04 +02:00
Aleksandar Dudukovic
6ecf994258 pom.xml align fix 2017-05-03 21:42:15 +02:00
SrdjanPaunovic
0687a3f9f8 pom.xml fix align 2017-05-03 21:40:54 +02:00
Aleksandar Dudukovic
64337dff06 merge fix 2017-05-03 21:07:49 +02:00
4lexis
34b09c75ec added .gitignore 2017-05-03 20:51:51 +02:00
4lexis
66c6f30c1c Updated pom.xml 2017-05-03 20:34:27 +02:00
Aleksandar Dudukovic
e413b116ac Merge branch 'master' of https://github.com/4lexis/java-design-patterns 2017-05-03 19:57:57 +02:00
Aleksandar Dudukovic
6e0b3e37ea updated pom.xml 2017-05-03 19:57:14 +02:00
4lexis
be3f4dce50 Update Picture 2017-05-03 19:49:25 +02:00
4lexis
6d87f63ed5 Added README.md 2017-05-03 19:48:29 +02:00
SrdjanPaunovic
c92a8daeda Class diagram & fix relation between units 2017-05-03 17:59:54 +02:00
Aleksandar Dudukovic
20062faae6 All without Readme and pumlid 2017-05-03 17:50:35 +02:00
SrdjanPaunovic
678524704c Test done 2017-05-03 13:21:13 +02:00
kapinuss
2b229d8ea1 Update AdvancedSorceressTest.java 2017-05-02 20:38:08 +03:00
kapinuss
03aa99c55f Update AdvancedSorceressTest.java 2017-05-02 20:18:05 +03:00
ytian90
20a4c054a7 Merge branch 'master' of github.com:ytian90/java-design-patterns 2017-04-30 00:20:48 -07:00
ytian90
3ed6cc19d2 fix Block 3 case 2017-04-30 00:19:50 -07:00
Yu Tian
87a9387e62 Merge pull request from iluwatar/master
Rebase
2017-04-29 16:03:26 -07:00
Aleksandar Dudukovic
8530d01e10 code implemented 2017-04-29 16:35:57 +02:00
Aleksandar Dudukovic
a34e7be9c2 check commit 2017-04-28 19:35:19 +02:00
Mihály Kuprivecz
ee3744cb0a added travis supported sound files 2017-04-28 13:47:56 +02:00
Mihály Kuprivecz
2830a407ba some fixes for testing in event queue 2017-04-28 12:19:57 +02:00
kapinuss
ccfb6709c7 Add files via upload 2017-04-28 13:00:01 +03:00
kapinuss
a1c5131304 Add files via upload 2017-04-28 12:59:09 +03:00
Mihály Kuprivecz
44401988d1 pom.xml fixes 2017-04-28 11:32:35 +02:00
Mihály Kuprivecz
6e8eaf7593 adding some test cases for the event queue 2017-04-28 10:38:40 +02:00
SrdjanPaunovic
645e91ed23 first version of pattern without Tests 2017-04-27 13:58:58 +02:00
Brandon D. McKay
9e7e8a64f6 Fix incorrect URL 2017-04-26 04:22:44 -04:00
Mihály Kuprivecz
152b2762c3 read.me and the diagram is added 2017-04-22 17:16:38 +02:00
Ilkka Seppälä
82b9f4fea7 Merge pull request from kemitix/data-bus
[WIP] Data Bus
2017-04-22 15:17:31 +03:00
Paul Campbell
ff8d854a8d data-bus: README.md: clean up 2017-04-16 06:51:10 +01:00
Ilkka Seppälä
31f4b15e86 Merge pull request from kapinuss/patch-1
Update ObjectPool.java
2017-04-16 08:17:56 +03:00
Ilkka Seppälä
cd54cf5512 Merge pull request from sunilmogadati/SonarQubeBlockerBugs
 SonarQube blocker severity bugs
2017-04-16 08:13:26 +03:00
kapinuss
798aee47b3 Update ObjectPool.java 2017-04-12 18:59:43 +03:00
Mihály Kuprivecz
dce767c1c5 first commit 2017-04-06 23:48:15 +02:00
Sunil Mogadati
60ebcc56f8 SonarQube blocker severity bugs 2017-04-01 20:55:47 -06:00
Paul Campbell
2643dfa0b8 data-bus: App: add notes about this implementation of the patter 2017-04-01 19:33:54 +01:00
Paul Campbell
c96ebcb197 data-bus: App: add description of the pattern 2017-04-01 19:26:41 +01:00
Paul Campbell
b72d545349 data-bus: members: StatusMemberTest: added 2017-04-01 19:17:09 +01:00
Paul Campbell
311bb79870 data-bus: members: StatusMember: records start and stop times 2017-04-01 19:16:55 +01:00
Paul Campbell
f495a88e91 data-bus: members: MessageCollectorMemberTest: added 2017-04-01 19:05:19 +01:00
Paul Campbell
8b0c14cae0 Counter doesn't count anything. Added ability to collect the messages
from the MessageData that it receives.
2017-04-01 19:05:09 +01:00
Paul Campbell
b7a6a018e0 data-bus: DataBusTest: added 2017-04-01 18:36:04 +01:00
Paul Campbell
46e0fa4825 data-bus: pom.xml: add mockito dependency 2017-04-01 18:35:40 +01:00
Paul Campbell
86009f2261 data-bus: add missing javadoc 2017-04-01 18:12:56 +01:00
Paul Campbell
146f367188 data-bus: remove lombok 2017-04-01 18:12:32 +01:00
Paul Campbell
bc4d029a87 data-bus: pom.xml: remove surefire plugin 2017-04-01 18:04:44 +01:00
Paul Campbell
960eee3d43 update version 2017-04-01 18:04:16 +01:00
Paul Campbell
30315e788f Merge remote-tracking branch 'upstream/master' into data-bus
* upstream/master: (67 commits)
  Set version for next development iteration
  Reached milestone 1.15.0
   Checkstyle fix
   More Checkstyle fixes
   Checkstyle fixes
   Add missing puml and license headers
   Add missing license header
  Work on : urm/puml updates * added pumlid where it was missing and possible * removed pumlid where it generated a bad image * regenerated some incorrect puml's * added 'left to right direction' puml prefix to some diagrams to improve the automatic layouting
  Removed AvoidStarImport Rule Added JavaDocType Rule
  Update App.java
  Update App.java
  Update after changes from review. Additional improvements.
  Pom.xml files fixed.
   Balking Pattern
  fixed pmd violation
  fixed checkstyle violations
  diagrams added
  comments, tests and description
  changed parent POM version 
  apply changes from review 
  ...

# Conflicts:
#	pom.xml
2017-04-01 18:03:02 +01:00
Ilkka Seppälä
073d06c0ae Set version for next development iteration 2017-04-01 17:15:59 +03:00
Ilkka Seppälä
8fea969912 Reached milestone 1.15.0 2017-04-01 17:14:02 +03:00
Ilkka Seppälä
139876f96a Checkstyle fix 2017-04-01 15:51:01 +03:00
Ilkka Seppälä
f3c4640d12 More Checkstyle fixes 2017-04-01 15:43:36 +03:00
Ilkka Seppälä
c1c4411957 Checkstyle fixes 2017-04-01 15:34:13 +03:00
Ilkka Seppälä
3f272bf291 Merge pull request from muditporwal/master
Checkstyle improvements  : Added JavaDocType Rule
2017-04-01 14:45:52 +03:00
Ilkka Seppälä
2921448f8b Add missing puml and license headers 2017-04-01 14:25:13 +03:00
Ilkka Seppälä
952c207a62 Merge pull request from Crossy147/converter
Converter
2017-04-01 14:17:37 +03:00
Ilkka Seppälä
6ba4d7be98 Add missing license header 2017-04-01 12:39:06 +03:00
Ilkka Seppälä
854101bb49 Merge pull request from thomasoss/master
Thread Local Storage issue 
2017-04-01 12:29:03 +03:00
Kamil Pietruszka
a5ab5c7d8e Merge branch 'master' into converter 2017-03-26 23:50:08 +02:00
Ilkka Seppälä
286d6c3a4c Merge pull request from Rzeposlaw/master
 Balking Pattern
2017-03-26 15:00:21 +03:00
NooBxGockeL
c2a7b902a9 Work on : urm/puml updates
* added pumlid where it was missing and possible
* removed pumlid where it generated a bad image
* regenerated some incorrect puml's
* added 'left to right direction' puml prefix to some diagrams to improve the automatic layouting
2017-03-25 22:07:10 +01:00
Mudit Porwal
09585c3874 Removed AvoidStarImport Rule
Added JavaDocType Rule
2017-03-22 01:16:02 +08:00
Thomas
f84c4c1611 Update App.java
Correction of correction ;-)
2017-03-18 10:02:37 +01:00
Thomas
2c2d874ac8 Update App.java
Correction of error detected by maven-pmd-plugin.
2017-03-18 10:00:13 +01:00
Kamil Pietruszka
72a0765ec6 Merge branch 'master' into converter 2017-03-16 12:27:05 +01:00
Katarzyna Rzepecka
cca4d5a670 Update after changes from review. Additional improvements. 2017-03-13 01:33:14 +01:00
Katarzyna Rzepecka
bb4a1bdc05 Pom.xml files fixed. 2017-03-13 01:16:26 +01:00
Katarzyna Rzepecka
1aed5905d7 Balking Pattern 2017-03-13 01:15:39 +01:00
Ilkka Seppälä
175e9f58c1 Merge pull request from robertt240/master
guarded suspension pattern 
2017-03-12 10:36:27 +02:00
Kamil Pietruszka
77a534385c fixed pmd violation 2017-03-11 13:35:55 +01:00
Kamil Pietruszka
2ed7acbc31 fixed checkstyle violations 2017-03-11 13:02:29 +01:00
Kamil Pietruszka
3a243eee6e diagrams added 2017-03-11 12:47:58 +01:00
Kamil Pietruszka
8632bafcd7 comments, tests and description 2017-03-11 12:24:48 +01:00
Robert Kasperczyk
449aed1a53 changed parent POM version 2017-03-11 12:02:04 +01:00
Robert Kasperczyk
a20abae21c apply changes from review 2017-03-11 11:50:19 +01:00
Robert Kasperczyk
7423f47daa further POM rearragments 2017-03-11 11:50:19 +01:00
Robert Kasperczyk
f09578c091 further POM rearragments 2017-03-11 11:50:19 +01:00
Robert Kasperczyk
29715028d1 fix in POM formatting 2017-03-11 11:50:19 +01:00
Robert Kasperczyk
e5034c6ae9 guarded suspension pattern 2017-03-11 11:50:19 +01:00
Robert Kasperczyk
a09866d35b another readme fix 2017-03-11 11:50:19 +01:00
Robert Kasperczyk
1824b4138b readme fix 2017-03-11 11:50:19 +01:00
Robert Kasperczyk
764ff4bf53 Initial commit of guarded suspension design pattern 2017-03-11 11:50:19 +01:00
Kamil Pietruszka
e8b634c33e java docs added 2017-03-10 20:59:24 +01:00
Kamil Pietruszka
8871f788d2 Converter pattern implementation 2017-03-10 20:08:58 +01:00
Kamil Pietruszka
e9c54011e9 Merge remote-tracking branch 'refs/remotes/iluwatar/master' 2017-03-08 16:50:04 +01:00
Paul Campbell
6b795e52c3 data-bus: README.md: updated for data-bus 2017-03-05 19:43:57 +00:00
Paul Campbell
b5bdf2d7d7 data-bus: etc: add urm diagrams 2017-03-05 19:43:26 +00:00
Paul Campbell
3fd6887975 data-bus: implement pattern 2017-03-05 18:55:34 +00:00
Paul Campbell
eecffb0ea5 data-bus: add stub 2017-03-03 19:58:03 +00:00
Thomas
fd7107694a Update pom.xml
Changed
    <version>1.14.0-SNAPSHOT</version>
to
    <version>1.15.0-SNAPSHOT</version>
2017-02-18 15:16:15 +01:00
Ilkka Seppälä
cca4760f69 Rename package for Queue-Based Load Leveling pattern 2017-02-12 00:33:30 +02:00
Ilkka Seppälä
a1ff55b462 Regenerate puml files 2017-02-11 21:46:56 +02:00
Thomas
ddac9dc6cb Add files via upload
Changed the classname part "runnable" to "callable"
2017-01-29 12:34:13 +01:00
Thomas
2bbf84233e Delete DateFormatRunnableTestMultiThread.java 2017-01-29 12:32:44 +01:00
Thomas
82f8460243 Delete DateFormatRunnableTestIncorrectDateFormat.java 2017-01-29 12:32:32 +01:00
Thomas
59ea20745f Delete DateFormatRunnableTest.java 2017-01-29 12:32:21 +01:00
Thomas
3d3dd58501 Update pom.xml
removed errors caused by copy code from master
2017-01-29 12:08:11 +01:00
Thomas
3324e1bc43 Update pom.xml
added  <module>tls</module>
2017-01-29 12:01:32 +01:00
Thomas
6202f3ab44 Add files via upload 2017-01-29 11:42:16 +01:00
Thomas
453862cfc2 Delete AppTest.java 2017-01-29 11:41:46 +01:00
Thomas
a8e2c157de Add files via upload
Test reworked completely. AppTest seperated.
2017-01-29 11:41:13 +01:00
Thomas
080965fb17 Delete DateFormatUglyRunnable.java 2017-01-29 11:38:49 +01:00
Thomas
7200329a6b Add files via upload
Rework replaces previous version completely. Using ExecutorService. Use of result object instead of static variables. Ugly example is left out.
2017-01-29 11:38:20 +01:00
Thomas
f170aaa42b Delete DateFormatRunnable.java 2017-01-29 11:34:12 +01:00
Thomas
c598748549 Delete AppUgly.java 2017-01-29 11:33:59 +01:00
Thomas
ed11c4c4f9 Delete App.java 2017-01-29 11:33:40 +01:00
Thomas
283f198ba8 Delete empty 2017-01-29 11:32:26 +01:00
Thomas
15913d6382 Add files via upload
new uml diagramm after changes to the java classes
2017-01-29 11:31:06 +01:00
Thomas
65e047974c Create empty 2017-01-29 11:29:19 +01:00
Thomas
c529e35791 Delete tls.urm.puml 2017-01-29 11:28:27 +01:00
Thomas
3342851005 Delete tls.ucls 2017-01-29 11:28:17 +01:00
Thomas
c167f87ce5 Delete tls.png 2017-01-29 11:27:46 +01:00
Thomas
e8fc3427c6 Update README.md
no change of content. Improved text
2017-01-29 11:23:33 +01:00
Thomas
26b79a5382 Update README.md
Some additonal description, deleted wrong pumlid
2017-01-29 11:16:45 +01:00
Ilkka Seppälä
9ec0935a1c Merge pull request from leogtzr/master
Adding initialization-on-demand idiom and noninstantiable class instead of interface constant idiom
2017-01-23 08:21:07 +02:00
leogtzr
c6d0d28557 Reverting initialization on demand holder idiom. 2017-01-22 11:06:57 -07:00
leogtzr
e26215578c Changing code to use interfaces instead of implementations. 2017-01-21 15:49:29 -07:00
leogtzr
d6fc28e120 Changing code to use interfaces instead of implementations. 2017-01-21 15:47:54 -07:00
Ilkka Seppälä
115a85301c Add link to proxy blog 2017-01-21 13:37:16 +02:00
Ilkka Seppälä
29c5b80f19 Add link to Queue-Based Load Leveling blog 2017-01-21 12:56:42 +02:00
Ilkka Seppälä
0c8bb1c22e Set version for next development iteration 2016-12-31 10:24:26 +02:00
Ilkka Seppälä
0c48695fa5 Achieved milestone 1.14.0 2016-12-31 10:23:32 +02:00
Ilkka Seppälä
8d34ccf827 Add link to Proxy presentation. 2016-12-26 20:16:30 +02:00
Ilkka Seppälä
512a5c0560 Merge branch 'proxy-presentation' 2016-12-26 20:08:41 +02:00
Ilkka Seppälä
9cf1918425 Add presentation for Proxy pattern. 2016-12-26 20:05:38 +02:00
Ilkka Seppälä
5e57cd03d1 Add some material for proxy presentation. 2016-12-26 19:43:46 +02:00
leogtzr
6292690250 Changing constant interface pattern with a Noninstantiable class 2016-12-24 14:49:41 -07:00
Ilkka Seppälä
ad93184a79 Merge pull request from Valdar-Soft/master
Sonar quality bugfix and minor refactor
2016-12-24 12:36:11 +02:00
leogtzr
20b1c2bd49 Adding initialization on demand holder idiom. 2016-12-24 00:49:46 -07:00
Krisztián Nagy
95f2c19780 Sonar bug fixes using Yoda condition in equals expression when comparing String literal with String object.
Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources.
Minimal refactor.
2016-12-18 16:08:59 +01:00
Krisztián Nagy
120033b58b Sonar bug fixes using Yoda condition in equals expression when comparing String literal with String object.
Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources.
Minimal refactor.
2016-12-18 16:04:13 +01:00
Thomas
e210e4ed62 Add files via upload 2016-12-16 11:17:27 +01:00
Thomas
fb98da86c4 Add files via upload 2016-12-16 11:12:43 +01:00
Thomas
c8b3c773c7 Add files via upload 2016-12-16 09:43:16 +01:00
Thomas
61b1356976 Delete emptyfile 2016-12-16 09:42:46 +01:00
Thomas
487f9ddc80 Add files via upload 2016-12-16 09:42:08 +01:00
Thomas
9b7ce556e3 Create emptyfile 2016-12-16 09:35:19 +01:00
Thomas
e17cf27e5a upload pom.xml 2016-12-15 18:33:52 +01:00
Thomas
937a1e269d delete empty file 2016-12-15 18:32:13 +01:00
Thomas
803a97237c delete empty file 2016-12-15 18:31:53 +01:00
Thomas
e64f7faa3f upload junit test 2016-12-15 18:31:20 +01:00
Thomas
15d660b117 empty file to create folder 2016-12-15 18:30:22 +01:00
Thomas
544f7fb6d1 delete empty file 2016-12-15 18:28:02 +01:00
Thomas
c4eb198a8d Upload code files 2016-12-15 18:27:28 +01:00
Thomas
7067d1ae56 Create test 2016-12-15 18:24:03 +01:00
Thomas
d80edd1ed3 Create test 2016-12-15 18:08:12 +01:00
Thomas
aeefc11f25 Merge pull request from iluwatar/master
Update my local repository
2016-12-14 08:52:22 +01:00
Ilkka Seppälä
c94c8a3e74 Merge pull request from inbravo/master
Module pattern 
2016-12-01 20:53:12 +02:00
Amit Dixit
5d8806858b Review comments++ 2016-12-01 16:29:35 +05:30
Ilkka Seppälä
efc2c887e9 Merge pull request from Amarnath510/master
Issue . First commit. Queue Based Load Leveling
2016-11-28 19:04:31 +02:00
Chandana Amarnath
1d6d0c54a7 pom.xml Fixed Conflict 2016-11-28 20:33:45 +05:30
Chandana Amarnath
1387e2bc96 Fixed all the code changes after review 2016-11-28 20:13:18 +05:30
Ilkka Seppälä
faa29f8025 Update license headers 2016-11-27 14:34:20 +02:00
Ilkka Seppälä
89e7f51e99 Merge pull request from iluwatar/presentation
Add hexagonal architecture presentation
2016-11-27 13:50:04 +02:00
Ilkka Seppälä
cc02ff472b Merge pull request from igeligel/master
Object Mother pattern 
2016-11-26 20:22:48 +02:00
NooBxGockeL
7d995056ff Update URM Version to 1.4.4 and regenerated all puml files 2016-11-26 12:51:06 +01:00
Ilkka Seppälä
8574e06966 Proxy pattern: Add missing license header 2016-11-23 22:08:50 +02:00
Ilkka Seppälä
82d3d7bf1f Proxy pattern: Improve the example 2016-11-23 22:03:26 +02:00
Chandana Amarnath
1a75ab8df1 Removed unused imports in tests 2016-11-23 09:00:04 +05:30
Ilkka Seppälä
92f8501f7d Decorator pattern: Improve the example 2016-11-22 23:08:39 +02:00
Chandana Amarnath
b9ac0dc6a3 Fixed PMD issue. 2016-11-23 00:10:30 +05:30
Amarnath Chandana
5e7887d9be Reverted pom.xml changes that are done previously. 2016-11-22 12:21:24 +05:30
Amarnath Chandana
e8f7187e4b Updated pom.xml with maven-pmd-plugin
Added dependency "maven-pmd-plugin" to the pom file.
2016-11-22 12:06:54 +05:30
Chandana Amarnath
d6b5456f98 Updated checkstyle errors. 2016-11-20 23:36:23 +05:30
Chandana Amarnath
52a81eb368 Issue . Updated pom.xml 2016-11-20 21:55:56 +05:30
Chandana Amarnath
12b70cb39c Issue . First commit. Queue Based Load Leveling 2016-11-20 16:25:10 +05:30
Ilkka Seppälä
68ec24c62e Merge pull request from dbryla/master
 Added logging framework to repository
2016-11-18 20:47:17 +02:00
daniel-bryla
3091ff21b0 Reduced amount of information logged 2016-11-17 09:54:10 +01:00
Ilkka Seppälä
95b651f177 Merge pull request from thomasoss/patch-1
Update App.java
2016-11-15 21:31:34 +02:00
Amit Dixit
f67d2fd9a9 Review comments++ 2016-11-15 13:01:37 +05:30
Amit Dixit
4ff8fa3721 Review comments++ 2016-11-15 12:59:05 +05:30
Thomas
9180bb0fef Update App.java
The relationship between decorator and target (in the code example between Troll und SmartTroll) ist not a composition as described in the code comment lines of class App. It's a aggregation. In a composition both instances canncot live without the other one. But the target (Troll) could live without the decorator (Smart Troll). Changed "composition" to "aggregation" in the comment lines. Code lines are unchanged.
Greetings Thomas
2016-11-14 16:43:58 +01:00
Ilkka Seppälä
1abf5b11c3 Add presentation link to README.md 2016-11-13 11:37:49 +02:00
Ilkka Seppälä
22d973c460 Merge branch 'master' into presentation 2016-11-13 11:34:14 +02:00
Ilkka Seppälä
c850295aab Add new diagram 2016-11-13 11:23:22 +02:00
Ilkka Seppälä
4c24d99414 Work on Hexagonal Architecture presentation 2016-11-12 22:44:08 +02:00
Ilkka Seppälä
e1ae1067db Link Hexagonal Architecture pattern to corresponding blog entry 2016-11-06 12:26:03 +02:00
Ilkka Seppälä
6f3e2985a4 Create presentation template 2016-11-06 12:14:39 +02:00
daniel-bryla
b37190a214 Introduced logging in new example 2016-11-04 12:19:32 +01:00
daniel-bryla
0a427710bb Merge branch 'master' of https://github.com/iluwatar/java-design-patterns
* 'master' of https://github.com/iluwatar/java-design-patterns: (27 commits)
  Remove use of coveralls-maven-plugin (sonarqube.com covers this)
  Add SonarQube.com badge
  Fix environment variable
  Add Travis instructions for SonarQube.com analysis
  Adds more criticism to Singleton pattern.
  Event Based Asynchronous pattern: Add missing license header and puml diagram
  Changed config to non-interactive
  Moved config into a separate dir
  Unused import removed.
  End process logic clause has been corrected.
  Caching pattern: Documentation and diagram
  Fixes . Adds criticism to Singleton pattern.
  Alter JUnit tests to run in lesser time.
  Updated version snapshot to 1.14.0
  Changes based on review feedback.
  Closes . Adds criticism to service locator pattern.
  Caching pattern: Implementation of Cache-Aside pattern
  Caching pattern: Style fix for null check
  Caching pattern: Refactor LRU cache to avoid NPE and unnecessary cache lookup
  Caching pattern: Refactor shutdown hook to use method reference
  ...
2016-11-04 11:51:45 +01:00
daniel-bryla
e138163c4f Adjusted tests for logger introduction 2016-11-04 11:47:06 +01:00
Ilkka Seppälä
124fd33da0 Remove use of coveralls-maven-plugin (sonarqube.com covers this) 2016-11-01 21:31:54 +02:00
Ilkka Seppälä
9433c78d29 Merge pull request from bellingard/patch-1
Add SonarQube.com badge
2016-10-28 20:39:55 +03:00
Ilkka Seppälä
932700d9b1 Merge pull request from dzmitryh/master
Cosmetic fixes in async-method-invocation
2016-10-28 19:13:17 +03:00
daniel-bryla
27d6d500bc Reverted changes in composite example, due to nature of this example using logger isn't good idea 2016-10-28 09:35:59 +02:00
Amit Dixit
ea7752c5e1 checkstyle errors removed
checkstyle errors removed
2016-10-27 18:30:07 +05:30
Amit Dixit
7ba6cb43fd App
App
2016-10-27 16:00:01 +05:30
Amit Dixit
1ace4c05d6 App++
App++
2016-10-27 15:59:51 +05:30
Amit Dixit
7015e95ac3 SecondCut++
SecondCut++
2016-10-27 15:55:08 +05:30
Amit Dixit
2a77ac29e9 FirstCut++
FirstCut++
2016-10-26 16:59:36 +05:30
igeligel
6aed26e61e Fix pom.xml
Deleted </modules> tag because i added it one time more than neccessary
2016-10-24 15:43:52 +02:00
igeligel
74ac79b01e Fix pom.xml 2016-10-24 15:33:25 +02:00
igeligel
750fa4f954 Merge Changes of the master repository 2016-10-24 15:32:32 +02:00
igeligel
20295316c2 add entry to parent pom.xml 2016-10-24 15:30:17 +02:00
igeligel
56b0884258 Change name of variables in test 2016-10-24 15:28:27 +02:00
daniel-bryla
0438811489 Replaced usages of System.out with logger. 2016-10-23 19:59:03 +02:00
Fabrice Bellingard
1c02785927 Add SonarQube.com badge 2016-10-23 14:35:45 +02:00
Ilkka Seppälä
19cb715d20 Fix environment variable 2016-10-19 23:08:51 +03:00
Ilkka Seppälä
ffdaf2ec47 Add Travis instructions for SonarQube.com analysis 2016-10-19 22:25:37 +03:00
Ilkka Seppälä
a37a29e12b Merge pull request from dmitraver/master
Adds criticism to a Service Locator and Singleton patterns.
2016-10-18 21:01:58 +03:00
Dmitry Avershin
b66e8ecef9 Adds more criticism to Singleton pattern. 2016-10-18 14:18:47 +02:00
Ilkka Seppälä
99677867c6 Event Based Asynchronous pattern: Add missing license header and puml diagram 2016-10-18 07:51:37 +03:00
Ilkka Seppälä
0f7b44c3b1 Merge pull request from waisuan/master
Issue : Event-based Asynchronous pattern
2016-10-18 07:43:01 +03:00
WSSIA
70318123fe Changed config to non-interactive 2016-10-17 22:22:06 +01:00
WSSIA
986c529eb6 Moved config into a separate dir 2016-10-17 21:29:03 +01:00
Ilkka Seppälä
64bdab46b9 Merge pull request from christofferh/feat/cache-aside
Caching pattern: Cache-Aside
2016-10-17 22:49:16 +03:00
dzmitryh
37b930c3b7 Unused import removed. 2016-10-15 14:29:32 +03:00
dzmitryh
85060784a7 End process logic clause has been corrected. 2016-10-15 14:27:15 +03:00
Christoffer Hamberg
f114b5b957 Caching pattern: Documentation and diagram 2016-10-09 12:43:43 +02:00
igeligel
863ea75381 Add PlantUML file for the UML diagram 2016-10-06 20:12:43 +02:00
igeligel
3a9d1684fd Initial commit of the object mother
Add a simple king and queen classes which implement the behaviour of the
royalty interface. Also wrote the object mother of royalty objects which
is final so you can just call the static methods in it to create objects
with a specific state to use them fast in tests. The tests are already
created for testing the behaviour and the type of the objects which are
created by the object mother.
I also created the UML diagrams via object aid and updated the readme.
2016-10-04 22:33:06 +02:00
Dmitry Avershin
eea8785a22 Fixes . Adds criticism to Singleton pattern. 2016-10-04 14:34:01 +02:00
WSSIA
8f1758c28f Alter JUnit tests to run in lesser time. 2016-10-03 21:46:16 +01:00
WSSIA
622376e0fa Updated version snapshot to 1.14.0 2016-10-03 21:16:23 +01:00
WSSIA
5eacf522a2 Merge remote-tracking branch 'upstream/master' 2016-10-03 21:05:31 +01:00
WSSIA
12544caa75 Changes based on review feedback. 2016-10-03 21:05:11 +01:00
Dmitry Avershin
9512f3ec70 Closes . Adds criticism to service locator pattern. 2016-10-03 21:59:36 +02:00
Ilkka Seppälä
4ca205c03c Set version number for next development iteration 2016-09-30 19:40:28 +03:00
Ilkka Seppälä
c5e6dcc11b Reached milestone 1.13.0 2016-09-30 19:38:28 +03:00
Christoffer Hamberg
b31edda3cf Caching pattern: Implementation of Cache-Aside pattern 2016-09-22 20:41:26 +02:00
Christoffer Hamberg
e3355d76d1 Caching pattern: Style fix for null check 2016-09-22 20:36:02 +02:00
Christoffer Hamberg
865f788612 Caching pattern: Refactor LRU cache to avoid NPE and unnecessary cache lookup 2016-09-22 20:35:44 +02:00
Christoffer Hamberg
6ed842e58b Caching pattern: Refactor shutdown hook to use method reference 2016-09-22 20:34:46 +02:00
WSSIA
69cab15d75 Merge remote-tracking branch 'upstream/master' 2016-09-19 21:50:54 +01:00
WSSIA
371b262a51 Changes based on latest code review 2016-09-19 21:50:23 +01:00
WSSIA
dbd605e378 Changes based on latest code review 2016-09-19 21:50:04 +01:00
Ilkka Seppälä
6026eedd51 UML generation: Mark the urm-maven-plugin execution to be ignored in Eclipse and recreate all .puml files 2016-09-18 17:51:09 +03:00
Ilkka Seppälä
b030cd4eba Hexagonal pattern: Introduce lottery utils class 2016-09-17 09:20:33 +03:00
Ilkka Seppälä
6aa58e8ae6 Hexagonal pattern: Remove unnecessary factories 2016-09-17 09:07:06 +03:00
Ilkka Seppälä
914d1353a1 Hexagonal pattern: Update test application description 2016-09-15 21:56:15 +03:00
Ilkka Seppälä
df32a7b893 Hexagonal pattern: Introduced lottery events port with two adapters 2016-09-15 21:45:09 +03:00
Ilkka Seppälä
c4c5e78e50 Hexagonal pattern: Improve error handling in console lottery 2016-09-14 22:18:42 +03:00
Ilkka Seppälä
3cf2b34d2a Hexagonal pattern: Improve connection properties handling 2016-09-14 22:01:41 +03:00
Ilkka Seppälä
27e8cb7f2d Hexagonal pattern: Add separate class for Mongo connection properties 2016-09-14 19:25:26 +03:00
Ilkka Seppälä
e685512ed5 Hexagonal pattern: Added Mongo based banking adapter and bound it in Guice production module 2016-09-11 23:19:02 +03:00
WSSIA
f2159515bc Merge remote-tracking branch 'upstream/master' 2016-09-11 20:33:51 +01:00
Ilkka Seppälä
59e6a0af85 Hexagonal pattern: Ignore Mongo repository test 2016-09-11 22:16:50 +03:00
WSSIA
9a90f2de1f Changes based on code review 2016-09-11 18:45:51 +01:00
Ilkka Seppälä
626c56730c Hexagonal pattern: Added Mongo based ticket repository and set production configuration to use that 2016-09-11 20:02:34 +03:00
WSSIA
fce30db803 Updating fork branch 2016-09-11 16:24:16 +01:00
Ilkka Seppälä
a85463470e Hexagonal pattern: Add mongo driver dependency 2016-09-11 13:53:00 +03:00
Ilkka Seppälä
4410419914 Hexagonal pattern: Simplified lottery ticket ids 2016-09-11 10:34:12 +03:00
Ilkka Seppälä
e17d72bca8 Hexagonal pattern: Added console interfaces for players and administration. 2016-09-10 14:28:05 +03:00
Ilkka Seppälä
121ed3cca8 Hexagonal pattern: Move lottery administration and service to the core. Introduce console interfaces for players and administartors. 2016-09-10 07:56:37 +03:00
Ilkka Seppälä
adc6019c7e Hexagonal pattern: Remove interfaces with only one implementation 2016-09-10 07:14:24 +03:00
Ilkka Seppälä
0f2807b9cf Hexagonal pattern: More descriptive class names 2016-09-09 21:36:17 +03:00
Ilkka Seppälä
1b10ddbb73 Hexagonal pattern: Use Guice dependency injection 2016-09-06 22:39:39 +03:00
Ilkka Seppälä
348e577e8e Hexagonal pattern: Add Guice dependency 2016-09-06 21:39:08 +03:00
Ilkka Seppälä
22821ba8cc Move Guice to parent pom dependency management section 2016-09-06 21:35:36 +03:00
Markus Moser
4493341ba6 add documentation to 'use latest java 8' change 2016-09-04 11:00:24 +02:00
Ilkka Seppälä
3cb872807e Hexagonal pattern: remove unnecessary repository usage from a unit test 2016-09-04 10:33:26 +03:00
Ilkka Seppälä
ab68129829 Hexagonal pattern: move business logic to core 2016-09-03 22:02:08 +03:00
Ilkka Seppälä
e57a0948ef Merge pull request from iluwatar/DocumentUsages
 Document GoF usages from Java API
2016-09-03 14:14:13 +03:00
WSSIA
233f1e69f9 Removed PUBLIC modifiers from IEvent 2016-09-03 11:32:31 +01:00
WSSIA
f11597136f Fixed Checkstyle errors. 2016-09-03 11:32:29 +01:00
WSSIA
e1836fee2f Updated parent POM to include new pattern (Event-asynchronous) 2016-09-03 11:32:28 +01:00
WSSIA
2d99061902 Issue : Implementation of Event-based Asynchronous pattern 2016-09-03 11:32:25 +01:00
Ilkka Seppälä
ff23e90c4f Add puml for Promise pattern 2016-09-03 08:43:35 +03:00
Markus Moser
fa52a7f77e Run build with latest java 8 release 2016-09-03 00:19:50 +02:00
Markus Moser
165d1f1298 Turn Error Tracing on when installing
Travis currently errors and i cant reproduce locally, so this might help finding the culprit
2016-09-02 23:54:52 +02:00
NooBxGockeL
be2c7fdb2b Update URM version: 1.4.0 -> 1.4.1, fixes 2016-09-02 23:15:38 +02:00
Ilkka Seppälä
90c636abd3 Add missing license headers 2016-09-02 21:28:45 +03:00
Ilkka Seppälä
678a06e7f8 Merge pull request from iluwatar/Promise
Implements  Promise pattern
2016-09-02 20:47:21 +03:00
Markus Moser
e425c2ef2f Add webhook for travis build failures to gitter
Only the core group (private) gitter room
2016-08-31 13:15:44 +02:00
Narendra Pathai
5c1a4f1caf Added example that mocking frameworks use proxy pattern 2016-08-31 16:12:13 +05:30
NooBxGockeL
58dce1bd89 Work on : Commit initial pumlId's added by the script 2016-08-30 15:10:34 +02:00
NooBxGockeL
9dd1503e6f Work on : add postPumlsToServer.py python script
Used to initially post all pumls to the plantuml hosting while preserving the pumlId's
2016-08-30 15:07:49 +02:00
Markus Moser
09037b0251 Rename index.md to README.md
to conform to our standards, every other file is named README.md
2016-08-30 14:06:14 +02:00
NooBxGockeL
36fe249960 Work on : Add first batch of automagically generated puml files 2016-08-30 13:29:12 +02:00
NooBxGockeL
e73867f9a1 Work on : Add automagic puml generation in pom.xml's 2016-08-30 13:24:53 +02:00
Narendra Pathai
59cf100302 , updated javadocs 2016-08-29 12:04:24 +05:30
Narendra Pathai
ad11ea46b1 Work on , javadocs updated 2016-08-29 11:55:30 +05:30
Narendra Pathai
5796e1967f Work on , updated diagram and finishing touches 2016-08-29 11:50:33 +05:30
Narendra Pathai
483c61a82a Some refactoring, added javadocs 2016-08-29 00:16:36 +05:30
Narendra Pathai
6575b3ae99 Merge pull request from alexsomai/patch-1
Minor code changes
2016-08-29 00:00:44 +05:30
Alexandru Somai
095adda7e9 Change access level to private 2016-08-26 12:54:20 +03:00
Alexandru Somai
f16ae08bdf Remove extra space 2016-08-26 12:46:30 +03:00
Narendra Pathai
95cf9fe367 Work on , made example readable and moved methods into utility 2016-08-22 18:43:29 +05:30
Narendra Pathai
28647cdf48 , consistent use of real world examples section in all readme files. 2016-08-20 20:57:48 +05:30
Narendra Pathai
fdcf546112 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into DocumentUsages 2016-08-20 20:50:30 +05:30
Narendra Pathai
a0c77c32b5 added further examples for structural and behavioral patterns 2016-08-20 20:49:28 +05:30
Narendra Pathai
eb75773891 Added FAQ on Memento pattern
Difference between java Serialization and Memento pattern added
2016-08-20 19:44:48 +05:30
Narendra Pathai
c79df708b1 added real world examples from Java api for creational patterns 2016-08-20 13:17:53 +05:30
Markus Moser
56100927a9 Addendum
Change page-index for faq.md
2016-08-15 12:33:24 +02:00
Markus Moser
7e77216919 remove link, resolves
to avoid confusion, the link is removed.
For more information on why this is done please look at the referenced issue
2016-08-15 11:53:39 +02:00
Ilkka Seppälä
b16d7fc970 Configure Travis notification email 2016-08-14 23:00:27 +03:00
Ilkka Seppälä
0b36a3153d Fix checkstyle error 2016-08-14 22:42:59 +03:00
Ilkka Seppälä
7c2f5da926 Add final keyword 2016-08-13 18:28:53 +03:00
Ilkka Seppälä
ffbc5f2f29 Reorganize LotteryNumbers for easier inclusion in the blog 2016-08-13 17:08:57 +03:00
Ilkka Seppälä
d50139e13e Merge pull request from iluwatar/DocumentDoubleCheckIdiom
Documented singleton double check idiom
2016-08-05 18:45:00 +03:00
Narendra Pathai
d484e7f731 Documented singleton double check idiom, explaining the dynamics that happen on each step for better understanding. Did this due to a PR 2016-08-05 14:38:25 +05:30
Narendra Pathai
76970633b8 Work on , incorporate review changes 2016-08-04 18:10:50 +05:30
Narendra Pathai
55028a49dc Merge pull request from sumityadav6541/master
removed extra "is" from javadoc comments
2016-08-04 17:47:37 +05:30
Sumit Yadav
94c3a2caf3 removed extra "is" from the javadoc of InitializingOnDemandHolderIdiom class 2016-08-03 15:02:46 +05:30
Sumit Yadav
547d798528 Merge pull request from iluwatar/master
merging changes into fork from origin
2016-08-03 14:57:07 +05:30
Sia Wai Suan
8953bfc81b Merge pull request from iluwatar/master
Bringing fork up-to-date
2016-08-01 16:55:27 +01:00
Narendra Pathai
e7be94d2e4 Merge branch 'Promise' of https://github.com/iluwatar/java-design-patterns into Promise 2016-07-29 13:12:33 +05:30
Narendra Pathai
383e4a3a0b Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into Promise 2016-07-29 13:01:51 +05:30
Ilkka Seppälä
3001fa4a30 Merge pull request from
 added known alias for monostate pattern
2016-07-27 15:46:17 +03:00
Kamil Pietruszka
5fcef89384 added known aliast for monostate pattern 2016-07-26 20:33:43 +02:00
Narendra Pathai
40ac552542 Work on , added README 2016-07-24 01:45:49 +05:30
Narendra Pathai
09ba5ca656 Work on , added class diagrams and javadocs 2016-07-22 18:34:05 +05:30
Narendra Pathai
eb560f5f54 Work on , removed checkstyle violations 2016-07-22 16:53:01 +05:30
Narendra Pathai
2b945ca27f Work on , removed dependency on async method invocation module, added more tests 2016-07-22 16:47:52 +05:30
Narendra Pathai
4bd1f14cfb Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into Promise 2016-07-22 12:52:54 +05:30
Ilkka Seppälä
bc94d0fc26 Fix link 2016-07-21 20:21:36 +03:00
Narendra Pathai
102341443d Work on , added application class and test cases. 2016-07-21 19:13:42 +05:30
Ilkka Seppälä
8124fd0771 Adjust pattern categories and tags 2016-07-21 09:27:48 +03:00
Narendra Pathai
ea7503414e Work on , added basic implementation of promise pattern 2016-07-20 19:58:20 +05:30
Ilkka Seppälä
d4c2f0392d Merge pull request from pnowy/#463-chain-of-responsibility
 Added javax.servlet.Filter to real world examples intercepting filter
2016-07-18 09:22:34 +03:00
Przemek Nowak
f7b7f15ec8 Added javax.servlet.Filter to real world examples of intercepting filter 2016-07-17 21:24:12 +02:00
Przemek Nowak
0fbbd8dc81 Added javax.servlet.Filter to real world examples of chain 2016-07-17 16:05:07 +02:00
Ilkka Seppälä
9f0320aeaf Add some tags to Page Object 2016-07-13 00:02:20 +03:00
Ilkka Seppälä
fe1d760c7f Fix license headers 2016-07-12 19:52:56 +03:00
Ilkka Seppälä
b46d2deeb0 Merge pull request from colinbut/master
 Page Object Pattern
2016-07-12 19:47:48 +03:00
Colin But
f182e87ee1 fixed app launch 2016-07-10 20:51:52 +01:00
Colin But
85f432fb54 exclude library class from jacoco code coverage 2016-07-09 22:24:17 +01:00
Colin But
7be98fa829 added missing licence headers to 2 files 2016-07-09 22:20:13 +01:00
Ilkka Seppälä
ff8037ee0b Add aliases for Specification pattern 2016-07-07 08:46:56 +03:00
Ilkka Seppälä
849df50394 Fix formatting 2016-07-04 22:22:37 +03:00
Ilkka Seppälä
f806c5b712 Add known uses to Factory Method 2016-07-04 21:52:39 +03:00
Colin But
ef2ada4fdf syncing fork 2016-07-03 21:47:07 +01:00
Colin But
5d58a1b333 syncing fork 2016-07-03 21:46:38 +01:00
Colin But
4a069ee93a new class diagrams 2016-07-03 21:36:03 +01:00
Colin But
88321890c7 remove old class diagram 2016-07-03 21:12:48 +01:00
Colin But
b1e40d9c92 Feedback changes - final and refactored code 2016-07-03 21:12:09 +01:00
Ilkka Seppälä
5c26f46174 Set version number for next development iteration 2016-06-30 18:15:26 +03:00
Ilkka Seppälä
7a118e4209 Reached milestone 1.12.0 2016-06-30 18:14:41 +03:00
Colin But
4eac37c6b5 Feedback changes - removed file 2016-06-28 22:04:39 +01:00
Colin But
c212ee5cb1 Feedback changes - fix dependency in pom 2016-06-28 22:03:57 +01:00
Colin But
8efaf44170 Feedback changes - sort out dependency 2016-06-28 22:02:03 +01:00
Colin But
27e4e9afee Feedback changes - restructed project structure 2016-06-28 21:53:55 +01:00
Colin But
35c0942803 syncing fork 2016-06-27 20:54:45 +01:00
Ilkka Seppälä
e7bd3cade2 Update link for Naked Objects paper 2016-06-26 20:23:05 +03:00
Ilkka Seppälä
f2e1982264 Merge pull request from protopapa/aggregator-microservices
implementation of microservices architectural pattern 
2016-06-26 17:32:42 +03:00
protopapa
27bbbd8335 fix bug 2016-06-26 14:57:27 +02:00
protopapa
6677d1091d implementation of microservices architectural pattern 2016-06-23 22:54:44 +02:00
Colin But
0282d6663f README 2016-06-18 21:08:15 +01:00
Colin But
c8f04d2f0d added Class Diagram 2016-06-18 19:20:29 +01:00
Colin But
53fc8b749a Page Object pattern implementation 2016-06-18 15:40:03 +01:00
Ilkka Seppälä
f57b94ab47 Merge pull request from qza/master
Abstract Document
2016-06-07 22:32:00 +03:00
Ilkka Seppälä
34431d71b4 Merge pull request from VarunVats9/master
Renamed HeroBuilder to Builder
2016-06-05 09:20:54 +03:00
qza
afdeba4f9a finalize example 2016-06-04 20:06:32 +02:00
qza
c229ec23b3 clean up 2016-06-02 07:41:32 +02:00
qza
f3110de130 handle case when there are no child elements for the given key 2016-06-02 07:32:48 +02:00
qza
43f90ead48 abstract document test 2016-06-02 07:29:37 +02:00
qza
a372f05e41 override toString to log properties 2016-06-02 07:27:35 +02:00
qza
32b647323c class diagrams 2016-06-01 22:21:31 +02:00
qza
913411773f document, abstract base, traits and example domain 2016-06-01 22:20:55 +02:00
qza
c1187ae0d7 init abstract-document module 2016-05-31 20:12:27 +02:00
VarunVats9
509de9782d renamed HeroBuilder to Builder 2016-05-29 20:05:54 +05:30
Ilkka Seppälä
f6649a4fed Markdown fix 2016-05-22 09:33:50 +03:00
Ilkka Seppälä
9de2cbe73e Merge pull request from iluwatar/hexagonal
Implements  Hexagonal Architecture
2016-05-21 22:19:16 +03:00
Ilkka Seppälä
75ed1b1a96 Review fixes 2016-05-21 21:48:25 +03:00
Ilkka Seppälä
2ed3748c9b Improve Singleton holder example 2016-05-07 11:38:55 +03:00
Ilkka Seppälä
0ad9937881 Merge pull request from surgeforward/297
 Create API Gateway pattern
2016-05-06 10:14:31 +03:00
tmcconville
f234a6875c Update class diagram to reflect new location of files 2016-05-03 17:41:37 -05:00
tmcconville
dd2385312b Add new dependencies to java-design-patterns/pom.xml and reference them from api-gateway submodule pom.xml files 2016-05-03 17:37:33 -05:00
tmcconville
8653eb87bc Move API Gateway code into a new submodule: api-gateway-service. Change api-gateway packaging type to "pom". Update price-microservice and image-microservice to be true submodules of api-gateway 2016-05-03 17:17:36 -05:00
tmcconville
a6036e5787 Update category and tags in README 2016-05-03 16:29:20 -05:00
tmcconville
5abd20f9e1 Update license headers 2016-05-03 16:28:20 -05:00
tmcconville
b115c61873 Fix error in README 2016-04-24 16:05:38 -05:00
tmcconville
b92318ae36 Increase version number 2016-04-24 16:00:53 -05:00
tmcconville
28d259a55c Create README.md 2016-04-24 16:00:39 -05:00
tmcconville
9a9df80080 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into 297
Conflicts:
	pom.xml
2016-04-24 15:30:35 -05:00
tmcconville
a54cea777f Create class diagrams for API Gateway, Price microservice, and Image microservice 2016-04-24 15:24:33 -05:00
Markus Moser
71e3443e0e Fix permalink to represent its current dir
Otherwise the picture cant be found, as the jekyll build process will put this file in a 'dm' directory and the other stuff like resources in a 'data-mapper' directory (because resources dont have permalink specified they are served static)
2016-04-24 12:58:38 +02:00
Markus Moser
bf7b682549 Add License Shield 2016-04-24 12:25:05 +02:00
Ilkka Seppälä
5b72510c1c Merge pull request from inbravo/master
Data Mapper 
2016-04-24 00:02:48 +03:00
Ilkka Seppälä
49ca63087c Merge branch 'master' into hexagonal
# Conflicts:
#	pom.xml
2016-04-20 22:32:22 +03:00
Amit Dixit
af1db79aa7 version++ 2016-04-20 07:23:12 +05:30
Amit Dixit
59e9d027d4 version++ 2016-04-19 12:45:12 +05:30
Amit Dixit
018a4e52a2 build error fix++ 2016-04-19 12:23:52 +05:30
Amit Dixit
93b0b3730e build error fix++ 2016-04-19 11:59:27 +05:30
Amit Dixit
d5f7cb4e2c build check style error-- 2016-04-19 11:49:35 +05:30
Amit Dixit
8fa774d420 mvn build file++ 2016-04-19 11:35:13 +05:30
Amit Dixit
28c2714862 review comments++
review comments++
2016-04-19 11:25:42 +05:30
Ilkka Seppälä
534fb67eb0 Merge pull request from gwildor28/master
Lock Pattern : Added mutex and semaphore modules to demonstrate locks
2016-04-18 21:12:29 +03:00
Amit Dixit
32736fc90c uml diagram++ 2016-04-18 17:05:18 +05:30
Amit Dixit
8529d6e34b First review changes++
First review changes++
2016-04-18 13:14:20 +05:30
gwildor28
a2843297d8 JUnit tests 2016-04-17 14:46:52 +01:00
Ilkka Seppälä
886ad7e8f0 Fix some markdown errors 2016-04-16 08:52:16 +03:00
Ilkka Seppälä
6f89315aa9 Fix minor display error on web site 2016-04-15 08:41:15 +03:00
Ilkka Seppälä
cf0570a5ed Fix display error 2016-04-15 08:38:08 +03:00
Ilkka Seppälä
8e69ebce9f Fix display error 2016-04-15 08:21:29 +03:00
Ilkka Seppälä
439e286f00 Fix minor display error 2016-04-15 08:13:51 +03:00
gwildor28
e821abdb1b updated version to fix pom 2016-04-14 17:44:18 +01:00
gwildor28
685d093cff added relative paths to pom in mutex/semaphore 2016-04-14 17:33:52 +01:00
gwildor28
ca8be7c43e pom update 2016-04-13 19:26:31 +01:00
gwildor28
3f9a756657 pom update 2016-04-13 19:25:02 +01:00
gwildor28
1fd15d535b Merge remote-tracking branch 'refs/remotes/iluwatar/master' 2016-04-13 18:51:55 +01:00
Ilkka Seppälä
b72214da2f Fix H2 database path problem 2016-04-12 23:04:37 +03:00
Ilkka Seppälä
a7dfe7681e Add alias names 2016-04-11 23:17:27 +03:00
Ilkka Seppälä
cfda338617 Fix version number 2016-04-10 22:03:24 +03:00
Ilkka Seppälä
e546d5dacc Add general description for the example code 2016-04-10 21:50:02 +03:00
Ilkka Seppälä
c2f4194c07 Add alias name for the pattern 2016-04-10 21:49:40 +03:00
Ilkka Seppälä
ccc1ec921a Add readme and class diagram 2016-04-10 21:22:40 +03:00
Ilkka Seppälä
9b3aa785ed Add missing license headers 2016-04-09 17:21:27 +03:00
Ilkka Seppälä
0fe8eec610 Fix merge conflict 2016-04-09 17:17:29 +03:00
Ilkka Seppälä
68725bf3cc Merge branch 'master' into hexagonal 2016-04-09 17:16:07 +03:00
Ilkka Seppälä
5de9c7e6b4 Lots of improvements to the example 2016-04-09 16:53:34 +03:00
Ilkka Seppälä
48803d4c7d Add example lottery run 2016-04-09 16:01:47 +03:00
Ilkka Seppälä
b94a705161 Add constants for win sum and prize payer's bank account 2016-04-09 15:14:12 +03:00
Ilkka Seppälä
335737d7dd Add alias for Multiton 2016-04-06 20:37:02 +03:00
Amit Dixit
06e0a15400 Applicability++ 2016-04-06 13:18:42 +05:30
Amit Dixit
c53dcf1274 Intent++ 2016-04-06 13:14:10 +05:30
Amit Dixit
822ab8d9fd Second type mapper is updated to use java.util.vector
Second type mapper is updated to use java.util.vector
2016-04-04 16:35:22 +05:30
Amit Dixit
59b6b817f4 Test/Doc added
Test/Doc added
2016-04-04 15:31:43 +05:30
Amit Dixit
eb72493f13 JDBC removed... 2016-04-04 12:33:43 +05:30
Amit Dixit
deb15e2733 JDBC removed... 2016-04-04 12:24:15 +05:30
Markus Moser
d631585fa8 Test commit for
ignore the minor documentation change.
This is to test our build chain with travis!
2016-04-03 20:04:56 +02:00
tmcconville
4ebb64c092 Create unit test for PriceController 2016-04-02 18:33:50 -05:00
tmcconville
e80583fad7 Create unit test for ImageController 2016-04-02 18:31:58 -05:00
tmcconville
665256ecc0 Create Spring Boot-backed API Gateway that aggregates calls to the Image and Price microservices 2016-04-02 18:25:13 -05:00
tmcconville
01737bc643 Create Spring Boot-backed Price microservice with an endpoint to retrieve a price 2016-04-02 18:19:42 -05:00
tmcconville
0c6d3f2c3a Create Spring Boot-backed Image microservice with an endpoint to retrieve an image path 2016-04-02 18:19:21 -05:00
Ilkka Seppälä
398eb11b11 Set version for the next development iteration 2016-04-02 19:55:04 +03:00
Ilkka Seppälä
1f27dbbf5b Set version for milestone 1.11.0 2016-04-02 19:51:03 +03:00
gwildor28
187658cce9 Merge remote-tracking branch 'iluwatar/master' 2016-03-29 14:19:01 +01:00
gwildor28
e2af78f417 Update According to Review Comments
Resubmit of updates
2016-03-29 13:42:54 +01:00
gwildor28
474f2658ee Merge remote-tracking branch 'refs/remotes/iluwatar/master' 2016-03-29 13:36:56 +01:00
Amit Dixit
28a5a43a47 basic implementation ++
basic implementation ++
2016-03-29 16:36:00 +05:30
Ilkka Seppälä
d20145c05d Merge pull request from iluwatar/refactor-dao
Solves  Refactor dao
2016-03-28 19:44:07 +03:00
Narendra Pathai
464ae1690b Updated pom 2016-03-28 11:59:29 +05:30
Narendra Pathai
ddbc61b140 Incorporated review changes - 1) Created sql file for central schema 2)
Changed getById return type to Optional
2016-03-28 11:55:22 +05:30
Narendra Pathai
f32a3892a3 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into refactor-dao 2016-03-28 11:06:25 +05:30
Ilkka Seppälä
6608a8de38 Utilize notifications and banking 2016-03-27 23:35:51 +03:00
Ilkka Seppälä
28d3cb2aa2 Add notifications implementation 2016-03-26 22:01:31 +02:00
Ilkka Seppälä
11c0654103 Add banking implementation 2016-03-26 21:47:25 +02:00
Ilkka Seppälä
f620123cee Organize packages 2016-03-26 21:22:49 +02:00
Ilkka Seppälä
d406f0f9c6 Merge pull request from slawiko/patch-1
Override annotation added
2016-03-26 21:03:34 +02:00
Ilkka Seppälä
ac468bb7e7 Added high level lottery test 2016-03-26 15:54:40 +02:00
Slava Shchaurouski
0c56d800c5 Override annotation added
I think this is a typo
2016-03-26 15:22:33 +03:00
Ilkka Seppälä
4bb7ddaec1 Work on admin tests 2016-03-26 12:42:23 +02:00
Ilkka Seppälä
39a1c1e956 Implement admin interface 2016-03-26 12:28:51 +02:00
Ilkka Seppälä
656b599687 Refactor to test utils 2016-03-26 12:28:31 +02:00
Narendra Pathai
9074a9ca05 Merge branch 'saifulazad-patch-1' 2016-03-26 15:54:38 +05:30
Narendra Pathai
b14aff17b6 Updated failing test cases 2016-03-26 15:54:10 +05:30
Narendra Pathai
20c1e2ea80 Merge branch 'patch-1' of https://github.com/saifulazad/java-design-patterns into saifulazad-patch-1 2016-03-26 15:50:25 +05:30
Ilkka Seppälä
100a72a5e2 Merge pull request from iluwatar/mute-idiom
Implements Mute idiom
2016-03-26 11:07:46 +02:00
Ilkka Seppälä
8d6bc522cd Simplify lottery ticket submit 2016-03-26 11:03:40 +02:00
Narendra Pathai
a395316a80 Added readme 2016-03-26 13:54:03 +05:30
Narendra Pathai
80875a9ac8 Removed dependency on Mockito from pom 2016-03-26 12:36:50 +05:30
Narendra Pathai
4d820b12ff Changes after review. Added README 2016-03-26 12:33:02 +05:30
Narendra Pathai
e543ee0a9c Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into mute-idiom 2016-03-26 12:11:09 +05:30
Ilkka Seppälä
2f5a2be27a Fix missing table error 2016-03-25 22:00:08 +02:00
Saiful Islam
e549af25dd Severe is not appropriate.
"Sever" is most Appropriate
2016-03-25 22:50:17 +06:00
gwildor28
6e4b269939 Update according to review comments
- Added descriptions
- Added junit tests
- Added javadoc
- Added index.md
- Added class diagrams
2016-03-24 18:13:37 +00:00
Narendra Pathai
3f7ead5ca5 Work on , updated class diagram and javadoc. Passed checkstyle checks 2016-03-23 13:13:19 +05:30
Ilkka Seppälä
266b658ab5 Refactor interfaces 2016-03-22 22:45:25 +02:00
Ilkka Seppälä
d2f620a5e6 Added tests for lottery ticket repository 2016-03-22 21:27:13 +02:00
Markus Moser
aebd857931 Merge pull request from slawiko/slawiko-patch-1
File renaming (index.md to README.md)
2016-03-22 12:22:35 +01:00
Narendra Pathai
fa077c8be9 Work on , javadocs and test cases for DB and in memory dao. 2016-03-21 17:55:29 +05:30
Ilkka Seppälä
8b147c4dd9 Add mock database for lottery tickets 2016-03-20 20:56:04 +02:00
Ilkka Seppälä
fde33999b7 Added interface for lottery administrators 2016-03-20 14:38:24 +02:00
Ilkka Seppälä
e8671e1d6e Add interface for lottery event notifications 2016-03-20 14:33:41 +02:00
Ilkka Seppälä
15d2b9dcca Added interface to lottery service provider's bank account 2016-03-20 14:26:43 +02:00
Ilkka Seppälä
95e6a67056 Added interface for accessing lottery tickets in database 2016-03-20 14:09:44 +02:00
Ilkka Seppälä
2785f6915b Add lottery ticket check result 2016-03-20 11:10:06 +02:00
slawiko
bd1b65276e all index.md files renamed to README.md for more compatibility with github 2016-03-20 11:50:21 +03:00
Ilkka Seppälä
804ffc3ea7 Added lottery service interface 2016-03-20 10:49:31 +02:00
Ilkka Seppälä
035b14fef8 Added lottery ticket and unit tests 2016-03-19 21:57:57 +02:00
Ilkka Seppälä
81718eb8ae Added player details and unit tests 2016-03-19 21:08:55 +02:00
Ilkka Seppälä
cd3a5d48d8 Work on lottery numbers unit tests 2016-03-19 20:37:36 +02:00
Ilkka Seppälä
b0f96adeb1 Added class for lottery numbers and unit tests for it 2016-03-19 18:13:30 +02:00
Narendra Pathai
448d855809 implemented and added test cases for DB dao. Added dependency of Hierarchical junit runner in parent pom 2016-03-18 16:39:45 +05:30
Narendra Pathai
f6a20c7693 Refactoring changes to DAO pattern. Renamed default dao implementation to InMemory and refined interface 2016-03-16 18:47:07 +05:30
Narendra Pathai
e5217bbde8 Work on , added missing license template 2016-03-16 12:48:53 +05:30
Narendra Pathai
40e5c8d587 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into mute-idiom 2016-03-16 12:41:15 +05:30
Narendra Pathai
c78dd2667a Work on , added documentation and class diagram. Made refactoring changes to pass checkstyle and PMD checks 2016-03-16 12:40:46 +05:30
Narendra Pathai
7aff77ab27 Used mockito to replicate SQLException while closing connection to show use of loggedMute 2016-03-15 18:44:59 +05:30
Ilkka Seppälä
528d179efe Add missing license headers 2016-03-13 17:29:09 +02:00
Ilkka Seppälä
06546ae3cf Fix license headers 2016-03-13 17:23:31 +02:00
Ilkka Seppälä
2ed089900d Initial commit for Hexagonal Architecture pattern 2016-03-13 17:23:15 +02:00
Ilkka Seppälä
984bf552ce Merge pull request from DevFactory/release/private-methods-that-don't-access-instance-data-should-be-static-fix-1
squid:S2325 - private methods that don't access instance data should …
2016-03-09 18:33:17 +02:00
Narendra Pathai
414cdfa332 Merge pull request from legka/master
Event driven architecture refactored.
2016-03-09 10:49:08 +05:30
Oleg
afb897300b Event driven architecture refactored.
1. Renamed Message to Event and Event to AbstractEvent
2. Generified Event and Handler
3. Updated EventDispatcher to make unsafe configuration impossible
4. Updated UML diagram accordingly
2016-03-08 00:56:08 -08:00
gwildor28
3ed3bc1fa5 Added mutex and semaphore modules to demonstrate locks
Added two modules to demonstrate locks.

Mutex demonstrates a simple mutual exclusion lock. Semaphore
demonstrates a semaphore for controlling access to a pool of resources.

The main class of both programs is App.java.
2016-03-07 19:40:50 +00:00
Narendra Pathai
adb94044ff Work on , created project and provided two mute methods 2016-03-01 17:28:28 +05:30
Narendra Pathai
35d6a54831 Merge pull request from DevFactory/release/Useless-parentheses-around-expressions-should-be-removed-to-prevent-any-misunderstanding-fix-1
squid:UselessParenthesesCheck - Useless parentheses around expression…
2016-02-29 17:53:13 +05:30
Ilkka Seppälä
f135ef6ec8 Merge pull request from DevFactory/release/Declarations-should-use-Java-collection-interfaces-such-as-List-rather-than-specific-implementation-classes-such-as-LinkedList-fix-1
squid:S1319 - Declarations should use Java collection interfaces such…
2016-02-29 07:42:04 +02:00
Mohammed Ezzat
046e131119 squid:UselessParenthesesCheck - Useless parentheses around expressions should be removed to prevent any misunderstanding 2016-02-23 20:57:55 +02:00
Mohammed Ezzat
e4c34b1e22 squid:S1319 - Declarations should use Java collection interfaces such as List rather than specific implementation classes such as LinkedList 2016-02-23 12:32:23 +02:00
Mohammed Ezzat
3791a80978 squid:S2325 - private methods that don't access instance data should be static 2016-02-22 19:15:51 +02:00
Ilkka Seppälä
ab19c47415 Merge pull request from Crossy147/monad-pattern
Monad pattern
2016-02-21 20:36:05 +02:00
Ilkka Seppälä
9f086ba72c Merge pull request from Crossy147/master
issue  Factory-kit
2016-02-21 19:56:53 +02:00
Crossy147
cfd83b5753 issue review changes 2016-02-21 12:54:40 +01:00
Crossy147
81e8d354a9 issue review changes 2016-02-21 12:10:08 +01:00
Ilkka Seppälä
c580b61df3 Merge pull request from DevFactory/release/Type-parameter-names-should-comply-with-a-naming-convention-fix-1
squid:S00119 - Type parameter names should comply with a naming conve…
2016-02-20 19:35:53 +02:00
Ilkka Seppälä
9714fe075a Merge pull request from DevFactory/release/Constructors-should-only-call-non-overridable-methods-fix-1
squid:S1699 - Constructors should only call non-overridable methods
2016-02-20 19:25:48 +02:00
Ilkka Seppälä
bbd769b208 Merge pull request from amitbhoraniya/master
Dao Pattern : Create object with reference to Interface
2016-02-20 18:34:47 +02:00
Mohammed Ezzat
d3689b2040 squid:S00119 - Type parameter names should comply with a naming convention 2016-02-20 18:19:44 +02:00
Ilkka Seppälä
ea81ef71ab Merge pull request from iluwatar/FactoryMethodChanges
Factory and Abstract Factory changes
2016-02-20 17:49:14 +02:00
Crossy147
80ff7bb217 issue brace typo 2016-02-20 15:01:45 +01:00
Crossy147
64f1fe8979 issue typos fixed 2016-02-20 14:55:37 +01:00
Crossy147
f47b9283c3 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into monad-pattern 2016-02-19 19:10:43 +01:00
Crossy147
72e08365b8 issue documentation improvements 2016-02-19 19:08:35 +01:00
Crossy147
3e526cb5da issue Monad pattern introduced 2016-02-19 17:56:09 +01:00
Mohammed Ezzat
50310aaeaf squid:S1699 - Constructors should only call non-overridable methods 2016-02-19 11:02:49 +02:00
Amit Bhoraniya
b70614efef Creating object with reference to Interface
In Dao pattern DaoImpl object is created with reference to dao interface.
2016-02-19 00:10:55 +05:30
Narendra Pathai
dfef28e93e Merge pull request from DevFactory/release/Redundant-Field-Initializer-fix-1
pmd:RedundantFieldInitializer - Redundant-Field-Initializer
2016-02-18 12:39:06 +05:30
Mohammed Ezzat
0003c6cb00 pmd:RedundantFieldInitializer - Redundant-Field-Initializer 2016-02-18 08:40:19 +02:00
Crossy147
6ab9b36d59 issue javadocs changes 2016-02-17 19:35:10 +01:00
Crossy147
2fa705ab59 issue snapshot version fixed 2016-02-16 00:05:28 +01:00
Crossy147
8fabc861b3 pom.xml minor 2016-02-15 21:57:26 +01:00
Crossy147
53fdaba6c4 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2016-02-15 21:48:07 +01:00
Crossy147
8b625a8d3c issue minor revert 2016-02-15 20:54:55 +01:00
Crossy147
022ab28e20 issue diagrams and index added 2016-02-15 20:37:16 +01:00
Narendra Pathai
f1122f78e3 Added real life application to Command pattern 2016-02-15 18:21:34 +05:30
Narendra Pathai
cd077fa490 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into FactoryMethodChanges 2016-02-12 15:49:35 +05:30
Narendra Pathai
823dc6395f Merge pull request from DevFactory/release/Classes-without-public-constructors-should-be-final-fix-1
squid:S2974 - Classes without public constructors should be final
2016-02-12 15:44:31 +05:30
Narendra Pathai
221b71781a Resolved checkstyle audit error 2016-02-11 12:29:35 +05:30
Narendra Pathai
b5d4445d63 Made example App a bit easier to understand 2016-02-10 17:53:32 +05:30
Narendra Pathai
f64ba22c64 1) Removed warning from test case. 2) Made implementation of App more understandable. 2016-02-10 17:38:15 +05:30
Mohammed Ezzat
632174b6dc squid:S2974 - Classes without public constructors should be final 2016-02-09 17:19:31 +02:00
Ilkka Seppälä
57be8aa522 Merge pull request from DevFactory/release/The-members-of-an-interface-declaration-or-class-should-appear-in-a-pre-defined-order-fix-1
squid:S1213 - The members of an interface declaration or class should…
2016-02-08 20:40:16 +02:00
tmcconville
3cbb88e09c Create unit tests for Gateway API pattern 2016-02-07 17:05:45 -06:00
tmcconville
88c3b04eb3 Create API Gateway pattern 2016-02-07 17:05:33 -06:00
Mohammed Ezzat
9c5745763d squid:S1213 - The members of an interface declaration or class should appear in a pre-defined order 2016-02-06 01:10:56 +02:00
Ilkka Seppälä
1655f30845 Merge pull request from DevFactory/release/Methods-should-not-be-empty-fix-1
squid:S1186 - Methods should not be empty
2016-02-05 21:07:57 +02:00
Ilkka Seppälä
769a6206f2 Merge pull request from fluxw42/license_date_2016
Update license year from 2014 to range '2014-2016'
2016-02-05 21:07:02 +02:00
Ilkka Seppälä
9b6517453f Merge pull request from JuhoKang/master
Value object pattern 
2016-02-05 21:04:21 +02:00
Mohammed Ezzat
df4a40fc13 squid:S1186 - Methods should not be empty 2016-02-03 21:51:40 +02:00
JuhoKang
83533543e6 format code 2016-02-03 23:38:13 +09:00
JuhoKang
f71e186959 Fixed descriptions in code. 2016-02-03 23:33:40 +09:00
JuhoKang
db2140ecc9 updated child and parent pom 2016-02-03 23:02:27 +09:00
JuhoKang
049841298e deleted the change in parent pom 2016-02-03 22:59:15 +09:00
JuhoKang
1e5cbe1f76 Merge remote-tracking branch 'upstream/master' 2016-02-03 22:49:59 +09:00
Jeroen Meulemeester
53cc97e9d0 Update license year from 2014 to range '2014-2016' 2016-02-03 07:15:19 +01:00
Ilkka Seppälä
33224dd7d7 Prepare for next development iteration 2016-02-02 22:14:20 +02:00
Ilkka Seppälä
4f56f7b097 Achieved milestone 1.10.0 2016-02-02 22:11:38 +02:00
Ilkka Seppälä
e25cbad811 Merge pull request from mikulucky/master
Feature Toogle PR
2016-02-02 22:02:15 +02:00
Markus Moser
6caea8557b added missing space, 'cause website didnt display correctly 2016-02-02 17:31:12 +01:00
JuhoKang
d8378915a1 pom.xml change to fit upstream 2016-02-02 08:02:38 +09:00
JuhoKang
0e7fae21c3 Edit pom.xml 2016-02-02 07:48:43 +09:00
JuhoKang
3ef464986c Merge remote-tracking branch 'upstream/master', fixed f-c index properly 2016-02-02 07:35:06 +09:00
Ilkka Seppälä
e05592b522 Merge pull request from DevFactory/release/Append-Character-With-Char-fix-1
pmd:AppendCharacterWithChar - Append Character With Char
2016-02-01 22:28:34 +02:00
Ilkka Seppälä
f08af14555 Merge pull request from DevFactory/release/The-diamond-operator-should-be-used-fix-1
squid:S2293 - The diamond operator should be used
2016-02-01 22:26:43 +02:00
Joseph McCarthy
c7f4311706 Clean up 2016-02-01 18:57:05 +00:00
Joseph McCarthy
37da470178 Finish Readme 2016-02-01 18:45:54 +00:00
Mohammed Ezzat
7adefc89ba pmd:AppendCharacterWithChar - Append Character With Char 2016-02-01 04:20:52 +02:00
Joseph McCarthy
b27d6dff66 Merge branch 'master' of github.com:mikulucky/java-design-patterns
terns
Update
2016-01-31 23:28:28 +00:00
Joseph McCarthy
bf5ba44260 add App.java 2016-01-31 23:24:35 +00:00
Joseph McCarthy
8603333e5d Adding Class Diagram 2016-01-31 14:10:34 +00:00
Joseph McCarthy
7cc93de672 Merged Remote Master and resolved conflicts 2016-01-31 13:58:00 +00:00
Joseph McCarthy
c2e750aca1 finished method javadocs 2016-01-31 13:46:34 +00:00
Ilkka Seppälä
59c32d3937 Add tests that run the examples 2016-01-31 12:09:09 +02:00
Ilkka Seppälä
dc4f07eb81 Merge pull request from mikulucky/MIT-Source
Pull Request for adding License Plugin and Generate 
2016-01-30 15:10:42 +02:00
Ilkka Seppälä
d24a12a9b2 Merge pull request from DevFactory/release/Local-Variables-should-not-be-declared-and-then-immediately-returned-or-thrown-fix-1
squid:S1488 - Local Variables should not be declared and then immedia…
2016-01-30 14:42:05 +02:00
Ilkka Seppälä
62b2f8e9a4 Merge pull request from DevFactory/release/Consecutive-Appends-Should-Reuse-fix-1
pmd:ConsecutiveAppendsShouldReuse - Consecutive Appends Should Reuse
2016-01-30 14:37:18 +02:00
Mohammed Ezzat
409ff027b8 squid:S2293 - The diamond operator should be used 2016-01-29 07:33:34 +02:00
Joseph McCarthy
98326a1e5e Start Adding Java docs 2016-01-28 21:14:40 +00:00
JuhoKang
d3eb8a2ef2 Added comments in the code. modified index.md 2016-01-29 00:53:27 +09:00
JuhoKang
083065ba93 Added index.md
Added index.md with explanation which seems a little bit short of detail.
Fixed the directory of the files.
2016-01-28 23:33:46 +09:00
JuhoKang
cca40a543a Added Code 2016-01-28 22:39:50 +09:00
Joseph McCarthy
3d95696078 Added license to all files using plugin 2016-01-27 22:20:42 +00:00
Joseph McCarthy
321f5d6c5a Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into MIT-Source 2016-01-27 22:15:15 +00:00
Joseph McCarthy
7b61395bc1 Add Plugin for Auto License 2016-01-27 22:14:28 +00:00
Narendra Pathai
ab2aad3226 Work on , moved pattern specific references to respective patterns. And removed credits section from Home page. 2016-01-27 12:55:59 +05:30
Mohammed Ezzat
4e40cc3888 squid:S1488 - Local Variables should not be declared and then immediately returned or thrown 2016-01-27 02:45:39 +02:00
Joseph McCarthy
77e14f0069 Add tests for Properties 2016-01-26 23:38:28 +00:00
Joseph McCarthy
4a49f82f23 add general boolean method to services for feature status. Change user.toString 2016-01-26 21:18:47 +00:00
Joseph McCarthy
ba1d3a0fbf Added Configuration Based Example of Feature Toggle 2016-01-26 21:08:28 +00:00
Joseph McCarthy
d627b7af6b Moved Tests to the correct area 2016-01-26 20:24:43 +00:00
Joseph McCarthy
91b2379fd0 Fixed CheckStyle Issues 2016-01-26 19:20:28 +00:00
Joseph McCarthy
32f9cf3ab1 Some clean up and show the difference between paid and free a bit more. 2016-01-26 18:58:35 +00:00
Joseph McCarthy
a1ede8980f Added WelcomeMessage Service and Tests for tier example of featureToggle 2016-01-26 18:49:25 +00:00
Joseph McCarthy
72733acfc6 added usergroup for version of feature toggle 2016-01-26 18:41:08 +00:00
Mohammed Ezzat
d00bfae5ee pmd:ConsecutiveAppendsShouldReuse - Consecutive Appends Should Reuse 2016-01-26 19:58:45 +02:00
Joseph McCarthy
0b834128b9 Add Blank index.md 2016-01-25 21:29:05 +00:00
Joseph McCarthy
89e0e3e73e Remove generated copyright banner 2016-01-25 21:16:35 +00:00
Joseph McCarthy
d7526fc7c0 Add maven model for feature toggle design pattern 2016-01-25 21:14:24 +00:00
Joseph McCarthy
cf10bd1d05 Add maven model for feature toggle design pattern 2016-01-25 21:11:26 +00:00
Joseph McCarthy
5ad99be224 Add maven model for feature toggle design pattern 2016-01-25 21:10:58 +00:00
JuhoKang
64b89ecb59 Create project for value-object pattern 2016-01-23 10:06:57 +09:00
NooBxGockeL
1a55f3a420 Work on : More descriptive Tags
* Added the full name for Apache Camel, including the trademark symbol for clarity among other things named "Camel" and to indicate that this is a 3rd party software
2016-01-19 21:28:54 +01:00
Kamil Pietruszka
10bbf988ea issue factory kit pattern introduced 2016-01-17 13:47:44 +01:00
Ilkka Seppälä
bd82387fc1 Merge pull request from azhuzhu/master
Fix the wrong uml .png name in decorator
2016-01-14 19:47:09 +02:00
Ilkka Seppälä
3398badd30 Merge pull request from hoswey/master
fix issue  ReaderWriterLock unit tests fail on CI
2016-01-14 19:42:46 +02:00
Yuming Zhu
033dce8387 Fix the wrong uml .png name in decorator 2016-01-15 00:56:46 +08:00
hoswey
e95cfe9292 fix issue ReaderWriterLock unit tests fail on CI 2016-01-13 09:35:31 +08:00
Ilkka Seppälä
150c4e0d5d Ignore rest of ReaderWriterLock tests with intermittent failures 2016-01-12 21:16:39 +02:00
Ilkka Seppälä
c8db19efe2 Ignore another test with intermittent failures until fixed 2016-01-12 21:08:10 +02:00
Ilkka Seppälä
2fec4f891b Ignore test with intermittent failures until fixed 2016-01-12 20:57:36 +02:00
Ilkka Seppälä
adf131b784 Merge pull request from hoswey/master
implements the  reader writer lock
2016-01-12 20:15:22 +02:00
hoswey
77d45c35e0 implements the reader writer lock, fix the problem of review 2016-01-10 21:23:52 +08:00
hoswey
2f84369003 Merge remote-tracking branch 'upstream/master' 2016-01-09 22:26:18 +08:00
Ilkka Seppälä
83f1ac7489 Update dependencies 2016-01-07 21:41:45 +02:00
Ilkka Seppälä
03e187743c Merge pull request from tomroy/master
Decorator pattern: SmartTroll should be SmartHostile 
2016-01-06 19:44:26 +02:00
Tom.TH.Lin
bd83fa28bb Correct method name and cleanup etc folder 2016-01-07 00:34:33 +08:00
Tom.TH.Lin
30ca1ea1fb Decorator pattern: SmartTroll should be SmartHostile 2016-01-04 23:07:33 +08:00
Markus
4c5f9ae44c Merge pull request from fluxw42/issue-238
Use headings instead of bold text in index.md 

Script used to do it: https://gist.github.com/fluxw42/464820d08e3b567fda48
2016-01-04 02:15:37 +01:00
Jeroen Meulemeester
3d642cdad7 Use headings instead of bold text in index.md 2016-01-03 21:14:30 +01:00
Ilkka Seppälä
b6beffec2e Merge pull request from genericmethod/master
 Event-driven Architecture
2016-01-03 14:50:46 +02:00
Chris Farrugia
1987bdb962 Merge pull request from mikulucky/master
Class Diagram for EDA
2016-01-03 12:20:35 +00:00
Joseph McCarthy
bea1a0d6d9 Revert "Revert "Add class diagram for and to be included in PR ""
This reverts commit 0f75a0e239.
2016-01-03 00:55:04 +00:00
Joseph McCarthy
d6719729b9 Revert "Revert "Merge remote-tracking branch 'origin/master'""
This reverts commit 03f0a2112b.
2016-01-03 00:54:49 +00:00
Joseph McCarthy
03f0a2112b Revert "Merge remote-tracking branch 'origin/master'"
This reverts commit 248ea5191a, reversing
changes made to 02bd15db90.
2016-01-03 00:52:56 +00:00
Joseph McCarthy
0f75a0e239 Revert "Add class diagram for and to be included in PR "
This reverts commit 0c062d3f55.
2016-01-03 00:52:24 +00:00
Joseph McCarthy
0c062d3f55 Add class diagram for and to be included in PR 2016-01-03 00:01:43 +00:00
Joseph McCarthy
248ea5191a Merge remote-tracking branch 'origin/master' 2016-01-02 23:59:47 +00:00
Joseph McCarthy
39b183d569 Merge pull request from genericmethod/master
Pull
2016-01-02 23:58:43 +00:00
Joseph McCarthy
02bd15db90 Merge remote-tracking branch 'iluwatar/master' 2016-01-02 18:39:58 +00:00
Ilkka Seppälä
317a599c3b Merge pull request from mikulucky/master
Provide a simple example for Callback Pattern using Lambdas
2016-01-02 19:04:43 +02:00
cfarrugia
7176b86146 Event Driven Architecture
bumped up version to 1.10
2016-01-02 14:05:36 +01:00
cfarrugia
2ea9bfef19 Event Driven Architecture
Fixed PMD errors
2016-01-02 14:04:07 +01:00
cfarrugia
40042ae392 Merge remote-tracking branch 'iluwatar/master'
# Conflicts:
#	pom.xml
2016-01-02 11:48:01 +01:00
Joseph McCarthy
e25ef1b0f8 Check Style fixes 2016-01-02 00:54:26 +00:00
Joseph McCarthy
ca4a4ec07b Created a Lambdas example for the callback pattern, using the same output of the traditional version. Have also added another unit test for issue 2016-01-01 23:41:56 +00:00
Ilkka Seppala
e0e51324db Set version number for next development iteration 2016-01-01 20:39:20 +02:00
Ilkka Seppala
e4458c1b17 Achieved milestone 1.9.0 2016-01-01 20:37:50 +02:00
Ilkka Seppälä
30e09a8dd9 Merge pull request from fluxw42/master
Add unit tests for remaining patterns
2016-01-01 18:24:58 +02:00
Ilkka Seppälä
f987c7253b Merge pull request from mikulucky/master
Delegation Pattern
2016-01-01 16:49:01 +02:00
Joseph McCarthy
ad714294dd Clean up javaDocs on Printer.java 2015-12-30 20:08:52 +00:00
Joseph McCarthy
623c2081cd Update App.java to have more information on the pattern 2015-12-30 20:07:42 +00:00
Jeroen Meulemeester
542a832a66 Added tests for twin pattern 2015-12-30 20:55:22 +01:00
Jeroen Meulemeester
444eb07e26 Added tests for tolerant-reader pattern 2015-12-30 20:55:22 +01:00
Jeroen Meulemeester
fd8c05846f Added tests for thread-pool pattern
Fixed concurrency problem in id generation of Task
2015-12-30 20:55:22 +01:00
Jeroen Meulemeester
47709e24b9 Added tests for template-method pattern 2015-12-30 20:55:22 +01:00
Jeroen Meulemeester
09d3a82884 Added tests for visitor pattern 2015-12-30 20:55:22 +01:00
Jeroen Meulemeester
997bfba3b2 Added tests for strategy pattern 2015-12-30 20:55:22 +01:00
Jeroen Meulemeester
6326c1742d Added tests for step-builder pattern 2015-12-30 20:55:22 +01:00
Jeroen Meulemeester
2e2707862a Fixed checkstyle code quality issues 2015-12-30 20:55:21 +01:00
Jeroen Meulemeester
1d9aff4071 Added tests for state pattern 2015-12-30 20:55:21 +01:00
Jeroen Meulemeester
5611f26c77 Added tests for specification pattern 2015-12-30 20:55:21 +01:00
Jeroen Meulemeester
d0cdf84936 Added tests for singleton pattern 2015-12-30 20:55:21 +01:00
Jeroen Meulemeester
a375b2d28b Added tests for service-locator pattern
Fix NPE when requested service is unknown
2015-12-30 20:55:21 +01:00
Jeroen Meulemeester
fcfdbe71f5 Added tests for service-layer pattern 2015-12-30 20:55:21 +01:00
Jeroen Meulemeester
52c483f1d0 Added tests for servant pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
c72faeb67e Added tests for resource-acquisition-is-initialization pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
299d612b9b Added tests for proxy pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
9d4c3154b1 Added tests for prototype pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
a3b1265921 Added tests for property pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
dca68511e8 Added tests for producer-consumer pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
42a1dc69ca Added tests for private-class-data pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
47e1cd710c Added tests for poison-pull pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
b3d1c2b2ed Added tests for generic observer pattern 2015-12-30 20:46:40 +01:00
Jeroen Meulemeester
3e20a2afa8 Added tests for observer pattern 2015-12-30 20:46:39 +01:00
Jeroen Meulemeester
4c938ab8a5 Added tests for object-pool pattern 2015-12-30 20:46:39 +01:00
Jeroen Meulemeester
8f6f171a3f Added tests for null-object pattern 2015-12-30 20:46:39 +01:00
Jeroen Meulemeester
b4dcec45ef Added tests for multiton pattern 2015-12-30 20:46:39 +01:00
Joseph McCarthy
dec5ff22fc Update index.md 2015-12-30 18:26:32 +00:00
Joseph McCarthy
7b323e9cb4 Updated Class Diagram 2015-12-30 17:55:42 +00:00
Ilkka Seppälä
a0af0a1a76 Merge pull request from DevFactory/utility-classes-should-not-have-public-constructors-fix-3
Utility classes should not have public constructors
2015-12-30 19:55:25 +02:00
Ilkka Seppälä
7c6e1fc3d8 Merge pull request from DevFactory/code-quality-fix-5
Code quality fixes
2015-12-30 19:47:19 +02:00
Joseph McCarthy
45cecf68c4 Updated Class Diagram 2015-12-30 17:34:50 +00:00
Joseph McCarthy
d7580f5530 Review Comments 2015-12-30 16:56:47 +00:00
Joseph McCarthy
58b8a06561 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns
* 'master' of https://github.com/iluwatar/java-design-patterns:
  Define checkstyle suppression filter location in maven plugin configuration
2015-12-30 16:17:07 +00:00
Ilkka Seppala
befe509582 Define checkstyle suppression filter location in maven plugin configuration 2015-12-30 17:58:03 +02:00
Joseph McCarthy
17b889c31d Update to match checkStyle rules added for test packages 2015-12-29 22:07:52 +00:00
Joseph McCarthy
52192de909 Merge commit '8b020837eaacc9ed4497f3c2461984935314bfb8' into add-delegation-pattern
* commit '8b020837eaacc9ed4497f3c2461984935314bfb8':
  Checkstyle corrections
  Checkstyle configuration to look into test classes too
  Rephrase readme title
  Corrected difficulty for Visitor 
  Add performance tag to relevant patterns 
  Categorize and tag all patterns 
  Update CONTRIBUTING.MD
  Update CONTRIBUTING.MD
  add-contributing
2015-12-29 22:00:56 +00:00
Ilkka Seppala
8b020837ea Checkstyle corrections 2015-12-29 21:34:27 +02:00
Ilkka Seppala
b369812511 Checkstyle configuration to look into test classes too 2015-12-29 13:27:49 +02:00
Joseph McCarthy
52d6e20ad9 Readd File to Index#324 2015-12-28 22:13:05 +00:00
Joseph McCarthy
749880e3b9 Messed up indexes 2015-12-28 22:12:11 +00:00
Joseph McCarthy
41593774c6 CheckStyle reporting strange error about classname, suspect caching, forcing a clean build 2015-12-28 21:56:41 +00:00
Joseph McCarthy
0bc722f797 Fix CheckStyle 2015-12-28 20:34:28 +00:00
Joseph McCarthy
fcadb223ce Merge branch 'add-delegation-pattern'
* add-delegation-pattern:
  Add java documentation 
  Populate the index.md for the delegate module 
  Move App.java to correct Package 
  Move App.java to correct Package 
  Generic For AbstractPrinterController 
  Generate UML for delegation pattern
  Add simple tests for delegate pattern 
  Make AppTest.java match other patterns and update AppTest.java to match other patterns 
  3am Code is starting to show. Get this build working. 
  Created a unit test for build, added junit to pom for delegation maven module. 
  Add template index.md for population later 
  Added skeleton code for delegation pattern 
  Create maven module for delegation pattern 
2015-12-28 20:01:14 +00:00
Joseph McCarthy
c842f88eb7 Add java documentation 2015-12-28 19:23:00 +00:00
Joseph McCarthy
6d516d5124 Populate the index.md for the delegate module 2015-12-28 18:16:58 +00:00
Ilkka Seppälä
9544dd321a Rephrase readme title 2015-12-28 20:09:53 +02:00
Ilkka Seppala
d623e9c8fd Corrected difficulty for Visitor 2015-12-28 19:52:10 +02:00
Ilkka Seppala
e27de33f75 Add performance tag to relevant patterns 2015-12-28 16:07:43 +02:00
Ilkka Seppala
7ac7e3b097 Categorize and tag all patterns 2015-12-28 15:52:44 +02:00
Ilkka Seppälä
fefb51c46e Merge pull request from zafarella/patch-1
add-contributing
2015-12-28 09:34:14 +02:00
Zafar Khaydarov
58547fae8f Update CONTRIBUTING.MD
real fix :)
2015-12-27 22:44:15 -05:00
Zafar Khaydarov
30676f8d4f Update CONTRIBUTING.MD
fix the typo
2015-12-27 22:42:42 -05:00
Joseph McCarthy
483db04cef Move App.java to correct Package 2015-12-27 20:12:04 +00:00
Joseph McCarthy
fac10dc454 Move App.java to correct Package 2015-12-27 20:10:48 +00:00
Joseph McCarthy
982f9f5e31 Generic For AbstractPrinterController 2015-12-27 20:09:33 +00:00
Joseph McCarthy
74d1823078 Merge pull request from fluxw42/add-delegation-pattern
Generate UML for delegation pattern
2015-12-27 20:03:42 +00:00
Ilkka Seppala
f59f18091e Remove Coverity scan 2015-12-27 21:23:09 +02:00
Ilkka Seppala
5f033be54f Fix PMD violations 2015-12-27 21:21:57 +02:00
Ilkka Seppala
df911baf36 Added maven pmd plugin and configured it to fail build when violations are found 2015-12-27 21:21:31 +02:00
Jeroen Meulemeester
32e7181478 Generate UML for delegation pattern 2015-12-27 18:13:34 +01:00
Kirill Vlasov
c8a750df49 Fixing squid:S1118 - Utility classes should not have public constructors 2015-12-27 21:17:13 +05:00
Kirill Vlasov
191078735f Fixing squid:S1698 - Objects should be compared with equals() and squid:HiddenFieldCheck - Local variables should not shadow class fields 2015-12-27 21:12:35 +05:00
Zafar Khaydarov
fa6a6006c3 add-contributing
so github will show link whenever PR are made
2015-12-27 11:03:21 -05:00
Joseph McCarthy
a49dbefb56 Add simple tests for delegate pattern 2015-12-27 14:10:49 +00:00
Joseph McCarthy
fb0617e9c5 Make AppTest.java match other patterns and update AppTest.java to match other patterns 2015-12-27 13:59:50 +00:00
Joseph McCarthy
84fd2348ea 3am Code is starting to show. Get this build working. 2015-12-26 23:02:45 +00:00
Joseph McCarthy
f0ff8ad4b3 Created a unit test for build, added junit to pom for delegation maven module. 2015-12-26 22:55:12 +00:00
Joseph McCarthy
c3184255bf Add template index.md for population later 2015-12-26 22:29:45 +00:00
Joseph McCarthy
bdacfe30c1 Added skeleton code for delegation pattern 2015-12-26 22:20:53 +00:00
Joseph McCarthy
30363cbb7f Create maven module for delegation pattern 2015-12-26 22:05:12 +00:00
Ilkka Seppälä
3d8c64d76d Merge pull request from DevFactory/dead-stores-fix-1
Fixing squid:S1854 - Dead stores should be removed
2015-12-26 13:38:16 +02:00
Ilkka Seppala
78fcd63271 Merge branch 'fluxw42-master' 2015-12-26 13:07:37 +02:00
Ilkka Seppala
30bc25b5bf Merge branch 'master' of https://github.com/fluxw42/java-design-patterns into fluxw42-master
Conflicts:
	monostate/src/main/java/com/iluwatar/monostate/LoadBalancer.java
2015-12-26 12:36:38 +02:00
Ilkka Seppälä
6b1356a160 Add Gitter link to README.md 2015-12-26 12:12:33 +02:00
hoswey
3731d26f6d implants the reader writer lock 2015-12-26 14:17:24 +08:00
Ilkka Seppala
cec9a99410 Adjust checkstyle rules. Make checkstyle fail the build when violations are found. Correct all current checkstyle violations. 2015-12-25 23:49:28 +02:00
Ilkka Seppala
9fbb085985 Checkstyle fails the build when violations are detected 2015-12-23 13:20:39 +02:00
Kirill Vlasov
6e496e7c86 Fixing squid:S1854 - Dead stores should be removed 2015-12-23 13:41:38 +05:00
Jeroen Meulemeester
e3e0e32e92 Fixed failing unit test
LoadBalancer has several static fields, this could cause problems since
JUnit tests are executed concurrently.
2015-12-21 14:35:36 +01:00
Jeroen Meulemeester
531158c836 Added tests for monostate pattern 2015-12-21 13:29:25 +01:00
Jeroen Meulemeester
6fe01e73b2 Add additional tests for model-view-presenter pattern 2015-12-21 12:17:20 +01:00
Jeroen Meulemeester
69c9374669 Added tests for model-view-controller pattern 2015-12-20 14:31:36 +01:00
Jeroen Meulemeester
a57a71b09c Added tests for memento pattern 2015-12-20 10:39:02 +01:00
Jeroen Meulemeester
719f80a0d6 Added tests for mediator pattern 2015-12-20 00:00:07 +01:00
Jeroen Meulemeester
2c82bd9450 Added tests for lazy-loading pattern 2015-12-19 21:44:50 +01:00
Jeroen Meulemeester
5948a82cf2 Added tests for layers pattern 2015-12-19 21:44:50 +01:00
Markus
a0151826ad Changed page-index to 1 for a better structured navbar 2015-12-19 17:35:49 +01:00
Ilkka Seppälä
33fe90d177 Merge pull request from fluxw42/master
Added some more JUnit tests
2015-12-15 18:48:31 +02:00
Jeroen Meulemeester
25cacdbbc9 Added tests for iterator pattern 2015-12-14 15:14:48 +01:00
Jeroen Meulemeester
323e4c8751 Added tests for interpreter pattern 2015-12-14 12:46:07 +01:00
Jeroen Meulemeester
de78490d29 Added tests for intercepting-filter pattern 2015-12-13 15:18:13 +01:00
Jeroen Meulemeester
9059d2b96c Added proper tests for front-controller pattern 2015-12-13 13:58:39 +01:00
Jeroen Meulemeester
dbca06a9e7 Added proper tests for half-sync-half-async 2015-12-13 13:04:17 +01:00
Jeroen Meulemeester
ca14e8ddad Add proper tests for flyweight pattern 2015-12-13 11:42:25 +01:00
Jeroen Meulemeester
3dc370e2d1 Add proper tests for flux pattern 2015-12-12 22:43:47 +01:00
Jeroen Meulemeester
4181514c65 Add proper tests for fluent-interface pattern and fixed a little bug 2015-12-12 20:16:10 +01:00
Jeroen Meulemeester
df69a8f986 Add proper tests for execute-around pattern 2015-12-12 20:14:59 +01:00
Jeroen Meulemeester
885d5bb7dd Add proper unit tests for event-aggregator pattern 2015-12-12 20:13:25 +01:00
Ilkka Seppälä
1b74e0ff67 Merge pull request from fluxw42/master
Added more JUnit tests
2015-12-12 09:44:41 +02:00
Jeroen Meulemeester
94f80d1868 Add proper unit tests for composite pattern 2015-12-11 20:24:56 +01:00
Jeroen Meulemeester
c837ffe234 Add proper unit tests for double-dispatch pattern 2015-12-11 20:24:56 +01:00
Jeroen Meulemeester
2edc1898b1 Add proper unit tests for double-checked-locking pattern 2015-12-11 20:24:56 +01:00
Jeroen Meulemeester
29fc56002a Add proper unit tests for dependency-injection pattern 2015-12-11 20:24:56 +01:00
Jeroen Meulemeester
0643289c74 Dependency org.mockito:mockito-core should have scope 'test' 2015-12-11 20:24:56 +01:00
Jeroen Meulemeester
2c0a5e8703 Add proper unit tests for facade pattern 2015-12-11 20:24:56 +01:00
Ilkka Seppälä
a3372febd0 Merge pull request from Deses/master
Just  Just a quick fix for the Front-controller pattern.
2015-12-11 20:46:18 +02:00
Carlos Romero
7df65adbfc Just Just a quick fix for the Front-controller pattern. 2015-12-11 13:54:32 +01:00
Ilkka Seppälä
d7dd8d42af Merge pull request from fluxw42/master
Add proper unit tests for chain, bridge and builder pattern 
2015-12-09 20:23:51 +02:00
Ilkka Seppälä
4e7a8fdaca Merge pull request from iluwatar/fstrategy
Functional approach to Strategy pattern 
2015-12-08 23:27:01 +02:00
Ilkka Seppala
6e59d9554f Functional approach to Strategy pattern 2015-12-08 23:25:05 +02:00
Ilkka Seppälä
e85308fbc4 Merge pull request from JuhoKang/adapterdev
Attempt to solve issue 
2015-12-08 20:53:15 +02:00
Jeroen Meulemeester
10a94cc91c Add proper unit tests for decorator pattern 2015-12-07 20:37:27 +01:00
JuhoKang
e2d8079b36 Fixed code to follow coding conventions 2015-12-07 10:35:32 +09:00
Jeroen Meulemeester
8367c83aca Add proper unit tests for bridge pattern 2015-12-06 23:48:48 +01:00
Jeroen Meulemeester
875e5b872c Add proper unit tests for builder pattern 2015-12-06 23:14:07 +01:00
Jeroen Meulemeester
1fa617d08d Add proper unit tests for chain pattern 2015-12-06 22:58:16 +01:00
Ilkka Seppala
6c1f025d0f Apply code formatting rules to async-method-invocation example tests 2015-12-06 21:42:06 +02:00
Ilkka Seppälä
601964a2d1 Merge pull request from fluxw42/master
Add proper unit tests for async-method-invocation 
2015-12-06 21:33:03 +02:00
Jeroen Meulemeester
1884df525b Add proper unit tests for async-method-invocation 2015-12-06 13:43:01 +01:00
Ilkka Seppala
507b89d5e4 Apply project coding conventions to Repository example 2015-12-05 21:26:30 +02:00
Ilkka Seppälä
02d6754804 Merge pull request from neonds/spring-annotation-config
Annotation Config was added.
2015-12-05 21:12:12 +02:00
Ilkka Seppala
e709a196bd Set version number for next development iteration 2015-12-02 23:26:07 +02:00
Ilkka Seppala
f018d13c39 Set version number for monthly release 2015-12-02 23:21:44 +02:00
JuhoKang
33b41f872e The new java files was not added.. 2015-12-02 18:45:08 +09:00
cfarrugia
898f3a428c Event Driven Architecture
Fixed a typo in index.md
2015-12-02 01:43:34 +01:00
cfarrugia
0b46a9985d Event Driven Architecture
Updated index.md with eda uses
2015-12-02 01:39:20 +01:00
cfarrugia
2aa20b7445 Event Driven Architecture
Adds various changes including :
- Fixes to Javadoc
2015-12-01 23:33:26 +01:00
cfarrugia
cfb0fafc7d Event Driven Architecture
Adds various changes including :
- Fixes to Javadoc
- Test refactoring and improvements
- Refactored EventDispatcher to be immutable
- Removed DynamicRouter interface since it not needed
- Renamed Channel to a more appropriate name - Handler
2015-12-01 23:30:01 +01:00
JuhoKang
119d264779 issue 2015-12-01 16:00:31 +09:00
cfarrugia
9e857d7dd6 Event Driven Architecture
Fixed javadoc
2015-11-28 19:05:23 +01:00
cfarrugia
d9a1d1cef9 Event Driven Architecture
Adds unit test to assert and verify pattern event get type behaviour.
Also added unit test comments.
2015-11-28 17:58:32 +01:00
cfarrugia
3ad36020aa Event Driven Architecture
Adds unit test to assert and verify pattern behaviour
2015-11-28 17:25:15 +01:00
cfarrugia
e1c0731f7e Event Driven Architecture
Adds more Javadoc and fixes checkstyle issues.
2015-11-28 15:03:22 +01:00
cfarrugia
b8b94b697a Event Driven Architecture
Adds more Javadoc
2015-11-28 13:12:16 +01:00
cfarrugia
fc70a706c6 Event Driven Architecture
Adds module to the root pom.xml
Fixes indentation
2015-11-28 10:57:00 +01:00
neonds
9a85dfe9df Annotation Config was added. Now AppConfig contains a Main Method (same logic in App.java) to execute 2015-11-27 21:23:55 -06:00
Ilkka Seppälä
5bec63659f Merge pull request from hoswey/master
Fix  Repository vs DAO
2015-11-28 00:09:27 +02:00
hoswey
9d4fff6029 Fix Repository vs DAO 2015-11-27 11:22:33 +08:00
chris
321e9d4191 Event Driven Architecture
- added class diagram
- added more comments
2015-11-23 11:20:20 +01:00
chris
b4aeca3aa0 Event Driven Architecture
- removed unused imports
2015-11-23 00:04:44 +01:00
chris
3ef0921f20 Event Driven Architecture
- refactored and moved around some classes
2015-11-23 00:02:58 +01:00
chris
eb396217d0 Event Driven Architecture
- initial commit includes a simple and advanced example of Event-driven architecture
2015-11-22 19:40:07 +01:00
Ilkka Seppälä
092d48d150 Merge pull request from DevFactory/release1
Unit tests for adapter, business-delegate, factory-method and command modules
2015-11-22 08:44:13 +02:00
mfarid
6b99f2669e Added capability for test coverage report generation and steps to do so. 2015-11-22 05:47:36 +05:30
mfarid
ced317bc9d Added UnitTest cases for factory method. 2015-11-22 05:46:14 +05:30
mfarid
e5614e5a20 Added UnitTest cases for command. 2015-11-22 05:45:45 +05:30
mfarid
012b638023 Added UnitTest cases for business delegate. 2015-11-22 05:45:14 +05:30
mfarid
b577890db4 Added UnitTest cases for adapter. 2015-11-22 05:44:45 +05:30
Ilkka Seppala
8ba0192864 Add EIP tag to relevant patterns 2015-11-21 16:34:59 +02:00
Ilkka Seppälä
899b9617c9 Merge pull request from iluwatar/JaXt0r-publish-subscribe
Jaxt0r publish subscribe
2015-11-21 16:10:34 +02:00
Ilkka Seppala
d0fca6d318 Improve the example and documentation 2015-11-21 16:05:55 +02:00
Ilkka Seppala
7885380633 Apply Google coding conventions 2015-11-21 15:12:31 +02:00
Ilkka Seppala
230c02fb24 Fix spelling 2015-11-21 15:09:23 +02:00
Ilkka Seppala
b97e9207a7 Update version number for Publish-Subscribe 2015-11-21 15:03:27 +02:00
Ilkka Seppala
8519e13de6 Merge branch 'publish-subscribe' of https://github.com/JaXt0r/java-design-patterns into JaXt0r-publish-subscribe
Conflicts:
	pom.xml
2015-11-21 14:55:02 +02:00
Ilkka Seppälä
ba3f583467 Merge pull request from hoswey/master
implements Twin design pattern 
2015-11-16 21:09:41 +02:00
hoswey
142274f3f7 implements Twin design pattern , add credit and rephrase the comments 2015-11-16 10:01:03 +08:00
Ilkka Seppälä
5b06c52fff Merge pull request from tainarareis/abstract-factory
Issue : Added main method in Abstract Factory Example
2015-11-14 21:33:48 +02:00
Ilkka Seppälä
033f8e740d Merge pull request from l-cortese/master
log4j.xml relocated and excluded from JAR
2015-11-14 21:19:50 +02:00
tainarareis
34528173b7 Issue : Added main method in Abstract Factory Example 2015-11-14 16:48:19 -02:00
hoswey
fdbfa9e8ee implements Twin design pattern 2015-11-14 17:38:35 +08:00
Luigi Cortese
bf65168776 corrected typos in the comments 2015-11-13 22:35:30 +01:00
Luigi Cortese
043a610754 log4j.xml relocated due to visibility issues and excluded from generated
JAR. pom.xml formatted according to coding conventions
2015-11-13 18:34:10 +01:00
Ilkka Seppälä
27199325ec Merge pull request from hoswey/master
correct the package name for producer-consumer test folder
2015-11-07 11:48:51 +02:00
hoswey
960b568fbb correct the package name for producer-consumer test folder 2015-11-07 15:51:16 +08:00
Ilkka Seppala
c02e65fa3a Added alias names for GOF patterns 2015-11-04 21:13:32 +02:00
Ilkka Seppälä
fe63c9cec4 Merge pull request from ankurkaushal/master
Reformat according to google style guide
2015-11-02 21:39:17 +02:00
Ilkka Seppälä
7e4f04602e Merge pull request from l-cortese/master
Corrected Freddy's last name
2015-11-02 21:36:20 +02:00
Ankur Kaushal
306b1f3d31 Reformat rest of the design patterns - Issue 2015-11-01 21:29:13 -05:00
Ankur Kaushal
449340bd2b Reformat business-delegate, callback, chain, command, composite, dao, decorator & dependency-injection patterns. 2015-11-01 18:48:43 -05:00
Ankur Kaushal
3af06a3a3a Reformat builder pattern - issue 2015-11-01 18:03:29 -05:00
Ankur Kaushal
e7b6542134 Reformat bridge design pattern - Issue 2015-11-01 17:43:54 -05:00
Ankur Kaushal
16a8c85af6 Reformat Async Method Invocation - Issue 2015-11-01 17:33:25 -05:00
Ankur Kaushal
95c16200e7 Reformat Adapter Pattern - Issue 2015-11-01 17:26:57 -05:00
Ankur Kaushal
c0c21ebd91 Reformat Abstract Factory - Issue 2015-11-01 17:18:39 -05:00
Luigi Cortese
25c1f87d46 Corrected Freddy's second name 2015-11-01 23:15:57 +01:00
Ilkka Seppala
c6ca80b25f Bump version number for the next development iteration 2015-11-01 22:22:31 +02:00
Ilkka Seppälä
a2dd87d28d Merge pull request from waisuan/master
Issue : Caching Patterns [new pattern]
2015-11-01 22:12:35 +02:00
waisuan
998ba7e6e0 Issue : Fixed HTML tags in comments 2015-11-02 02:11:58 +08:00
waisuan
6418a6c2b6 Issue : Fixed issues based on review remarks 2015-11-02 01:40:38 +08:00
waisuan
37cfa4b295 Merge remote-tracking branch 'upstream/master' 2015-11-02 01:38:37 +08:00
Ilkka Seppälä
7d3483daad Merge pull request from ankurkaushal/master
Reformat Code According to Google Style Guide 
2015-11-01 17:57:14 +02:00
Ankur Kaushal
44b7b94da6 Reformatting test case as well 2015-11-01 02:23:27 -05:00
Ankur Kaushal
87baa98d2b Reformat Code According to Google Style Guide 2015-11-01 02:05:54 -05:00
Ilkka Seppälä
3dc9b2f97e Merge pull request from hoswey/master
 implements producer-consumer
2015-10-31 19:02:03 +02:00
waisuan
d0f5009996 Issue : Changed DB to internal Java data structure to avoid compilation errors + decrease in code coverage 2015-10-29 00:57:41 +08:00
waisuan
9891c2e17b Issue #273:Caching Patterns [new pattern] 2015-10-28 23:55:47 +08:00
hongsw
07faa2f625 implements producer-consumer 2015-10-28 09:55:05 +08:00
Ilkka Seppälä
a869294851 Merge pull request from mafagafogigante/readme-warning-for-beginners
A Warning for beginners in the Readme.
2015-10-25 08:47:49 +02:00
JaXt0r
ac5c1967df - Publish Subscribe Channel realisation.Heavily based on iluwatars Message Channel implementation (). 2015-10-25 07:11:34 +01:00
Ilkka Seppälä
a2b8359ab5 Merge pull request from iamrichardjones/master
Add unit test to callback method
2015-10-20 23:37:39 +03:00
Richard Jones
21a4d7b4c9 Add unit test to show that the callback method is called. 2015-10-19 22:07:00 +01:00
Richard Jones
83c2fbdcd3 Add unit test to show that the callback method is called. 2015-10-19 22:06:35 +01:00
Ilkka Seppälä
8eff279233 Merge pull request from iamrichardjones/master
Update to singleton unit tests and lazy loading unit test
2015-10-19 21:21:45 +03:00
Ilkka Seppälä
b961c57919 Merge pull request from iluwatar/themoffster-master
Themoffster master - unit test improvements
2015-10-19 21:14:58 +03:00
Ilkka Seppala
b028f66b08 Removed properties 2015-10-19 21:01:41 +03:00
Ilkka Seppala
339db2a0bf Merge branch 'master' of https://github.com/themoffster/java-design-patterns into themoffster-master
Conflicts:
	dao/pom.xml
2015-10-19 20:44:46 +03:00
Ilkka Seppälä
9cbc4a20b9 Merge pull request from mkobit/double-checked-locking-executor-service-shutdown
Fix - Shutdown the ExecutorService in App so that the resources are c…
2015-10-14 20:10:46 +03:00
Mike Kobit
07a77ba11d Fix - Shutdown the ExecutorService in App so that the resources are collected and the process can finish
I ran App.main(String[] args) in the 'double-checked-locking' module and the process does not terminate. This is because the executor service still has open threads. I'm not sure how the JUnit tests are run, but it seems they are handling the leftover resources themselves.

Also, minor modifications to Inventory for final fields are used since there is no state change around them, and added some more meaningful printing so the example is more clearly demonstrated
2015-10-14 07:01:15 -05:00
Bernardo Sulzbach
e09dda6037 A Warning for beginners in the Readme. 2015-10-14 06:41:32 -03:00
Richard Jones
7ab799c452 Synchronise the list as multiple threads are calling it 2015-10-13 21:23:32 -03:00
Ilkka Seppälä
3c8b83748a Merge pull request from amit2103/master
MonoState Pattern
2015-10-13 20:03:45 +03:00
Richard Jones
5d970438bf Update comment 2015-10-12 05:22:09 -03:00
Richard Jones
0d068a35d8 Update comment 2015-10-12 05:21:33 -03:00
Richard Jones
64e3e1a9e8 For some reason it thinks there are two fields in the CI build. Making this more generic 2015-10-11 22:16:51 -03:00
Richard Jones
31e2940eb1 Remove error unit test so pull request can proceed. Will check this at at later date 2015-10-11 22:11:03 -03:00
Richard Jones
0107b24976 Fix unit test by makinig getField use the field name directly 2015-10-11 22:06:00 -03:00
Richard Jones
7cf5b32086 Add additional unit tests to show how lazy loading is working with reflection 2015-10-11 21:58:13 -03:00
Richard Jones
45b0ac386e Add additional unit tests to show that singletons can be created in single thread environment and multithread environment. Also add a test to demonstrate a whole with Singleton when instantiating using reflection
Add some logging. Tests pass locally but not on github?
2015-10-11 21:54:45 -03:00
Richard Jones
6ba7f5ea04 Add additional unit tests to show that singletons can be created in single thread environment and multithread environment. Also add a test to demonstrate a whole with Singleton when instantiating using reflection 2015-10-11 21:32:51 -03:00
amit2103
271ce09e26 Fixed POMS 2015-10-09 23:26:10 +05:30
amit2103
9d0673af0a Made changes according to feedback issue 2015-10-09 23:23:34 +05:30
amit2103
eb22febdfc Printing Server variables 2015-10-09 23:23:34 +05:30
amit2103
9a824c7d21 MonoState 2015-10-09 23:23:34 +05:30
amit2103
81b5bc99ce Update Pom.xml
Fixed Reference to Parent POM
2015-10-08 09:43:19 +05:30
amit2103
19f5966cb9 Added Comments and Feedback 2015-10-07 20:37:45 +05:30
amit2103
1e988c10f9 fixed merge conflict 2015-10-07 20:10:36 +05:30
amit2103
2c45f73254 MonoState 2015-10-04 03:12:51 +05:30
amit2103
c8fd9f3a0d Monostate pattern 2015-10-04 03:06:11 +05:30
Ilkka Seppala
0a9879a277 Improve Strategy Javadoc 2015-10-04 00:22:27 +03:00
Ilkka Seppala
2234a25c76 Improve State Javadoc 2015-10-04 00:19:34 +03:00
Ilkka Seppala
74e32259be Improve Service Locator Javadoc 2015-10-04 00:16:05 +03:00
Ilkka Seppala
8db2bb2ac8 Improve Servant Javadoc 2015-10-04 00:13:08 +03:00
Ilkka Seppala
c3a827b475 Improved Proxy Javadoc 2015-10-04 00:08:34 +03:00
Ilkka Seppala
9a4f83e7b8 Improve Prototype Javadoc 2015-10-04 00:04:12 +03:00
Ilkka Seppala
40e378c1f3 Improve Property Javadoc 2015-10-03 23:57:17 +03:00
Ilkka Seppala
98aa28d94e Improve Poison Pill Javadoc 2015-10-03 23:53:09 +03:00
Ilkka Seppala
4d1aae21f7 Improve Observer Javadoc 2015-10-03 23:48:51 +03:00
Ilkka Seppala
ca6bb7a3a8 Improve Memento Javadoc 2015-10-03 23:38:37 +03:00
Ilkka Seppala
fc66ae8084 Improve Mediator Javadoc 2015-10-03 23:34:20 +03:00
Ilkka Seppala
e4ff39e080 Improve Iterator Javadoc 2015-10-03 21:37:29 +03:00
Ilkka Seppala
44d7be9c94 Improve Interpreter Javadoc 2015-10-03 21:32:56 +03:00
Ilkka Seppala
b4118bb866 Improve Intercepting Filter Javadoc 2015-10-03 21:28:17 +03:00
Ilkka Seppala
c27291fd27 Improve Fluent Interface Javadoc 2015-10-03 21:17:56 +03:00
Ilkka Seppala
c989f6cb21 Improve Factory Method Javadoc 2015-10-03 21:14:40 +03:00
Ilkka Seppala
516b127d21 Improved Facade Javadoc 2015-10-03 21:11:19 +03:00
Ilkka Seppala
584a22238d Improve Event Aggregator Javadoc 2015-10-03 21:06:52 +03:00
Ilkka Seppala
e32b440a38 Improve Double Checked Locking Javadoc 2015-10-03 21:00:21 +03:00
Ilkka Seppala
8cf35fc315 Improve Decorator Javadoc 2015-10-03 20:43:38 +03:00
Ilkka Seppala
621793ed2d Improved DAO Javadoc 2015-10-03 20:34:15 +03:00
Ilkka Seppala
807478ab3d Improve Composite Javadoc 2015-10-03 20:27:28 +03:00
Ilkka Seppala
d5f52edecf Improve Command Javadoc 2015-10-03 20:21:56 +03:00
Ilkka Seppala
a2f3d58709 Improve Chain Javadoc 2015-10-03 20:19:01 +03:00
Ilkka Seppala
9a08e35101 Improve Builder Javadoc 2015-10-03 17:13:38 +03:00
Ilkka Seppala
cdd586ec7c Improve Bridge Javadoc 2015-10-03 12:40:24 +03:00
Ilkka Seppala
8c6caa29b7 Improve Adapter Javadoc 2015-10-03 11:56:59 +03:00
Ilkka Seppala
0a61d7b067 Improve Abstract Factory Javadocs 2015-10-03 11:53:44 +03:00
Ilkka Seppala
6413c4d2be Added more Singleton documentation 2015-10-02 22:53:41 +03:00
Ilkka Seppala
11cdd20f6f Update version to 1.7.0 2015-09-30 22:36:01 +03:00
Ilkka Seppala
621c3498f6 Remove broken deploy config 2015-09-26 22:52:59 +03:00
Ilkka Seppala
83fed6dd34 Fix Travis config syntax 2015-09-26 22:14:36 +03:00
Ilkka Seppala
793b1cc172 Travis configuration changes 2015-09-26 22:08:23 +03:00
Ilkka Seppala
2ad361f2c3 Travis configuration changes 2015-09-26 21:23:00 +03:00
Ilkka Seppala
e077aa34d7 Travis deploy web site to S3 2015-09-26 20:19:39 +03:00
Ilkka Seppälä
c1fda3ad6c Merge pull request from zafarella/refactor-singleton-according-to-checkstyle
Refactor singleton according to checkstyle rules
2015-09-24 22:32:11 +03:00
zafarella
60f9b71278 eliminate all warnings of checkstyle. 2015-09-24 13:29:39 -04:00
Narendra Pathai
ba6511fe5d Work on , moved POSA reference and some J2EE design pattern references 2015-09-24 12:23:02 +05:30
zafarella
36809537d9 checkstyle fixes - docs, indent etc 2015-09-24 01:01:51 -04:00
Ilkka Seppälä
6735c81b52 Merge pull request from mgalushka/master
 adding getAttackPower method to pattern decorator
2015-09-23 21:10:35 +03:00
Maxim Galushka
ec9af416ba adding getAttackPower method to pattern decorator 2015-09-23 17:58:58 +01:00
Narendra Pathai
b3e4e8a47b Work on , , added references of Gang Of Four to all GoF patterns, added tag for Gang Of Four, added difficulty tags to some of them 2015-09-22 18:25:56 +05:30
Alan
d0af12b1ee Removed magic number. 2015-09-16 21:32:52 +01:00
Alan
51dca28fe7 Updated unit .equals() and .hashCode() methods
Formatted code using this formatter:
https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml
Removed argument final declaration on interface
Updated addCustomer logic for cases where the added customer already
exists
2015-09-14 21:22:33 +01:00
Alan
9c43827004 Removed erroneous semi-colon. 2015-09-05 22:00:27 +01:00
Alan
3da48d970c Inclusion of log4j dependency rather than relying on
System.out.println() statements.
Added unit tests for doa module.
2015-09-05 21:54:14 +01:00
1588 changed files with 82477 additions and 13332 deletions
.gitignore.travis.ymlCODE_COVERAGE.mdCONTRIBUTING.MDLICENSE.mdPULL_REQUEST_TEMPLATE.mdREADME.md
abstract-document
abstract-factory
acyclic-visitor
adapter
aggregator-microservices
README.md
aggregator-service
etc
information-microservice
pom.xml
src
main
test
java
com
iluwatar
information
inventory-microservice
pom.xml
src
main
test
java
com
iluwatar
inventory
pom.xml
ambassador
api-gateway
async-method-invocation
balking
bridge
builder
business-delegate
caching
callback
chain
checkstyle-suppressions.xmlcheckstyle.xml
collection-pipeline
command
composite
converter
cqrs
dao
data-bus
data-mapper
data-transfer-object
decorator
delegation
dependency-injection
dirty-flag
double-checked-locking
README.mdpom.xml
src
main
java
com
iluwatar
resources
test
java
com
iluwatar
doublechecked
double-dispatch
eip-aggregator
eip-message-channel
.gitignoreREADME.md
etc
pom.xml
src
main
java
com
iluwatar
eip
message
channel
test
java
com
iluwatar
eip
message
eip-publish-subscribe
.gitignoreREADME.md
etc
pom.xml
src
main
java
com
iluwatar
eip
publish
subscribe
resources
test
java
com
iluwatar
eip
publish
subscribe
eip-splitter
README.md
etc
pom.xml
src
main
java
com
iluwatar
resources
test
java
com
iluwatar
resources
eip-wire-tap
README.md
etc
pom.xml
src
main
java
com
iluwatar
resources
test
java
com
iluwatar
resources
event-aggregator
event-asynchronous
event-driven-architecture
event-queue
event-sourcing
exclude-pmd.properties
execute-around
extension-objects
facade
factory-kit
factory-method
faq.md
feature-toggle
fluentinterface
flux
flyweight
front-controller
guarded-suspension
README.md
etc
pom.xml
src
main
java
com
iluwatar
guarded
test
java
com
iluwatar
guarded
half-sync-half-async
README.mdpom.xml
src
main
java
test
java
com
hexagonal
intercepting-filter
interpreter
iterator
layers
lazy-loading
marker
mediator
memento
message-channel
index.mdpom.xml
src
main
java
com
iluwatar
message
channel
test
java
com
iluwatar
message
model-view-controller
model-view-presenter
module
monad
monostate
multiton
mute-idiom
mutex
naked-objects
null-object
object-mother
object-pool
observer
page-object
partial-response
poison-pill
pom.xml
private-class-data
producer-consumer
promise
property
prototype
proxy
queue-load-leveling
reactor
reader-writer-lock
repository
resource-acquisition-is-initialization
README.mdpom.xml
src
main
java
com
iluwatar
resource
test
java
com
iluwatar
resource
acquisition
retry
semaphore
servant
serverless
service-layer
service-locator
singleton
specification
state
step-builder
strategy
template-method
thread-pool
throttling
tls
tolerant-reader
trampoline
.gitignoreREADME.mdpom.xml
src
main
java
test
java
com
iluwatar
twin
unit-of-work
update-ghpages.shurm.sh
value-object
README.md
etc
pom.xml
src
main
java
com
iluwatar
test
java
com
visitor

34
.gitignore vendored

@@ -1,14 +1,20 @@
target
.metadata
.settings
.classpath
.project
*.class
# Package Files #
*.jar
*.war
*.ear
.idea
*.iml
*.swp
datanucleus.log
target
.metadata
.settings
.classpath
.project
*.class
# Package Files #
*.jar
*.war
*.ear
.idea
*.iml
*.swp
datanucleus.log
/bin/
/bin/
/bin/
*.log
data-mapper/src/main/resources/log4j.xml
event-sourcing/Journal.json

@@ -1,20 +1,39 @@
language: java
jdk:
- oraclejdk8
- oraclejdk8
env:
global:
- GH_REF: github.com/iluwatar/java-design-patterns.git
- secure: "LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg="
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
- secure: "eoWlW9GyTJY04P8K3pxayXwU9/hmptQg/LfirispQkV9YvmziCfSzXnatnBhNfud98sCzY8BScXnb+OWLTnjLKpId4rtEqb0aJ40Jc32cUKzgzFAUn7cNcDAbUIfyPAGVqyQqfj/11wYSADwWMMOPlW97ExUtoyiH2WenXuRHso="
after_success:
- mvn clean test jacoco:report coveralls:report
- bash update-ghpages.sh
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
# Migration to container-based infrastructure
sudo: false
# default install command is just "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V"
install:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -e
after_success:
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN
- bash update-ghpages.sh
# use latest java version available instead of travis default
addons:
apt:
packages:
- oracle-java8-installer
notifications:
email:
- iluwatar@gmail.com
webhooks:
urls:
- https://webhooks.gitter.im/e/3319623945358a093a6f
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always
sudo: required

13
CODE_COVERAGE.md Normal file

@@ -0,0 +1,13 @@
# Code Coverage Report generation
To generate the code coverage report, execute the following command:
> mvn clean verify jacoco:report
This will generate code coverage report in each of the modules. In order to view the same, open the following file in your browser.
> target/site/jacoco/index.html
Please note that the above folder is created under each of the modules. For example:
* adapter/target/site/jacoco/index.html
* busniess-delegate/target/site/jacoco/index.html

4
CONTRIBUTING.MD Normal file

@@ -0,0 +1,4 @@
This is great you have something to contribute!
Before going any further please read the [wiki](https://github.com/iluwatar/java-design-patterns/wiki)
with conventions and rules we used for this project.

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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

15
PULL_REQUEST_TEMPLATE.md Normal file

@@ -0,0 +1,15 @@
Pull request title
- Clearly and concisely describes what it does
- Refer to the issue that it solves, if available
Pull request description
- Describes the main changes that come with the pull request
- Any relevant additional information is provided
> For detailed contributing instructions see https://github.com/iluwatar/java-design-patterns/wiki/01.-How-to-contribute

@@ -2,12 +2,12 @@
that smart and dearly wants an empty line before a heading to be able to
display it as such, e.g. website) -->
# Design pattern samples in Java
# Design patterns implemented in Java
[![Build status](https://travis-ci.org/iluwatar/java-design-patterns.svg?branch=master)](https://travis-ci.org/iluwatar/java-design-patterns)
[![Coverage Status](https://coveralls.io/repos/iluwatar/java-design-patterns/badge.svg?branch=master)](https://coveralls.io/r/iluwatar/java-design-patterns?branch=master)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5634/badge.svg)](https://scan.coverity.com/projects/5634)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
[![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)
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=com.iluwatar%3Ajava-design-patterns&metric=alert_status)](https://sonarcloud.io/dashboard/index/com.iluwatar%3Ajava-design-patterns)
# Introduction
@@ -23,10 +23,16 @@ are familiar with the patterns.
# Getting started
Before you dive into the material, you should be familiar with various
[Programming/Software Design Principles](http://webpro.github.io/programming-principles/).
Before you dive into the material, you should be familiar with various
Programming/Software Design Principles.
Once you are familiar with these concepts you can start drilling down into patterns by any of the following approaches
All designs should be as simple as possible. You should start with KISS, YAGNI,
and Do The Simplest Thing That Could Possibly Work principles. Complexity and
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
patterns by any of the following approaches
- Using difficulty tags, `Difficulty-Beginner`, `Difficulty-Intermediate` & `Difficulty-Expert`.
- Using pattern categories, `Creational`, `Behavioral` and others.
@@ -34,21 +40,7 @@ Once you are familiar with these concepts you can start drilling down into patte
# 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).
# Credits
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
* [Effective Java (2nd Edition)](http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683)
* [Java Generics and Collections](http://www.amazon.com/Java-Generics-Collections-Maurice-Naftalin/dp/0596527756/)
* [Let's Modify the Objects-First Approach into Design-Patterns-First](http://edu.pecinovsky.cz/papers/2006_ITiCSE_Design_Patterns_First.pdf)
* [Pattern Languages of Program Design](http://www.amazon.com/Pattern-Languages-Program-Design-Coplien/dp/0201607344/ref=sr_1_1)
* [Presentation Tier Patterns](http://www.javagyan.com/tutorials/corej2eepatterns/presentation-tier-patterns)
* [Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions](http://www.amazon.com/Functional-Programming-Java-Harnessing-Expressions/dp/1937785467/ref=sr_1_1)
* [Patterns of Enterprise Application Architecture](http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420)
* [Spring Data](http://www.amazon.com/Spring-Data-Mark-Pollack/dp/1449323952/ref=sr_1_1)
* [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
* [Pattern Oriented Software Architecture Vol I-V](http://www.amazon.com/Pattern-Oriented-Software-Architecture-Volume-Patterns/dp/0471958697)
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

@@ -0,0 +1,29 @@
---
layout: pattern
title: Abstract Document
folder: abstract-document
permalink: /patterns/abstract-document/
categories: Structural
tags:
- Java
- Difficulty-Intermediate
---
## Intent
Achieve flexibility of untyped languages and keep the type-safety
![alt text](./etc/abstract-document.png "Abstract Document Traits and Domain")
## Applicability
Use the Abstract Document Pattern when
* there is a need to add new properties on the fly
* you want a flexible way to organize domain in tree like structure
* you want more loosely coupled system
## Credits
* [Wikipedia: Abstract Document Pattern](https://en.wikipedia.org/wiki/Abstract_Document_Pattern)
* [Martin Fowler: Dealing with properties](http://martinfowler.com/apsupp/properties.pdf)

Binary file not shown.

After

(image error) Size: 94 KiB

@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.2.2" icons="true" always-add-relationships="false" generalizations="true" realizations="true"
associations="true" dependencies="false" nesting-relationships="true" router="FAN">
<class id="1" language="java" name="com.iluwatar.abstractdocument.AbstractDocument" project="abstract-document"
file="/abstract-document/src/main/java/com/iluwatar/abstractdocument/AbstractDocument.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="659" y="286"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="2" language="java" name="com.iluwatar.abstractdocument.Document" project="abstract-document"
file="/abstract-document/src/main/java/com/iluwatar/abstractdocument/Document.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="562" y="27"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="3" language="java" name="com.iluwatar.abstractdocument.domain.Car" project="abstract-document"
file="/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Car.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="348" y="737"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="4" language="java" name="com.iluwatar.abstractdocument.domain.Part" project="abstract-document"
file="/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Part.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="760" y="746"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="5" language="java" name="com.iluwatar.abstractdocument.domain.HasModel" project="abstract-document"
file="/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasModel.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="355" y="297"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<interface id="6" language="java" name="com.iluwatar.abstractdocument.domain.HasParts" project="abstract-document"
file="/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasParts.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="109" y="297"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<interface id="7" language="java" name="com.iluwatar.abstractdocument.domain.HasPrice" project="abstract-document"
file="/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasPrice.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="1008" y="283"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<interface id="8" language="java" name="com.iluwatar.abstractdocument.domain.HasType" project="abstract-document"
file="/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasType.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="1257" y="277"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<realization id="9">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="8"/>
</realization>
<realization id="10">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="7"/>
</realization>
<generalization id="11">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="2"/>
</generalization>
<realization id="12">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="5"/>
</realization>
<realization id="13">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="7"/>
</realization>
<generalization id="14">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="1"/>
</generalization>
<realization id="15">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="6"/>
</realization>
<generalization id="16">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="2"/>
</generalization>
<generalization id="17">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="2"/>
</generalization>
<realization id="18">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="5"/>
</realization>
<generalization id="19">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="1"/>
</generalization>
<generalization id="20">
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="2"/>
</generalization>
<realization id="21">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="2"/>
</realization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

47
abstract-document/pom.xml Normal file

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright (c) 2014-2016 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>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.21.0-SNAPSHOT</version>
</parent>
<artifactId>abstract-document</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@@ -0,0 +1,72 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;
/**
* Abstract implementation of Document interface
*/
public abstract class AbstractDocument implements Document {
private final Map<String, Object> properties;
protected AbstractDocument(Map<String, Object> properties) {
Objects.requireNonNull(properties, "properties map is required");
this.properties = properties;
}
@Override
public Void put(String key, Object value) {
properties.put(key, value);
return null;
}
@Override
public Object get(String key) {
return properties.get(key);
}
@Override
public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) {
Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null)
.map(el -> (List<Map<String, Object>>) el).findAny();
return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getClass().getName()).append("[");
properties.entrySet()
.forEach(e -> builder.append("[").append(e.getKey()).append(" : ").append(e.getValue()).append("]"));
builder.append("]");
return builder.toString();
}
}

@@ -0,0 +1,91 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument;
import com.iluwatar.abstractdocument.domain.Car;
import com.iluwatar.abstractdocument.domain.HasModel;
import com.iluwatar.abstractdocument.domain.HasParts;
import com.iluwatar.abstractdocument.domain.HasPrice;
import com.iluwatar.abstractdocument.domain.HasType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* The Abstract Document pattern enables handling additional, non-static
* properties. This pattern uses concept of traits to enable type safety and
* separate properties of different classes into set of interfaces.
* <p>
* <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.
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Executes the App
*/
public App() {
LOGGER.info("Constructing parts and car");
Map<String, Object> carProperties = new HashMap<>();
carProperties.put(HasModel.PROPERTY, "300SL");
carProperties.put(HasPrice.PROPERTY, 10000L);
Map<String, Object> wheelProperties = new HashMap<>();
wheelProperties.put(HasType.PROPERTY, "wheel");
wheelProperties.put(HasModel.PROPERTY, "15C");
wheelProperties.put(HasPrice.PROPERTY, 100L);
Map<String, Object> doorProperties = new HashMap<>();
doorProperties.put(HasType.PROPERTY, "door");
doorProperties.put(HasModel.PROPERTY, "Lambo");
doorProperties.put(HasPrice.PROPERTY, 300L);
carProperties.put(HasParts.PROPERTY, Arrays.asList(wheelProperties, doorProperties));
Car car = new Car(carProperties);
LOGGER.info("Here is our car:");
LOGGER.info("-> model: {}", car.getModel().get());
LOGGER.info("-> price: {}", car.getPrice().get());
LOGGER.info("-> parts: ");
car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get()));
}
/**
* Program entry point
*
* @param args command line args
*/
public static void main(String[] args) {
new App();
}
}

@@ -0,0 +1,59 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Stream;
/**
* Document interface
*/
public interface Document {
/**
* Puts the value related to the key
*
* @param key element key
* @param value element value
* @return Void
*/
Void put(String key, Object value);
/**
* Gets the value for the key
*
* @param key element key
* @return value or null
*/
Object get(String key);
/**
* Gets the stream of child documents
*
* @param key element key
* @param constructor constructor of child class
* @return child documents
*/
<T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor);
}

@@ -0,0 +1,38 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument.domain;
import java.util.Map;
import com.iluwatar.abstractdocument.AbstractDocument;
/**
* Car entity
*/
public class Car extends AbstractDocument implements HasModel, HasPrice, HasParts {
public Car(Map<String, Object> properties) {
super(properties);
}
}

@@ -0,0 +1,40 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument.domain;
import java.util.Optional;
import com.iluwatar.abstractdocument.Document;
/**
* HasModel trait for static access to 'model' property
*/
public interface HasModel extends Document {
String PROPERTY = "model";
default Optional<String> getModel() {
return Optional.ofNullable((String) get(PROPERTY));
}
}

@@ -0,0 +1,40 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument.domain;
import java.util.stream.Stream;
import com.iluwatar.abstractdocument.Document;
/**
* HasParts trait for static access to 'parts' property
*/
public interface HasParts extends Document {
String PROPERTY = "parts";
default Stream<Part> getParts() {
return children(PROPERTY, Part::new);
}
}

@@ -0,0 +1,40 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument.domain;
import java.util.Optional;
import com.iluwatar.abstractdocument.Document;
/**
* HasPrice trait for static access to 'price' property
*/
public interface HasPrice extends Document {
String PROPERTY = "price";
default Optional<Number> getPrice() {
return Optional.ofNullable((Number) get(PROPERTY));
}
}

@@ -0,0 +1,40 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument.domain;
import com.iluwatar.abstractdocument.Document;
import java.util.Optional;
/**
* HasType trait for static access to 'type' property
*/
public interface HasType extends Document {
String PROPERTY = "type";
default Optional<String> getType() {
return Optional.ofNullable((String) get(PROPERTY));
}
}

@@ -0,0 +1,38 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument.domain;
import java.util.Map;
import com.iluwatar.abstractdocument.AbstractDocument;
/**
* Part entity
*/
public class Part extends AbstractDocument implements HasType, HasModel, HasPrice {
public Part(Map<String, Object> properties) {
super(properties);
}
}

@@ -0,0 +1,88 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* AbstractDocument test class
*/
public class AbstractDocumentTest {
private static final String KEY = "key";
private static final String VALUE = "value";
private class DocumentImplementation extends AbstractDocument {
DocumentImplementation(Map<String, Object> properties) {
super(properties);
}
}
private DocumentImplementation document = new DocumentImplementation(new HashMap<>());
@Test
public void shouldPutAndGetValue() {
document.put(KEY, VALUE);
assertEquals(VALUE, document.get(KEY));
}
@Test
public void shouldRetrieveChildren() {
Map<String, Object> child1 = new HashMap<>();
Map<String, Object> child2 = new HashMap<>();
List<Map<String, Object>> children = Arrays.asList(child1, child2);
document.put(KEY, children);
Stream<DocumentImplementation> childrenStream = document.children(KEY, DocumentImplementation::new);
assertNotNull(children);
assertEquals(2, childrenStream.count());
}
@Test
public void shouldRetrieveEmptyStreamForNonExistingChildren() {
Stream<DocumentImplementation> children = document.children(KEY, DocumentImplementation::new);
assertNotNull(children);
assertEquals(0, children.count());
}
@Test
public void shouldIncludePropsInToString() {
Map<String, Object> props = new HashMap<>();
props.put(KEY, VALUE);
DocumentImplementation document = new DocumentImplementation(props);
assertNotNull(document.toString().contains(KEY));
assertNotNull(document.toString().contains(VALUE));
}
}

@@ -0,0 +1,37 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument;
import org.junit.jupiter.api.Test;
/**
* Simple App test
*/
public class AppTest {
@Test
public void shouldExecuteAppWithoutException() {
App.main(null);
}
}

@@ -0,0 +1,77 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.abstractdocument;
import com.iluwatar.abstractdocument.domain.Car;
import com.iluwatar.abstractdocument.domain.HasModel;
import com.iluwatar.abstractdocument.domain.HasParts;
import com.iluwatar.abstractdocument.domain.HasPrice;
import com.iluwatar.abstractdocument.domain.HasType;
import com.iluwatar.abstractdocument.domain.Part;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Part and Car
*/
public class DomainTest {
private static final String TEST_PART_TYPE = "test-part-type";
private static final String TEST_PART_MODEL = "test-part-model";
private static final long TEST_PART_PRICE = 0L;
private static final String TEST_CAR_MODEL = "test-car-model";
private static final long TEST_CAR_PRICE = 1L;
@Test
public void shouldConstructPart() {
Map<String, Object> partProperties = new HashMap<>();
partProperties.put(HasType.PROPERTY, TEST_PART_TYPE);
partProperties.put(HasModel.PROPERTY, TEST_PART_MODEL);
partProperties.put(HasPrice.PROPERTY, TEST_PART_PRICE);
Part part = new Part(partProperties);
assertEquals(TEST_PART_TYPE, part.getType().get());
assertEquals(TEST_PART_MODEL, part.getModel().get());
assertEquals(TEST_PART_PRICE, part.getPrice().get());
}
@Test
public void shouldConstructCar() {
Map<String, Object> carProperties = new HashMap<>();
carProperties.put(HasModel.PROPERTY, TEST_CAR_MODEL);
carProperties.put(HasPrice.PROPERTY, TEST_CAR_PRICE);
carProperties.put(HasParts.PROPERTY, Arrays.asList(new HashMap<>(), new HashMap<>()));
Car car = new Car(carProperties);
assertEquals(TEST_CAR_MODEL, car.getModel().get());
assertEquals(TEST_CAR_PRICE, car.getPrice().get());
assertEquals(2, car.getParts().count());
}
}

199
abstract-factory/README.md Normal file

@@ -0,0 +1,199 @@
---
layout: pattern
title: Abstract Factory
folder: abstract-factory
permalink: /patterns/abstract-factory/
categories: Creational
tags:
- Java
- Gang Of Four
- Difficulty-Intermediate
---
## Also known as
Kit
## Intent
Provide an interface for creating families of related or dependent
objects without specifying their concrete classes.
## Explanation
Real world example
> To create a kingdom we need objects with 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.
In plain words
> A factory of factories; a factory that groups the individual but related/dependent factories together without specifying their concrete classes.
Wikipedia says
> The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes
**Programmatic Example**
Translating the kingdom example above. First of all we have some interfaces and implementation for the objects in the kingdom
```java
public interface Castle {
String getDescription();
}
public interface King {
String getDescription();
}
public interface Army {
String getDescription();
}
// Elven implementations ->
public class ElfCastle implements 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!";
@Override
public String getDescription() {
return DESCRIPTION;
}
}
public class ElfArmy implements Army {
static final String DESCRIPTION = "This is the Elven Army!";
@Override
public String getDescription() {
return DESCRIPTION;
}
}
// Orcish implementations similarly...
```
Then we have the abstraction and implementations for the kingdom factory
```java
public interface KingdomFactory {
Castle createCastle();
King createKing();
Army createArmy();
}
public class ElfKingdomFactory implements KingdomFactory {
public Castle createCastle() {
return new ElfCastle();
}
public King createKing() {
return new ElfKing();
}
public Army createArmy() {
return new ElfArmy();
}
}
public class OrcKingdomFactory implements KingdomFactory {
public Castle createCastle() {
return new OrcCastle();
}
public King createKing() {
return new OrcKing();
}
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.
```java
KingdomFactory factory = new ElfKingdomFactory();
Castle castle = factory.createCastle();
King king = factory.createKing();
Army army = factory.createArmy();
castle.getDescription(); // Output: This is the Elven castle!
king.getDescription(); // Output: This is the Elven king!
army.getDescription(); // Output: 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).
In this example, we also used an enum to parameterize which type of kingdom factory the client will ask for.
```java
public static class FactoryMaker {
public enum KingdomType {
ELF, ORC
}
public static KingdomFactory makeFactory(KingdomType type) {
switch (type) {
case ELF:
return new ElfKingdomFactory();
case ORC:
return new OrcKingdomFactory();
default:
throw new IllegalArgumentException("KingdomType not supported.");
}
}
}
public static void main(String[] args) {
App app = new App();
LOGGER.info("Elf Kingdom");
app.createKingdom(FactoryMaker.makeFactory(KingdomType.ELF));
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
LOGGER.info("Orc Kingdom");
app.createKingdom(FactoryMaker.makeFactory(KingdomType.ORC));
-- similar use of the orc factory
}
```
## Applicability
Use the Abstract Factory pattern when
* a system should be independent of how its products are created, composed and represented
* a system should be configured with one of multiple families of products
* a 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.
* you need a run-time value to construct a particular dependency
* you want to decide which product to call from a family at runtime.
* you need to supply one or more parameters only known at run-time before you can resolve a dependency.
## Use Cases:
* Selecting to call the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or NetworkAcmeService at runtime.
* Unit test case writing becomes much easier
## Consequences:
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time.
## Tutorial
* [Abstract Factory Pattern Tutorial](https://www.journaldev.com/1418/abstract-factory-design-pattern-in-java)
## Presentations
* [Abstract Factory Pattern](etc/presentation.html)
## Real world examples
* [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)
* [javax.xml.transform.TransformerFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/transform/TransformerFactory.html#newInstance--)
* [javax.xml.xpath.XPathFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/xpath/XPathFactory.html#newInstance--)
## Credits
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

Binary file not shown.

Before

(image error) Size: 21 KiB

@@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
<interface id="1" language="java" name="com.iluwatar.abstractfactory.Army" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java" binary="false" corner="BOTTOM_RIGHT">
<position height="70" width="161" x="1407" y="300"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<interface id="2" language="java" name="com.iluwatar.abstractfactory.KingdomFactory" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="124" width="161" x="1001" y="300"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="3" language="java" name="com.iluwatar.abstractfactory.ElfCastle" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="161" x="96" y="118"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="4" language="java" name="com.iluwatar.abstractfactory.ElfKingdomFactory" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="142" width="161" x="900" y="118"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="5" language="java" name="com.iluwatar.abstractfactory.ElfKing" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="161" x="498" y="118"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="6" language="java" name="com.iluwatar.abstractfactory.King" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java" binary="false" corner="BOTTOM_RIGHT">
<position height="70" width="161" x="599" y="300"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="7" language="java" name="com.iluwatar.abstractfactory.OrcCastle" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="161" x="297" y="118"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="8" language="java" name="com.iluwatar.abstractfactory.OrcKing" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="161" x="699" y="118"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="9" language="java" name="com.iluwatar.abstractfactory.ElfArmy" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="161" x="1306" y="118"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="10" language="java" name="com.iluwatar.abstractfactory.OrcArmy" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="161" x="1507" y="118"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="11" language="java" name="com.iluwatar.abstractfactory.Castle" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java" binary="false" corner="BOTTOM_RIGHT">
<position height="70" width="161" x="197" y="300"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="12" language="java" name="com.iluwatar.abstractfactory.OrcKingdomFactory" project="abstract-factory"
file="/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="142" width="165" x="1101" y="118"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<realization id="13">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="2"/>
</realization>
<realization id="14">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="11"/>
</realization>
<realization id="15">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="6"/>
</realization>
<realization id="16">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="11"/>
</realization>
<realization id="17">
<end type="SOURCE" refId="10"/>
<end type="TARGET" refId="1"/>
</realization>
<realization id="18">
<end type="SOURCE" refId="12"/>
<end type="TARGET" refId="2"/>
</realization>
<realization id="19">
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="6"/>
</realization>
<realization id="20">
<end type="SOURCE" refId="9"/>
<end type="TARGET" refId="1"/>
</realization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

Binary file not shown.

Before

(image error) Size: 57 KiB

Binary file not shown.

After

(image error) Size: 57 KiB

Binary file not shown.

After

(image error) Size: 26 KiB

@@ -0,0 +1,190 @@
<!--
The MIT License
Copyright (c) 2017 Rodolfo Forte
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.
-->
<!DOCTYPE html>
<html>
<head>
<title>Design Patterns - Abstract Factory Presentation</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
blockquote {
border-left: 0.3em solid rgba(0,0,0,0.5);
padding: 0 15px;
font-style: italic;
}
img {
max-width:100%;
}
</style>
</head>
<body>
<textarea id="source">
class: center, middle
# Abstract Factory
---
# Also known as
* Kit
---
# Intent
* Provide an interface for creating families of related or dependent objects without specifying their concrete classes
---
# Explanation
* [Wikipedia](https://en.wikipedia.org/wiki/Abstract_factory_pattern) says:
> "The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes"
<br />
* In plain words:
* A factory that groups individual but related/dependent factories together without specifying their concrete classes;
* A factory of factories;
---
# Example
* In a factory that creates kingdoms, we need objects with common theme:
* Elven kingdom needs an Elven king, Elven castle and Elven army;
* Orcish kingdom needs an Orcish king, Orcish castle and Orcish army;
<br />
* There is a dependency between the objects in the kingdom;
---
# Diagram
* Based on the kingdom example, the diagram below showcases the different concrete factories and their concrete products:
.center[![Diagram](diagram1.png)]
---
# Diagram
* The class diagram below showcases the factory of factories;
* At runtime, we can define which Kingdom type is needed and pass it as a parameter to define which concrete KingdomFactory to instantiate;
* The concrete factory returned will then be able to produce the related objects of the specified type;
.center[![Diagram](diagram2.png)]
---
# Applicability
Use the Abstract Factory pattern when:
* A system should be independent of how its products are created, composed and represented;
* A system should be configured with one of multiple families of products;
* A 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;
---
# Applicability
Use the Abstract Factory pattern when:
* The lifetime of the dependency is conceptually shorter than the lifetime of the consumer;
* You need a run-time value to construct a particular dependency;
* You want to decide which product to call from a family at runtime;
* You need to supply one or more parameters only known at run-time before you can resolve a dependency;
---
#Use Cases
* Selecting to call the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or NetworkAcmeService at runtime;
* Unit test case writing becomes much easier;
---
# Consequences
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time
---
# Real world examples
[javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)
[javax.xml.transform.TransformerFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/transform/TransformerFactory.html#newInstance--)
[javax.xml.xpath.XPathFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/xpath/XPathFactory.html#newInstance--)
---
# Credits
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
---
# Tutorials
* Source code http://java-design-patterns.com/patterns/abstract-factory/
</textarea>
<script src="https://gnab.github.io/remark/downloads/remark-latest.min.js">
</script>
<script>
var slideshow = remark.create();
</script>
</body>
</html>

@@ -1,24 +0,0 @@
---
layout: pattern
title: Abstract Factory
folder: abstract-factory
permalink: /patterns/abstract-factory/
categories: Creational
tags: Java
---
**Intent:** Provide an interface for creating families of related or dependent
objects without specifying their concrete classes.
![alt text](./etc/abstract-factory_1.png "Abstract Factory")
**Applicability:** Use the Abstract Factory pattern when
* a system should be independent of how its products are created, composed and represented
* a system should be configured with one of multiple families of products
* a 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
**Real world examples:**
* [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)

@@ -1,19 +1,47 @@
<?xml version="1.0"?>
<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.6.0</version>
</parent>
<artifactId>abstract-factory</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!--
The MIT License
Copyright (c) 2014-2016 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 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.21.0-SNAPSHOT</version>
</parent>
<artifactId>abstract-factory</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@@ -1,73 +1,147 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.iluwatar.abstractfactory.App.FactoryMaker.KingdomType;
/**
*
* The essence of the Abstract Factory pattern is a factory interface
* ({@link KingdomFactory}) and its implementations ({@link ElfKingdomFactory},
* {@link OrcKingdomFactory}).
* The Abstract Factory pattern provides a way to encapsulate a group of individual factories that have a common theme
* without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of
* the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part
* of the theme. The client does not know (or care) which concrete objects it gets from each of these internal
* factories, since it uses only the generic interfaces of their products. This pattern separates the details of
* implementation of a set of objects from their general usage and relies on object composition, as object creation is
* implemented in methods exposed in the factory interface.
* <p>
* The example uses both concrete implementations to create a king, a castle and
* an army.
* 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.
*
*/
public class App {
private King king;
private Castle castle;
private Army army;
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Creates kingdom
* @param factory
*/
public void createKingdom(final KingdomFactory factory) {
setKing(factory.createKing());
setCastle(factory.createCastle());
setArmy(factory.createArmy());
}
ElfKingdomFactory getElfKingdomFactory() {
return new ElfKingdomFactory();
}
OrcKingdomFactory getOrcKingdomFactory() {
return new OrcKingdomFactory();
}
King getKing(final KingdomFactory factory) {
return factory.createKing();
}
Castle getCastle(final KingdomFactory factory) {
return factory.createCastle();
}
Army getArmy(final KingdomFactory factory) {
return factory.createArmy();
}
public King getKing() {
return king;
}
private void setKing(final King king) {
this.king = king;
}
public Castle getCastle() {
return castle;
}
private void setCastle(final Castle castle) {
this.castle = castle;
}
public Army getArmy() {
return army;
}
private void setArmy(final Army army) {
this.army = army;
}
}
private King king;
private Castle castle;
private Army army;
/**
* Creates kingdom
*/
public void createKingdom(final KingdomFactory factory) {
setKing(factory.createKing());
setCastle(factory.createCastle());
setArmy(factory.createArmy());
}
King getKing(final KingdomFactory factory) {
return factory.createKing();
}
public King getKing() {
return king;
}
private void setKing(final King king) {
this.king = king;
}
Castle getCastle(final KingdomFactory factory) {
return factory.createCastle();
}
public Castle getCastle() {
return castle;
}
private void setCastle(final Castle castle) {
this.castle = castle;
}
Army getArmy(final KingdomFactory factory) {
return factory.createArmy();
}
public Army getArmy() {
return army;
}
private void setArmy(final Army army) {
this.army = army;
}
/**
* The factory of kingdom factories.
*/
public static class FactoryMaker {
/**
* Enumeration for the different types of Kingdoms.
*/
public enum KingdomType {
ELF, ORC
}
/**
* The factory method to create KingdomFactory concrete objects.
*/
public static KingdomFactory makeFactory(KingdomType type) {
switch (type) {
case ELF:
return new ElfKingdomFactory();
case ORC:
return new OrcKingdomFactory();
default:
throw new IllegalArgumentException("KingdomType not supported.");
}
}
}
/**
* Program entry point.
*
* @param args
* command line args
*/
public static void main(String[] args) {
App app = new App();
LOGGER.info("Elf Kingdom");
app.createKingdom(FactoryMaker.makeFactory(KingdomType.ELF));
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
LOGGER.info("Orc Kingdom");
app.createKingdom(FactoryMaker.makeFactory(KingdomType.ORC));
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
}
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,5 +29,5 @@ package com.iluwatar.abstractfactory;
*/
public interface Army {
String getDescription();
String getDescription();
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,5 +29,5 @@ package com.iluwatar.abstractfactory;
*/
public interface Castle {
String getDescription();
String getDescription();
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,10 +29,10 @@ 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() {
return DESCRIPTION;
}
@Override
public String getDescription() {
return DESCRIPTION;
}
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,10 +29,10 @@ 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() {
return DESCRIPTION;
}
@Override
public String getDescription() {
return DESCRIPTION;
}
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,10 +29,10 @@ package com.iluwatar.abstractfactory;
*/
public class ElfKing implements King {
static final String DESCRIPTION = "This is the Elven king!";
@Override
public String getDescription() {
return DESCRIPTION;
}
static final String DESCRIPTION = "This is the Elven king!";
@Override
public String getDescription() {
return DESCRIPTION;
}
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,16 +29,16 @@ package com.iluwatar.abstractfactory;
*/
public class ElfKingdomFactory implements KingdomFactory {
public Castle createCastle() {
return new ElfCastle();
}
public Castle createCastle() {
return new ElfCastle();
}
public King createKing() {
return new ElfKing();
}
public King createKing() {
return new ElfKing();
}
public Army createArmy() {
return new ElfArmy();
}
public Army createArmy() {
return new ElfArmy();
}
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,5 +29,5 @@ package com.iluwatar.abstractfactory;
*/
public interface King {
String getDescription();
String getDescription();
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,10 +29,10 @@ package com.iluwatar.abstractfactory;
*/
public interface KingdomFactory {
Castle createCastle();
Castle createCastle();
King createKing();
King createKing();
Army createArmy();
Army createArmy();
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,10 +29,10 @@ 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() {
return DESCRIPTION;
}
@Override
public String getDescription() {
return DESCRIPTION;
}
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,10 +29,10 @@ 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() {
return DESCRIPTION;
}
@Override
public String getDescription() {
return DESCRIPTION;
}
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,10 +29,10 @@ package com.iluwatar.abstractfactory;
*/
public class OrcKing implements King {
static final String DESCRIPTION = "This is the Orc king!";
@Override
public String getDescription() {
return DESCRIPTION;
}
static final String DESCRIPTION = "This is the Orc king!";
@Override
public String getDescription() {
return DESCRIPTION;
}
}

@@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
/**
@@ -7,16 +29,15 @@ package com.iluwatar.abstractfactory;
*/
public class OrcKingdomFactory implements KingdomFactory {
public Castle createCastle() {
return new OrcCastle();
}
public Castle createCastle() {
return new OrcCastle();
}
public King createKing() {
return new OrcKing();
}
public Army createArmy() {
return new OrcArmy();
}
public King createKing() {
return new OrcKing();
}
public Army createArmy() {
return new OrcArmy();
}
}

@@ -0,0 +1,106 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.iluwatar.abstractfactory.App.FactoryMaker;
import com.iluwatar.abstractfactory.App.FactoryMaker.KingdomType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Test for abstract factory
*/
public class AbstractFactoryTest {
private App app = new App();
private KingdomFactory elfFactory;
private KingdomFactory orcFactory;
@BeforeEach
public void setUp() {
elfFactory = FactoryMaker.makeFactory(KingdomType.ELF);
orcFactory = FactoryMaker.makeFactory(KingdomType.ORC);
}
@Test
public void king() {
final King elfKing = app.getKing(elfFactory);
assertTrue(elfKing instanceof ElfKing);
assertEquals(ElfKing.DESCRIPTION, elfKing.getDescription());
final King orcKing = app.getKing(orcFactory);
assertTrue(orcKing instanceof OrcKing);
assertEquals(OrcKing.DESCRIPTION, orcKing.getDescription());
}
@Test
public void castle() {
final Castle elfCastle = app.getCastle(elfFactory);
assertTrue(elfCastle instanceof ElfCastle);
assertEquals(ElfCastle.DESCRIPTION, elfCastle.getDescription());
final Castle orcCastle = app.getCastle(orcFactory);
assertTrue(orcCastle instanceof OrcCastle);
assertEquals(OrcCastle.DESCRIPTION, orcCastle.getDescription());
}
@Test
public void army() {
final Army elfArmy = app.getArmy(elfFactory);
assertTrue(elfArmy instanceof ElfArmy);
assertEquals(ElfArmy.DESCRIPTION, elfArmy.getDescription());
final Army orcArmy = app.getArmy(orcFactory);
assertTrue(orcArmy instanceof OrcArmy);
assertEquals(OrcArmy.DESCRIPTION, orcArmy.getDescription());
}
@Test
public void createElfKingdom() {
app.createKingdom(elfFactory);
final King king = app.getKing();
final Castle castle = app.getCastle();
final Army army = app.getArmy();
assertTrue(king instanceof ElfKing);
assertEquals(ElfKing.DESCRIPTION, king.getDescription());
assertTrue(castle instanceof ElfCastle);
assertEquals(ElfCastle.DESCRIPTION, castle.getDescription());
assertTrue(army instanceof ElfArmy);
assertEquals(ElfArmy.DESCRIPTION, army.getDescription());
}
@Test
public void createOrcKingdom() {
app.createKingdom(orcFactory);
final King king = app.getKing();
final Castle castle = app.getCastle();
final Army army = app.getArmy();
assertTrue(king instanceof OrcKing);
assertEquals(OrcKing.DESCRIPTION, king.getDescription());
assertTrue(castle instanceof OrcCastle);
assertEquals(OrcCastle.DESCRIPTION, castle.getDescription());
assertTrue(army instanceof OrcArmy);
assertEquals(OrcArmy.DESCRIPTION, army.getDescription());
}
}

@@ -1,77 +1,38 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.abstractfactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
/**
* Tests that Abstract Factory example runs without errors.
*/
public class AppTest {
private App app = new App();;
private KingdomFactory elfFactory;
private KingdomFactory orcFactory;
@Before
public void setUp() {
elfFactory = app.getElfKingdomFactory();
orcFactory = app.getOrcKingdomFactory();
}
@Test
public void king() {
final King elfKing = app.getKing(elfFactory);
assertTrue(elfKing instanceof ElfKing);
assertEquals(ElfKing.DESCRIPTION, elfKing.getDescription());
final King orcKing = app.getKing(orcFactory);
assertTrue(orcKing instanceof OrcKing);
assertEquals(OrcKing.DESCRIPTION, orcKing.getDescription());
}
@Test
public void castle() {
final Castle elfCastle = app.getCastle(elfFactory);
assertTrue(elfCastle instanceof ElfCastle);
assertEquals(ElfCastle.DESCRIPTION, elfCastle.getDescription());
final Castle orcCastle = app.getCastle(orcFactory);
assertTrue(orcCastle instanceof OrcCastle);
assertEquals(OrcCastle.DESCRIPTION, orcCastle.getDescription());
}
@Test
public void army() {
final Army elfArmy = app.getArmy(elfFactory);
assertTrue(elfArmy instanceof ElfArmy);
assertEquals(ElfArmy.DESCRIPTION, elfArmy.getDescription());
final Army orcArmy = app.getArmy(orcFactory);
assertTrue(orcArmy instanceof OrcArmy);
assertEquals(OrcArmy.DESCRIPTION, orcArmy.getDescription());
}
@Test
public void createElfKingdom() {
app.createKingdom(elfFactory);
final King king = app.getKing();
final Castle castle = app.getCastle();
final Army army = app.getArmy();
assertTrue(king instanceof ElfKing);
assertEquals(ElfKing.DESCRIPTION, king.getDescription());
assertTrue(castle instanceof ElfCastle);
assertEquals(ElfCastle.DESCRIPTION, castle.getDescription());
assertTrue(army instanceof ElfArmy);
assertEquals(ElfArmy.DESCRIPTION, army.getDescription());
}
@Test
public void createOrcKingdom() {
app.createKingdom(orcFactory);
final King king = app.getKing();
final Castle castle = app.getCastle();
final Army army = app.getArmy();
assertTrue(king instanceof OrcKing);
assertEquals(OrcKing.DESCRIPTION, king.getDescription());
assertTrue(castle instanceof OrcCastle);
assertEquals(OrcCastle.DESCRIPTION, castle.getDescription());
assertTrue(army instanceof OrcArmy);
assertEquals(OrcArmy.DESCRIPTION, army.getDescription());
}
@Test
public void test() throws IOException {
String[] args = {};
App.main(args);
}
}

39
acyclic-visitor/README.md Normal file

@@ -0,0 +1,39 @@
---
layout: pattern
title: Acyclic Visitor
folder: acyclic-visitor
permalink: /patterns/acyclic-visitor/
categories: Behavioral
tags:
- Java
- Difficulty-Intermediate
---
![alt text](./etc/acyclic-visitor.png "Acyclic Visitor")
## Intent
Allow new functions to be added to existing class hierarchies without affecting those hierarchies, and without creating the troublesome dependency cycles that are inherent to the GOF VISITOR Pattern.
## Applicability
This pattern can be used:
* When you need to add a new function to an existing hierarchy without the need to alter or affect that hierarchy.
* When there are functions that operate upon a hierarchy, but which do not belong in the hierarchy itself. e.g. the ConfigureForDOS / ConfigureForUnix / ConfigureForX issue.
* When you need to perform very different operations on an object depending upon its type.
* 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.
## Consequences
The good:
* No dependency cycles between class hierarchies.
* No need to recompile all the visitors if a new one is added.
* Does not cause compilation failure in existing visitors if class hierarchy has a new member.
The bad:
* Violates the principle of least surprise or Liskov's Substitution principle by showing that it can accept all visitors but actually only being interested in particular visitors.
* Parallel hierarchy of visitors has to be created for all members in visitable class hierarchy.
## Related patterns
* [Visitor Pattern](../visitor/README.md)
## Credits
* [Acyclic Visitor](http://condor.depaul.edu/dmumaugh/OOT/Design-Principles/acv.pdf)

@@ -1,113 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
<class id="1" language="java" name="com.iluwatar.factory.method.OrcBlacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/OrcBlacksmith.java" binary="false"
<class-diagram version="1.2.2" icons="true" always-add-relationships="false" generalizations="true" realizations="true"
associations="true" dependencies="false" nesting-relationships="true" router="FAN">
<interface id="1" language="java" name="com.iluwatar.acyclicvisitor.ModemVisitor" project="acyclic-visitor"
file="/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ModemVisitor.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="280" x="-46" y="239"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="2" language="java" name="com.iluwatar.factory.method.Blacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/Blacksmith.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="88" width="280" x="114" y="385"/>
<position height="-1" width="-1" x="860" y="67"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<enumeration id="3" language="java" name="com.iluwatar.factory.method.WeaponType" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/WeaponType.java" binary="false"
<class id="2" language="java" name="com.iluwatar.acyclicvisitor.Modem" project="acyclic-visitor"
file="/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Modem.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="327" y="77"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="3" language="java" name="com.iluwatar.acyclicvisitor.ConfigureForUnixVisitor" project="acyclic-visitor"
file="/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForUnixVisitor.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="196" width="210" x="793" y="385"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</enumeration>
<class id="4" language="java" name="com.iluwatar.factory.method.OrcWeapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/OrcWeapon.java" binary="false" corner="BOTTOM_RIGHT">
<position height="106" width="178" x="806" y="239"/>
<position height="124" width="196" x="647" y="225"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="5" language="java" name="com.iluwatar.factory.method.ElfWeapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/ElfWeapon.java" binary="false" corner="BOTTOM_RIGHT">
<position height="106" width="172" x="594" y="239"/>
<class id="4" language="java" name="com.iluwatar.acyclicvisitor.Zoom" project="acyclic-visitor"
file="/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Zoom.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="203" y="305"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="6" language="java" name="com.iluwatar.factory.method.Weapon" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/Weapon.java" binary="false" corner="BOTTOM_RIGHT">
<position height="70" width="159" x="594" y="385"/>
<interface id="5" language="java" name="com.iluwatar.acyclicvisitor.HayesVisitor" project="acyclic-visitor"
file="/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/HayesVisitor.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="1019" y="468"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="7" language="java" name="com.iluwatar.factory.method.ElfBlacksmith" project="factory-method"
file="/factory-method/src/main/java/com/iluwatar/factory/method/ElfBlacksmith.java" binary="false"
<interface id="6" language="java" name="com.iluwatar.acyclicvisitor.ZoomVisitor" project="acyclic-visitor"
file="/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ZoomVisitor.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="106" width="280" x="274" y="239"/>
<position height="-1" width="-1" x="758" y="467"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="7" language="java" name="com.iluwatar.acyclicvisitor.Hayes" project="acyclic-visitor"
file="/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Hayes.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="479" y="307"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<realization id="8">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="6"/>
</realization>
<realization id="9">
<class id="8" language="java" name="com.iluwatar.acyclicvisitor.ConfigureForDosVisitor" project="acyclic-visitor"
file="/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForDosVisitor.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="142" width="192" x="883" y="225"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<generalization id="9">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="2"/>
</realization>
</generalization>
<realization id="10">
<end type="SOURCE" refId="5"/>
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="6"/>
</realization>
<association id="11">
<end type="SOURCE" refId="4" navigable="false">
<attribute id="12" name="weaponType">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="13" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="14">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="2"/>
<realization id="11">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="5"/>
</realization>
<association id="15">
<end type="SOURCE" refId="5" navigable="false">
<attribute id="16" name="weaponType">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="17" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="12">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="6"/>
</realization>
<realization id="13">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="1"/>
</realization>
<realization id="14">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="1"/>
</realization>
<generalization id="15">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="2"/>
</generalization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>

Binary file not shown.

After

(image error) Size: 26 KiB

76
acyclic-visitor/pom.xml Normal file

@@ -0,0 +1,76 @@
<!--
The MIT License
Copyright (c) 2014 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.21.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.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<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.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@@ -0,0 +1,31 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
/**
* All ModemVisitor interface extends all visitor interfaces. This interface
* provides ease of use when a visitor needs to visit all modem types.
*/
public interface AllModemVisitor extends ZoomVisitor, HayesVisitor{
}

@@ -0,0 +1,55 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
/**
* The Acyclic Visitor pattern allows new functions to be added to existing class
* hierarchies without affecting those hierarchies, and without creating the dependency
* cycles that are inherent to the GoF Visitor pattern, by making the Visitor base class
* degenerate
* <p>
* In this example the visitor base class is {@link ModemVisitor}. The base class of the
* visited hierarchy is {@link Modem} and has two children {@link Hayes} and {@link Zoom}
* each one having its own visitor interface {@link HayesVisitor} and {@link ZoomVisitor}
* respectively. {@link ConfigureForUnixVisitor} and {@link ConfigureForDosVisitor}
* implement each derivative's visit method only if it is required
*/
public class App {
/**
* Program's entry point
*/
public static void main(String[] args) {
ConfigureForUnixVisitor conUnix = new ConfigureForUnixVisitor();
ConfigureForDosVisitor conDos = new ConfigureForDosVisitor();
Zoom zoom = new Zoom();
Hayes hayes = new Hayes();
hayes.accept(conDos); // Hayes modem with Unix configurator
zoom.accept(conDos); // Zoom modem with Dos configurator
hayes.accept(conUnix); // Hayes modem with Unix configurator
zoom.accept(conUnix); // Zoom modem with Unix configurator
}
}

@@ -0,0 +1,43 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ConfigureForDosVisitor class implements both zoom's and hayes' visit method
* for Dos manufacturer
*/
public class ConfigureForDosVisitor implements AllModemVisitor {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class);
public void visit(Hayes hayes) {
LOGGER.info(hayes + " used with Dos configurator.");
}
public void visit(Zoom zoom) {
LOGGER.info(zoom + " used with Dos configurator.");
}
}

@@ -0,0 +1,40 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ConfigureForUnixVisitor class implements zoom's visit method for Unix
* manufacturer, unlike traditional visitor pattern, this class may selectively implement
* visit for other modems.
*/
public class ConfigureForUnixVisitor implements ZoomVisitor {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForUnixVisitor.class);
public void visit(Zoom zoom) {
LOGGER.info(zoom + " used with Unix configurator.");
}
}

@@ -0,0 +1,56 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Hayes class implements its accept method
*/
public class Hayes extends Modem {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class);
/**
* Accepts all visitors but honors only HayesVisitor
*/
@Override
public void accept(ModemVisitor modemVisitor) {
if (modemVisitor instanceof HayesVisitor) {
((HayesVisitor) modemVisitor).visit(this);
} else {
LOGGER.info("Only HayesVisitor is allowed to visit Hayes modem");
}
}
/**
* Hayes' modem's toString
* method
*/
@Override
public String toString() {
return "Hayes modem";
}
}

@@ -0,0 +1,30 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
/**
* HayesVisitor interface
*/
public interface HayesVisitor extends ModemVisitor {
void visit(Hayes hayes);
}

@@ -0,0 +1,30 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
/**
* Modem abstract class
*/
public abstract class Modem {
public abstract void accept(ModemVisitor modemVisitor);
}

@@ -0,0 +1,32 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
/**
* ModemVisitor interface does not contain any visit methods so that it does not
* depend on the visited hierarchy. Each derivative's visit method is declared in
* its own visitor interface
*/
public interface ModemVisitor {
// Visitor is a degenerate base class for all visitors.
}

@@ -0,0 +1,55 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Zoom class implements its accept method
*/
public class Zoom extends Modem {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class);
/**
* Accepts all visitors but honors only ZoomVisitor
*/
@Override
public void accept(ModemVisitor modemVisitor) {
if (modemVisitor instanceof ZoomVisitor) {
((ZoomVisitor) modemVisitor).visit(this);
} else {
LOGGER.info("Only ZoomVisitor is allowed to visit Zoom modem");
}
}
/**
* Zoom modem's toString
* method
*/
@Override
public String toString() {
return "Zoom modem";
}
}

@@ -0,0 +1,30 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
/**
* ZoomVisitor interface
*/
public interface ZoomVisitor extends ModemVisitor {
void visit(Zoom zoom);
}

@@ -0,0 +1,39 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
import org.junit.jupiter.api.Test;
import com.iluwatar.acyclicvisitor.App;
/**
* Tests that the Acyclic Visitor example runs without errors.
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
}
}

@@ -0,0 +1,75 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.tuple;
import static org.mockito.Mockito.mock;
import static uk.org.lidalia.slf4jext.Level.INFO;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import com.iluwatar.acyclicvisitor.ConfigureForDosVisitor;
import com.iluwatar.acyclicvisitor.Hayes;
import com.iluwatar.acyclicvisitor.HayesVisitor;
import com.iluwatar.acyclicvisitor.Zoom;
import com.iluwatar.acyclicvisitor.ZoomVisitor;
import uk.org.lidalia.slf4jtest.TestLogger;
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
/**
* ConfigureForDosVisitor test class
*/
public class ConfigureForDosVisitorTest {
TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForDosVisitor.class);
@Test
public void testVisitForZoom() {
ConfigureForDosVisitor conDos = new ConfigureForDosVisitor();
Zoom zoom = new Zoom();
conDos.visit(zoom);
assertThat(logger.getLoggingEvents()).extracting("level", "message").contains(
tuple(INFO, zoom + " used with Dos configurator."));
}
@Test
public void testVisitForHayes() {
ConfigureForDosVisitor conDos = new ConfigureForDosVisitor();
Hayes 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();
}
}

@@ -0,0 +1,65 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.acyclicvisitor;
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 static org.mockito.Mockito.mock;
import uk.org.lidalia.slf4jtest.TestLogger;
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
import org.junit.jupiter.api.Test;
import com.iluwatar.acyclicvisitor.ConfigureForUnixVisitor;
import com.iluwatar.acyclicvisitor.Hayes;
import com.iluwatar.acyclicvisitor.HayesVisitor;
import com.iluwatar.acyclicvisitor.Zoom;
import com.iluwatar.acyclicvisitor.ZoomVisitor;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
/**
* ConfigureForUnixVisitor test class
*/
public class ConfigureForUnixVisitorTest {
TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForUnixVisitor.class);
@AfterEach
public void clearLoggers() {
TestLoggerFactory.clear();
}
@Test
public void testVisitForZoom() {
ConfigureForUnixVisitor conUnix = new ConfigureForUnixVisitor();
Zoom zoom = new Zoom();
conUnix.visit(zoom);
assertThat(logger.getLoggingEvents()).extracting("level", "message").contains(
tuple(INFO, zoom + " used with Unix configurator."));
}
}

@@ -0,0 +1,60 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.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 com.iluwatar.acyclicvisitor.ConfigureForDosVisitor;
import com.iluwatar.acyclicvisitor.ConfigureForUnixVisitor;
import com.iluwatar.acyclicvisitor.Hayes;
import com.iluwatar.acyclicvisitor.HayesVisitor;
/**
* Hayes test class
*/
public class HayesTest {
@Test
public void testAcceptForDos() {
Hayes hayes = new Hayes();
ConfigureForDosVisitor mockVisitor = mock(ConfigureForDosVisitor.class);
hayes.accept(mockVisitor);
verify((HayesVisitor)mockVisitor).visit(eq(hayes));
}
@Test
public void testAcceptForUnix() {
Hayes hayes = new Hayes();
ConfigureForUnixVisitor mockVisitor = mock(ConfigureForUnixVisitor.class);
hayes.accept(mockVisitor);
verifyZeroInteractions(mockVisitor);
}
}

@@ -0,0 +1,59 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.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 com.iluwatar.acyclicvisitor.ConfigureForDosVisitor;
import com.iluwatar.acyclicvisitor.ConfigureForUnixVisitor;
import com.iluwatar.acyclicvisitor.Zoom;
import com.iluwatar.acyclicvisitor.ZoomVisitor;
/**
* Zoom test class
*/
public class ZoomTest {
@Test
public void testAcceptForDos() {
Zoom zoom = new Zoom();
ConfigureForDosVisitor mockVisitor = mock(ConfigureForDosVisitor.class);
zoom.accept(mockVisitor);
verify((ZoomVisitor)mockVisitor).visit(eq(zoom));
}
@Test
public void testAcceptForUnix() {
Zoom zoom = new Zoom();
ConfigureForUnixVisitor mockVisitor = mock(ConfigureForUnixVisitor.class);
zoom.accept(mockVisitor);
verify((ZoomVisitor)mockVisitor).visit(eq(zoom));
}
}

133
adapter/README.md Normal file

@@ -0,0 +1,133 @@
---
layout: pattern
title: Adapter
folder: adapter
permalink: /patterns/adapter/
categories: Structural
tags:
- Java
- Gang Of Four
- Difficulty-Beginner
---
## Also known as
Wrapper
## Intent
Convert the interface of a class into another interface the clients
expect. Adapter lets classes work together that couldn't otherwise because of
incompatible interfaces.
## Explanation
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.
> Yet another example would be a translator translating words spoken by one person to another
In plain words
> Adapter pattern lets you wrap an otherwise incompatible object in an adapter to make it compatible with another class.
Wikipedia says
> In software engineering, the adapter pattern is a software design pattern that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code.
**Programmatic Example**
Consider a captain that can only use rowing boats and cannot sail at all.
First we have interfaces `RowingBoat` and `FishingBoat`
```java
public interface RowingBoat {
void row();
}
public class FishingBoat {
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoat.class);
public void sail() {
LOGGER.info("The fishing boat is sailing");
}
}
```
And captain expects an implementation of `RowingBoat` interface to be able to move
```java
public class Captain implements RowingBoat {
private RowingBoat rowingBoat;
public Captain(RowingBoat rowingBoat) {
this.rowingBoat = rowingBoat;
}
@Override
public void row() {
rowingBoat.row();
}
}
```
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.
```java
public class FishingBoatAdapter implements RowingBoat {
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoatAdapter.class);
private FishingBoat boat;
public FishingBoatAdapter() {
boat = new FishingBoat();
}
@Override
public void row() {
boat.sail();
}
}
```
And now the `Captain` can use the `FishingBoat` to escape the pirates.
```java
Captain captain = new Captain(new FishingBoatAdapter());
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.
## 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.
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.
## 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-)
* [java.util.Collections#enumeration()](https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#enumeration-java.util.Collection-)
* [javax.xml.bind.annotation.adapters.XMLAdapter](http://docs.oracle.com/javase/8/docs/api/javax/xml/bind/annotation/adapters/XmlAdapter.html#marshal-BoundType-)
## Credits
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
* [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)

Binary file not shown.

Before

(image error) Size: 12 KiB

Binary file not shown.

Before

(image error) Size: 29 KiB

@@ -1,24 +0,0 @@
---
layout: pattern
title: Adapter
folder: adapter
permalink: /patterns/adapter/
categories: Structural
tags: Java
---
**Intent:** Convert the interface of a class into another interface the clients
expect. Adapter lets classes work together that couldn't otherwise because of
incompatible interfaces.
![alt text](./etc/adapter_1.png "Adapter")
**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.
**Real world examples:**
* [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29)

@@ -1,19 +1,52 @@
<?xml version="1.0"?>
<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.6.0</version>
</parent>
<artifactId>adapter</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!--
The MIT License
Copyright (c) 2014-2016 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 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.21.0-SNAPSHOT</version>
</parent>
<artifactId>adapter</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<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-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@@ -1,25 +1,60 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.adapter;
/**
*
* There are two variations of the Adapter pattern: The class adapter implements
* the adaptee's interface whereas the object adapter uses composition to
* contain the adaptee in the adapter object. This example uses the object
* adapter approach.
* An adapter helps two incompatible interfaces to work together. This is the real world definition
* for an adapter. Interfaces may be incompatible but the inner functionality should suit the need.
* The Adapter design pattern allows otherwise incompatible classes to work together by converting
* the interface of one class into an interface expected by the clients.
*
* <p>
* The Adapter ({@link GnomeEngineer}) converts the interface of the target class
* ({@link GoblinGlider}) into a suitable one expected by the client
* ({@link GnomeEngineeringManager}).
*
* There are two variations of the Adapter pattern: The class adapter implements the adaptee's
* interface whereas the object adapter uses composition to contain the adaptee in the adapter
* object. This example uses the object adapter approach.
*
* <p>
* The Adapter ({@link FishingBoatAdapter}) converts the interface of the adaptee class (
* {@link FishingBoat}) into a suitable one expected by the client ( {@link RowingBoat} ).
*
* <p>
* The story of this implementation is this. <br>
* Pirates are coming! we need a {@link RowingBoat} to flee! We have a {@link FishingBoat} and our
* captain. We have no time to make up a new ship! we need to reuse this {@link FishingBoat}. The
* captain needs a rowing boat which he can operate. The spec is in {@link RowingBoat}. We will
* use the Adapter pattern to reuse {@link FishingBoat}.
*
*/
public class App {
/**
* Program entry point
* @param args command line args
*/
public static void main(String[] args) {
Engineer manager = new GnomeEngineeringManager();
manager.operateDevice();
}
/**
* Program entry point.
*
* @param args command line args
*/
public static void main(String[] args) {
// The captain can only operate rowing boats but with adapter he is able to use fishing boats as well
Captain captain = new Captain(new FishingBoatAdapter());
captain.row();
}
}

@@ -0,0 +1,47 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.adapter;
/**
* The Captain uses {@link RowingBoat} to sail. <br>
* This is the client in the pattern.
*/
public class Captain {
private RowingBoat rowingBoat;
public Captain() {}
public Captain(RowingBoat rowingBoat) {
this.rowingBoat = rowingBoat;
}
public void setRowingBoat(RowingBoat rowingBoat) {
this.rowingBoat = rowingBoat;
}
public void row() {
rowingBoat.row();
}
}

@@ -1,12 +0,0 @@
package com.iluwatar.adapter;
/**
*
* Engineers can operate devices.
*
*/
public interface Engineer {
void operateDevice();
}

@@ -0,0 +1,42 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.adapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* Device class (adaptee in the pattern). We want to reuse this class.
* Fishing boat moves by sailing.
*
*/
public class FishingBoat {
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoat.class);
public void sail() {
LOGGER.info("The fishing boat is sailing");
}
}

@@ -0,0 +1,43 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.adapter;
/**
*
* Adapter class. Adapts the interface of the device ({@link FishingBoat}) into {@link RowingBoat}
* interface expected by the client ({@link Captain}).
*
*/
public class FishingBoatAdapter implements RowingBoat {
private FishingBoat boat;
public FishingBoatAdapter() {
boat = new FishingBoat();
}
@Override
public void row() {
boat.sail();
}
}

@@ -1,24 +0,0 @@
package com.iluwatar.adapter;
/**
*
* Adapter class. Adapts the interface of the device ({@link GoblinGlider}) into
* {@link Engineer} interface expected by the client ({@link GnomeEngineeringManager}).
*
*/
public class GnomeEngineer implements Engineer {
private GoblinGlider glider;
public GnomeEngineer() {
glider = new GoblinGlider();
}
@Override
public void operateDevice() {
glider.attachGlider();
glider.gainSpeed();
glider.takeOff();
}
}

@@ -1,20 +0,0 @@
package com.iluwatar.adapter;
/**
*
* GnomeEngineering manager uses {@link Engineer} to operate devices.
*
*/
public class GnomeEngineeringManager implements Engineer {
private Engineer engineer;
public GnomeEngineeringManager() {
engineer = new GnomeEngineer();
}
@Override
public void operateDevice() {
engineer.operateDevice();
}
}

@@ -1,21 +0,0 @@
package com.iluwatar.adapter;
/**
*
* Device class (adaptee in the pattern).
*
*/
public class GoblinGlider {
public void attachGlider() {
System.out.println("Glider attached.");
}
public void gainSpeed() {
System.out.println("Gaining speed.");
}
public void takeOff() {
System.out.println("Lift-off!");
}
}

@@ -0,0 +1,34 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.adapter;
/**
* The interface expected by the client.<br>
* A rowing boat is rowed to move.
*
*/
public interface RowingBoat {
void row();
}

@@ -0,0 +1,78 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.adapter;
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
*
*/
public class AdapterPatternTest {
private Map<String, Object> beans;
private static final String FISHING_BEAN = "fisher";
private static final String ROWING_BEAN = "captain";
/**
* This method runs before the test execution and sets the bean objects in the beans Map.
*/
@BeforeEach
public void setup() {
beans = new HashMap<>();
FishingBoatAdapter fishingBoatAdapter = spy(new FishingBoatAdapter());
beans.put(FISHING_BEAN, fishingBoatAdapter);
Captain captain = new Captain();
captain.setRowingBoat((FishingBoatAdapter) beans.get(FISHING_BEAN));
beans.put(ROWING_BEAN, captain);
}
/**
* This test asserts that when we use the row() method on a captain bean(client), it is
* internally calling sail method on the fishing boat object. The Adapter ({@link FishingBoatAdapter}
* ) converts the interface of the target class ( {@link FishingBoat}) into a suitable one
* expected by the client ({@link Captain} ).
*/
@Test
public void testAdapter() {
Captain captain = (Captain) beans.get(ROWING_BEAN);
// when captain moves
captain.row();
// the captain internally calls the battleship object to move
RowingBoat adapter = (RowingBoat) beans.get(FISHING_BEAN);
verify(adapter).row();
}
}

@@ -1,19 +1,38 @@
/**
* The MIT License
* Copyright (c) 2014-2016 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.adapter;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.iluwatar.adapter.App;
import java.io.IOException;
/**
*
* Application test
*
* Tests that Adapter example runs without errors.
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
}
@Test
public void test() throws IOException {
String[] args = {};
App.main(args);
}
}

@@ -0,0 +1,29 @@
---
layout: pattern
title: Aggregator Microservices
folder: aggregator-microservices
permalink: /patterns/aggregator-microservices/
categories: Architectural
tags:
- Java
- Spring
---
## Intent
The user makes a single call to the Aggregator, and the aggregator then calls each relevant microservice and collects
the data, apply business logic to it, and further publish is as a REST Endpoint.
More variations of the aggregator are:
- Proxy Microservice Design Pattern: A different microservice is called upon the business need.
- Chained Microservice Design Pattern: In this case each microservice is dependent/ chained to a series
of other microservices.
![alt text](./etc/aggregator-microservice.png "Aggregator Microservice")
## Applicability
Use the Aggregator Microservices pattern when you need a unified API for various microservices, regardless the client device.
## Credits
* [Microservice Design Patterns](http://blog.arungupta.me/microservice-design-patterns/)

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright (c) 2014-2016 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">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.21.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-service</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<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-api</artifactId>
<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-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@@ -0,0 +1,58 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.aggregator.microservices;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* The aggregator aggregates calls on various micro-services, collects
* data and further publishes them under a REST endpoint.
*/
@RestController
public class Aggregator {
@Resource
private ProductInformationClient informationClient;
@Resource
private ProductInventoryClient inventoryClient;
/**
* Retrieves product data.
*
* @return a Product.
*/
@RequestMapping("/product")
public Product getProduct() {
Product product = new Product();
product.setTitle(informationClient.getProductTitle());
product.setProductInventories(inventoryClient.getProductInventories());
return product;
}
}

@@ -0,0 +1,42 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.aggregator.microservices;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Spring Boot EntryPoint Class
*/
@SpringBootApplication
public class App {
/**
* Program entry point
*
* @param args command line args
*/
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}

@@ -0,0 +1,57 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.aggregator.microservices;
/**
* Encapsulates all the data for a Product that clients will request.
*/
public class Product {
/**
* The title of the product.
*/
private String title;
/**
* The inventories of the 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;
}
}

@@ -0,0 +1,32 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.aggregator.microservices;
/**
* Interface for the Information micro-service.
*/
public interface ProductInformationClient {
String getProductTitle();
}

@@ -0,0 +1,57 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.aggregator.microservices;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* An adapter to communicate with information micro-service.
*/
@Component
public class ProductInformationClientImpl implements ProductInformationClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInformationClientImpl.class);
@Override
public String getProductTitle() {
String response = null;
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:51515/information");
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
LOGGER.error("Exception caught.", e);
}
return response;
}
}

@@ -0,0 +1,31 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.aggregator.microservices;
/**
* Interface to Inventory micro-service.
*/
public interface ProductInventoryClient {
int getProductInventories();
}

@@ -0,0 +1,57 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.aggregator.microservices;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* An adapter to communicate with inventory micro-service.
*/
@Component
public class ProductInventoryClientImpl implements ProductInventoryClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInventoryClientImpl.class);
@Override
public int getProductInventories() {
String response = "0";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:51516/inventories");
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
LOGGER.error("Exception caught.", e);
}
return Integer.parseInt(response);
}
}

@@ -0,0 +1,24 @@
#
# The MIT License
# Copyright (c) 2014-2016 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.
#
server.port=50004

@@ -0,0 +1,70 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.aggregator.microservices;
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 {
@InjectMocks
private Aggregator aggregator;
@Mock
private ProductInformationClient informationClient;
@Mock
private ProductInventoryClient inventoryClient;
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
}
/**
* Tests getting the data for a desktop client
*/
@Test
public void testGetProduct() {
String title = "The Product Title.";
int inventories = 5;
when(informationClient.getProductTitle()).thenReturn(title);
when(inventoryClient.getProductInventories()).thenReturn(inventories);
Product testProduct = aggregator.getProduct();
assertEquals(title, testProduct.getTitle());
assertEquals(inventories, testProduct.getProductInventories());
}
}

Binary file not shown.

After

(image error) Size: 40 KiB

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright (c) 2014-2016 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">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.21.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>information-microservice</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<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-api</artifactId>
<scope>test</scope>
</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>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@@ -0,0 +1,37 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.information.microservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Inventory Application starts container (Spring Boot) and exposes the Inventory micro-service.
*/
@SpringBootApplication
public class InformationApplication {
public static void main(String[] args) {
SpringApplication.run(InformationApplication.class, args);
}
}

@@ -0,0 +1,44 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.information.microservice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Controller providing endpoints to retrieve information about products
*/
@RestController
public class InformationController {
/**
* Endpoint to retrieve a product's informations.
*
* @return product inventory.
*/
@RequestMapping(value = "/information", method = RequestMethod.GET)
public String getProductTitle() {
return "The Product Title.";
}
}

@@ -0,0 +1,24 @@
#
# The MIT License
# Copyright (c) 2014-2016 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.
#
server.port=51515

@@ -0,0 +1,43 @@
/**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.information.microservice;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Information Rest Controller
*/
public class InformationControllerTest {
@Test
public void shouldGetProductTitle() {
InformationController infoController = new InformationController();
String title = infoController.getProductTitle();
assertEquals("The Product Title.", title);
}
}

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright (c) 2014-2016 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">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.21.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>inventory-microservice</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<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-api</artifactId>
<scope>test</scope>
</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>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

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