Compare commits
102 Commits
Author | SHA1 | Date | |
---|---|---|---|
c5e6dcc11b | |||
6026eedd51 | |||
b030cd4eba | |||
6aa58e8ae6 | |||
914d1353a1 | |||
df32a7b893 | |||
c4c5e78e50 | |||
3cf2b34d2a | |||
27e8cb7f2d | |||
e685512ed5 | |||
59e6a0af85 | |||
626c56730c | |||
a85463470e | |||
4410419914 | |||
e17d72bca8 | |||
121ed3cca8 | |||
adc6019c7e | |||
0f2807b9cf | |||
1b10ddbb73 | |||
348e577e8e | |||
22821ba8cc | |||
4493341ba6 | |||
3cb872807e | |||
ab68129829 | |||
e57a0948ef | |||
ff23e90c4f | |||
fa52a7f77e | |||
165d1f1298 | |||
be2c7fdb2b | |||
90c636abd3 | |||
678a06e7f8 | |||
e425c2ef2f | |||
5c1a4f1caf | |||
58dce1bd89 | |||
9dd1503e6f | |||
09037b0251 | |||
36fe249960 | |||
e73867f9a1 | |||
59cf100302 | |||
ad11ea46b1 | |||
5796e1967f | |||
483c61a82a | |||
6575b3ae99 | |||
095adda7e9 | |||
f16ae08bdf | |||
95cf9fe367 | |||
28647cdf48 | |||
fdcf546112 | |||
a0c77c32b5 | |||
eb75773891 | |||
c79df708b1 | |||
56100927a9 | |||
7e77216919 | |||
b16d7fc970 | |||
0b36a3153d | |||
7c2f5da926 | |||
ffbc5f2f29 | |||
d50139e13e | |||
d484e7f731 | |||
76970633b8 | |||
55028a49dc | |||
94c3a2caf3 | |||
547d798528 | |||
e7be94d2e4 | |||
383e4a3a0b | |||
3001fa4a30 | |||
5fcef89384 | |||
40ac552542 | |||
09ba5ca656 | |||
eb560f5f54 | |||
2b945ca27f | |||
4bd1f14cfb | |||
bc94d0fc26 | |||
102341443d | |||
8124fd0771 | |||
ea7503414e | |||
d4c2f0392d | |||
f7b7f15ec8 | |||
0fbbd8dc81 | |||
9f0320aeaf | |||
fe1d760c7f | |||
b46d2deeb0 | |||
f182e87ee1 | |||
85f432fb54 | |||
7be98fa829 | |||
ff8037ee0b | |||
849df50394 | |||
f806c5b712 | |||
ef2ada4fdf | |||
5d58a1b333 | |||
4a069ee93a | |||
88321890c7 | |||
b1e40d9c92 | |||
5c26f46174 | |||
4eac37c6b5 | |||
c212ee5cb1 | |||
8efaf44170 | |||
27e4e9afee | |||
35c0942803 | |||
0282d6663f | |||
c8f04d2f0d | |||
53fc8b749a |
20
.travis.yml
20
.travis.yml
@ -11,8 +11,28 @@ before_install:
|
|||||||
- export DISPLAY=:99.0
|
- export DISPLAY=:99.0
|
||||||
- sh -e /etc/init.d/xvfb start
|
- sh -e /etc/init.d/xvfb start
|
||||||
|
|
||||||
|
# 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:
|
after_success:
|
||||||
- mvn clean test jacoco:report coveralls:report
|
- mvn clean test jacoco:report coveralls:report
|
||||||
- bash update-ghpages.sh
|
- 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: false # route the build to the container-based infrastructure for a faster build
|
sudo: false # route the build to the container-based infrastructure for a faster build
|
||||||
|
@ -24,7 +24,7 @@ are familiar with the patterns.
|
|||||||
# Getting started
|
# Getting started
|
||||||
|
|
||||||
Before you dive into the material, you should be familiar with various
|
Before you dive into the material, you should be familiar with various
|
||||||
[Programming/Software Design Principles](http://webpro.github.io/programming-principles/).
|
Programming/Software Design Principles.
|
||||||
|
|
||||||
All designs should be as simple as possible. You should start with KISS, YAGNI,
|
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
|
and Do The Simplest Thing That Could Possibly Work principles. Complexity and
|
||||||
|
190
_scripts/postPumlsToServer.firstrun.output
Normal file
190
_scripts/postPumlsToServer.firstrun.output
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
parent: half-sync-half-async; artifact: half-sync-half-async
|
||||||
|
Puml Server ID: RScv3SCm3030LU819FRPXg5fIm552tnYPFiyjRi3RkbAaYkdoQr5JBy369vrxz7oaSv6XmPhL3e6TCaJ0msU-CAoilTToyG8DdKOw5z0GzcAlvNAN_WZSD1brBHHPmxv0000
|
||||||
|
parent: abstract-document; artifact: abstract-document
|
||||||
|
Puml Server ID: PSjB3eCm34NHhPG599vtDyQn85L-ifzX-p3lxEf8Twj3MXGDQvyJMFubChxpKN767gucSq07iinEjSNDOACVNvoAUZr6MWoe3QVE_WRnxZ0Mf38b-hkIGlurX_MyehS7
|
||||||
|
parent: tolerant-reader; artifact: tolerant-reader
|
||||||
|
Puml Server ID: NSZ14SCm20NHLf829ExfXaYChGn26lZ4xSVdtFRjSrZJx9AkZnFOyI9olkenSEOxGxmjWnXgMvE6viLWfmz_kNI9SLZP38XRqEIuWx1Kd0t5XVjjGVj_DNtMdLD_
|
||||||
|
parent: event-driven-architecture; artifact: event-driven-architecture
|
||||||
|
Puml Server ID: TOhH3SCW30LNQGS0_tSRnrZ15H1adfFromBzkfFktZQaHT7mzgh0N1yYvoUVXXf7B7Mv1dGWozN9MZmCTlhopQdeidEaoO3wMDHvRI6zzvwAssPYbsfGGRYIGlxN7DxpZDv-
|
||||||
|
parent: publish-subscribe; artifact: publish-subscribe
|
||||||
|
Puml Server ID: PSZB3SCm203GLTe1RExT1XCKKs5YyMdMR--zFRsd66aTNAwFcRdZ1U1uzrDorgXWfykIBJjT2qJhnaI7Dtwm7HnoMjkOoMu12-C7s3LKOhQe4UGo63ZfVtlvwhkMVW40
|
||||||
|
parent: facade; artifact: facade
|
||||||
|
Puml Server ID: BSP15eCm20N0gxG7CEoz3ILKqvTW7dpq-hhehERTJ7fMJU-l7PYn4ZbVPMlOyvEXBeT13KMEGQtdnM2d7v-yL8sssJ8PKBUWmV64lYnSbHJoRqaVPUReDm00
|
||||||
|
parent: service-locator; artifact: service-locator
|
||||||
|
Puml Server ID: NSjB3iCm203HgxG7iDdtDeIWX0fZYqzo_MRTtUX9ynOZhPtBzNLchlW0EDxza3nhgs2dQScMdUO0qRenqU6B5xQTGmvh2pFPBM1WF07FSmbnqqcOqu6J_gsNZxvgw0y0
|
||||||
|
parent: dao; artifact: dao
|
||||||
|
Puml Server ID: 5SR14OKW30N0LhG0oVrt4o6ZE12Ov4NR_thQNQlc5aN2sd82qtz4naywAixOmyNoK8WYvT6fjdWOR7JnpLiHhuTkam4nTUhiRwZm847-J64zpUZj3m00
|
||||||
|
parent: model-view-presenter; artifact: model-view-presenter
|
||||||
|
Puml Server ID: ROlR3SGW3C1MkGu0-RzjKeXQJWcWFChwPO3xispvQBrmL0hbp-q-xGkWkFBL_8upZBICxjGzbo7GE1OwAlpmmLJ9sjNJH7VIRY1e6q169KvFevMcakrtI_BoD-HGoJE4Nm00
|
||||||
|
parent: observer; artifact: observer
|
||||||
|
Puml Server ID: FSkn4OGm30NHLg00hFow4KO3PcpP8tr1-pYwx6smQz5Suv2mkbp0y1-HyPlEWYlsSB7S5Q98kJSgDLu66ztyy7Q8brEtmO2OEZNs2Uhxl9u9GVv72cjfHAiV
|
||||||
|
parent: intercepting-filter; artifact: intercepting-filter
|
||||||
|
Puml Server ID: RSfB3i8m303Hgy014k-vZN5DQkIuaJ_q-fGzkz7JtCL8Q-DolUsPAnu0ZcSVadizAzZfi6JBJiS4qJenqU6D7smRXmnh2pFPBM1YN05o_KwyKcoqb-ZFEEcVz_BPLqtz0W00
|
||||||
|
parent: factory-method; artifact: factory-method
|
||||||
|
Puml Server ID: NSZB3G8n30N0Lg20n7UwCOxPP9MVx6TMT0zdRgEvjoazYeRrMmMsFuYChtmqr7Y6gycQq8aiQr3hSJ7OwEGtfwBUZfas0shJQR3_G2yMBFkaeQYha4B-AeUDl6FqBm00
|
||||||
|
parent: private-class-data; artifact: private-class-data
|
||||||
|
Puml Server ID: RShR3SCm243HLTe1RFwx3S4eeSB4uf6itmpGlwkZ-nOZhS7b-ZeoLtm07E--InwrLR3JQScMdSu9edLZeiCNBso3GtPh2pFPBM1YF07BvSBaHeeHRJm_SD8VxkMphvhw0m00
|
||||||
|
parent: async-method-invocation; artifact: async-method-invocation
|
||||||
|
Puml Server ID: TSdB3SCW303GLTe1mFTkunWhk0A3_4dKxTi5UdlIUuhIoCPfuz4Zjhy03EzwIlGyqjbeQR16fJL1HjuOQF362qjZbrFBnWWsTPZeFm3wHwbCZhvQ4RqMOSXIuA1_LzDctJd75m00
|
||||||
|
parent: execute-around; artifact: execute-around
|
||||||
|
Puml Server ID: NSZ14G8n20NGLhI0XBlT865suoGa0n_NylNixSsxTvEHJTF7xGHsF8YShtfqdFdCK9TbK4ELDQcFl1ZizE8tbwRH3okR0NKBcXm_a7vK4bhOLreZXVnLJPzrvnnV
|
||||||
|
parent: monostate; artifact: monostate
|
||||||
|
Puml Server ID: HSV14OGm20NGLjO23FVj1YEZsGaa0nzjVxrvUszfLdlkaju_9p3ZI-HybwFXp2r3l0w364eTIgtdpM2d7r-yxXBji7Ko86v1ol60TDW8C8G4zLr9rp9J-ny0
|
||||||
|
parent: thread-pool; artifact: thread-pool
|
||||||
|
Puml Server ID: JSV14SCW30J0Lk82GFzq8uF6a1624IUx_UIPt-xHhMXK2TTN0zP-4pa_-UfeSSOMBzCWXbpceAxnCDZfmpUdAhjVbXO3uhPfyFw1q5oufZMdag3yFuUFl6Be5m00
|
||||||
|
parent: delegation; artifact: delegation
|
||||||
|
Puml Server ID: JSV14GCX20NGLf82LkxfXbN69OFeu2VRVdBCxRsdUhLiac6F2rZxHHHybwwuyimjKQT37ANEGMfvCpZepHy-ccpjVYm697pJuFq3DJ7f39rEWlhNaZ7Aoc5V
|
||||||
|
parent: chain; artifact: chain
|
||||||
|
Puml Server ID: 9SR13SCm20NGLTe1OkxTXX0KKzd4Wa-pVYlrdTxJN4OTMZ4U7LZv8Wg-ssdejLTgoELGHvDhaesw6HpqvWzlXwQTlYq6D3nfSlv2qjcS5F9VgvXjrHnV
|
||||||
|
parent: resource-acquisition-is-initialization; artifact: resource-acquisition-is-initialization
|
||||||
|
Puml Server ID: ZShR3S8m343HLUW0YV_PnhXMQvGumOzMOdhA1lqxkhgBABLSEQqzzeZfJm33isuIUxxIsMXei4QbqK5QdXXeyCO3oyekcvQ94MpgqD4lWB6FDEA2z4bn2HbQn8leHMponNy13hgvrhHUP_Rs0m00
|
||||||
|
parent: fluentinterface; artifact: fluentinterface
|
||||||
|
Puml Server ID: NOj93eCm302_KXv0VEzlN6F0bMCYB_3zvjpRQ3IpY97MnkNwEZD7l04SdtP8dlMfOAVBaYqRNHr4wy54Xo_Uk6uSSjWwC9FT0Zh61DYrPY_pyXs9WPF-NIllRLJN7m00
|
||||||
|
parent: service-layer; artifact: service-layer
|
||||||
|
Puml Server ID: LOl93SCm3C1MQGUmzUysgY8aAcJ5q96WszVV_aW2V8gHriRb-ZWoPxm07E--Inxrhc2dqv8jEvq3HEl6H8SFNjWs3jcjJSnaju21iG3MSmbnK_mkuwJ_qij7dpNq1m00
|
||||||
|
parent: visitor; artifact: visitor
|
||||||
|
Puml Server ID: DSR14OGm20NGLhG0mtsxmSWeJa8oyD7sTo_xJczLgoqFIM_B1Spu43c_vLHSkMU8rs4GGwcZaxPy6UnqyyFR8Q6dRPC1SGlg7B_Gew4OJeBwVqdlPMPlNm00
|
||||||
|
parent: double-dispatch; artifact: double-dispatch
|
||||||
|
Puml Server ID: NSbB3iCW303HgpG70Ezx6yTOWSeOv4zp_MRTtUZDCPGa6wV9gqTiVmCOtlKQqVDCPwEbmHgLreGXUMEWmGU_M1hxkBHiZ61JXud-1BILft1fmvz37JZetshQh3kd_000
|
||||||
|
parent: monad; artifact: monad
|
||||||
|
Puml Server ID: 9SR13SCm20NGLPe1OkxTXjWeSMMm1Pza_LRgExsjMntP97syBc35cyZvAMV7bKU6U9q6CPGwbVh8Xy5E7xvvRnBzj7qn86v1ol4BwJHk9AZ_bNGjAtLy0G00
|
||||||
|
parent: front-controller; artifact: front-controller
|
||||||
|
Puml Server ID: PSlB3OGm303HLfO24j-t6nCC13bEvC_IFk6yjz6JPgbIE3OAvS_fFkmBe7Zde_ePQnXfwU8adajlK3bkT5Iuy8Tf8wk7f87kf6BGq6R0hlD8xwQTUG9v-SCSslA8nWy0
|
||||||
|
parent: strategy; artifact: strategy
|
||||||
|
Puml Server ID: FSV13OCm30NGLM00udktCS4AGOaJsTz5tRwSkBstLiqj3WbhombC_n0PtwbKdB67Y-MX44NAerDjSJFOwE8lRuTuBRfD1iJKgRC_88SnfFn8aD-ai9vczFO7
|
||||||
|
parent: command; artifact: command
|
||||||
|
Puml Server ID: DSgn4OCm30NGLM00h3xR25i7vYpXaxx2-g59zugtTgiZcwIFvGHcV8YSdt9qdBbdYDVR88PIRwK-yc6mqyLVtff4FsoR38XRa7Aye3SgMoD1_RkaQvcfumS0
|
||||||
|
parent: abstract-factory; artifact: abstract-factory
|
||||||
|
Puml Server ID: PSZB3OD034NHLa81Czwd6sCC39gVxEUWT1_ssLmTtQLqgR5fM7sTmFGtaV6TZu8prd0r6HtQaMKqAZLk1XjT_E6qgPUZfyc0MdTgx0-8LuUn8ErFXdr98NypXxKyezKV
|
||||||
|
parent: flux; artifact: flux
|
||||||
|
Puml Server ID: 7SP14eCm20NGg-W13FlU1YFLE0GpyAazVZk-rPkRLSrDqdKwW14l8kUxx0r7hXdYzJA8eTIhKzEy6UnqyeUNJQBjjWm6n2seS_n3Ryql2UgJajxBoAu_
|
||||||
|
parent: event-aggregator; artifact: event-aggregator
|
||||||
|
Puml Server ID: PSf13iCW30NHgxG70Ezx6uTOX0eCih-JwvTzTwEdUJSjFKu9wwyBMFuXCdvoRRZY21ShKo6ANEQWrkDXiD6NRqwdUAkQ5WDYwZJOTv3SUqzSgqbbp0qeVvZ3Hbun-Wy0
|
||||||
|
parent: singleton; artifact: singleton
|
||||||
|
Puml Server ID: HSV14SCm20J0Lk82BFxf1ikCh0n26ZZizfDVVhjRjwfvIhg-Bc35cyZvAQtZoYD3l4w364gTWxhcms2d3z-ydnAzsRuO4BUWmV43HRUcWcaagF-Lz55M3lq2
|
||||||
|
parent: null-object; artifact: null-object
|
||||||
|
Puml Server ID: JSV14SCm20J0Lk829Fxf1cF6bWSX3JhYzfDdVhjRSx4yDCDU5p3NcoZugMV3bNik3HaETLGPdPhbm-2WcpzS3btjz38PqF15dTSFv6bMndwhW1Jo_vhHwynkNm00
|
||||||
|
parent: multiton; artifact: multiton
|
||||||
|
Puml Server ID: FST14i8m20NGg-W16lRUXgPCYnD81Zxs-hfozzvJlOywf68yBc3bYoZuRgVYghrIea-7E5gVHZhgPd3Gcp-y7P9w-hOOaF0au_o1h0OKqqdG_saLrbRP-080
|
||||||
|
parent: composite; artifact: composite
|
||||||
|
Puml Server ID: HSf13eCm30NHgy01YFUzZGaM62LEP7-NwvTTT_EaMTLgoqFIst81Cpv4payv5LVk6U9r6CHGwkYaBHy6EztyvUsGqDEsoO2u1NMED-WTvmY5aA3-LT9xcTdR3m00
|
||||||
|
parent: api-gateway; artifact: image-microservice
|
||||||
|
Puml Server ID: 3Sp13SCm2030LTe1RFxTXX3aK1biOOZLxPlVlUujHZrFJk-lAsAk3u3ZhatYoYCNEmqBjgWq5AJdna27BzvOJbxIh4oCOBS5Yki1u9JIC7ZZ3pW8HB5nKI4VJtSBSKtNEbFx7m00
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'api-gateway/etc/image-microservice.urm.puml'
|
||||||
|
pumlid: 3Sp13SCm2030LTe1RFxTXX3aK1biOOZLxPlVlUujHZrFJk-lAsAk3u3ZhatYoYCNEmqBjgWq5AJdna27BzvOJbxIh4oCOBS5Yki1u9JIC7ZZ3pW8HB5nKI4VJtSBSKtNEbFx7m00
|
||||||
|
parent: api-gateway; artifact: api-gateway-service
|
||||||
|
Puml Server ID: JSox3SCm303HLP819FRUXg49cO542_nOyFPncUvUSszHwhbpMdyT4TCt0CDLcyIHdtGsEZLOez8vG7ek33JuueLbPvUcPM84cpeCz2S0fvI6mGjluA1_b-Tt2N5D6tNcw3y0
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'api-gateway/etc/api-gateway-service.urm.puml'
|
||||||
|
pumlid: JSox3SCm303HLP819FRUXg49cO542_nOyFPncUvUSszHwhbpMdyT4TCt0CDLcyIHdtGsEZLOez8vG7ek33JuueLbPvUcPM84cpeCz2S0fvI6mGjluA1_b-Tt2N5D6tNcw3y0
|
||||||
|
parent: api-gateway; artifact: price-microservice
|
||||||
|
Puml Server ID: 3Sn13iGW243HgqmFeEpdDfGIoqJK8DJqzkFklyq_f56DYyFgvtOVymjWk78Hl-ECoKQzEJVFr1Mana97Wny-c2wUKbeQwCxM9YZE7O13Ka7dXI-m4mmJugH2rlVksSXXcaTe_GC0
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'api-gateway/etc/price-microservice.urm.puml'
|
||||||
|
pumlid: 3Sn13iGW243HgqmFeEpdDfGIoqJK8DJqzkFklyq_f56DYyFgvtOVymjWk78Hl-ECoKQzEJVFr1Mana97Wny-c2wUKbeQwCxM9YZE7O13Ka7dXI-m4mmJugH2rlVksSXXcaTe_GC0
|
||||||
|
parent: object-pool; artifact: object-pool
|
||||||
|
Puml Server ID: JSV94SCm2030Lk829Fxf1cF6bWU1XYDkFtdcjxiD9Qc3o-LrPQvu0pW-_HnvrLx1JgR9cfrimf1wCD7XnW-sWsESsXPcicl0nFW1RB-PiYqp0KxwVo-VVTMKBm00
|
||||||
|
parent: adapter; artifact: adapter
|
||||||
|
Puml Server ID: DSR14S8m30J0Lg20M7-wEMnDOiPMFDA9j0yyUEtUkzMHJTF7xI1NF4GSLzaxZtncgDVJgCPIpobzv0N2vOKtjgRHTziMI7KBcOXl10thfxB-Nz9dMJd71m00
|
||||||
|
parent: hexagonal; artifact: hexagonal
|
||||||
|
Puml Server ID: HSTB4W8X30N0g-W1XkozpPD90LO8L3wEnzUTk-xxq2fvSfhSUiJs1v7XAcr4psSwMrqQh57gcZGaBmICNdZZEDb7qsCZWasT9lm7wln1MmeXZlfVIPjbvvGl
|
||||||
|
parent: value-object; artifact: value-object
|
||||||
|
Puml Server ID: LSZ13SCm20NGLTe1RExTXX2KECBOmfza_VRQszDxDnVBNJFiTG9pVOY2dteqdBdbqf3XK4ULqQbPFWmEklZcikjgXvV9W8Olwhn-e9ijjOpjKW4fv2zgHgypktq1
|
||||||
|
parent: twin; artifact: twin
|
||||||
|
Puml Server ID: 7SR13OCm30NGLUW0n7UsCS42eyH4zdUpFbNVwNtKQij3qjjo0ICs8kTPJiMLUuPuVGnYAFNff2qdWvrk_l9wIEXfws10t88wno-4gKQ2-az9xsLaRoy0
|
||||||
|
parent: semaphore; artifact: semaphore
|
||||||
|
Puml Server ID: HSV14SCm20J0Lk82BFxf1ikCfOn06ZZizfDVVhjRjphobFJnQi2ADv7pKwwEbaU6U9q6CPGwbVh8Xy5E7xvvFoNwPVjYGDo2bEC72b5URRgGeFvNqhMirF45
|
||||||
|
parent: message-channel; artifact: message-channel
|
||||||
|
Puml Server ID: NSZB3SCm203GLTe1RExTXX1akm9YyMdMRy-zFRtdCf8wkLmUCtF72y3nxcFbhAE2dIvBjknqAIof6nCTtlZ1TdAiOMrZ9hi5ACOFe1o1WnjDD6C1Jlg_NgvzbyeN
|
||||||
|
parent: poison-pill; artifact: poison-pill
|
||||||
|
Puml Server ID: JSZ14SCm20NHLf82BExfXiYCJGOX3NpYzkDZRllsgTwjTgcmnmciV145N-rGdFMkbEZJ8OxMvo2rkXWSzE4lRxka7huj1YGyQN3UGMjgpdkh6Gdwlrl5QAk6_G00
|
||||||
|
parent: aggregator-microservices; artifact: aggregator-service
|
||||||
|
Puml Server ID: JOov3SCm301NIGQGs7iRXYPa1g8ayB7NjuiKwGvtmBrbKC-Tq_hhY5Y-0HXUjKaS-Kbdepc2HrIQ2jBpma23BvvOTdPfeooCO1iEYlu0O6l63MDQKI6Rp-CKOWSE-ey_NzEqhjH-0m00
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'aggregator-microservices/etc/aggregator-service.urm.puml'
|
||||||
|
pumlid: JOov3SCm301NIGQGs7iRXYPa1g8ayB7NjuiKwGvtmBrbKC-Tq_hhY5Y-0HXUjKaS-Kbdepc2HrIQ2jBpma23BvvOTdPfeooCO1iEYlu0O6l63MDQKI6Rp-CKOWSE-ey_NzEqhjH-0m00
|
||||||
|
parent: aggregator-microservices; artifact: information-microservice
|
||||||
|
Puml Server ID: LSnB3i8m303Hgy016k-vZN5DQXGxaJ_jzUcMtKXFcgSOZTgvV3oEp1Kl0CUhTScZtXNiD2tPij5Ka54N9ZfyySHjvv1ksy9CTWjGZ3i0UtVkcDCt5V9vFquX3k0a4FjCLqoPzgUjNDig7Jy0
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'aggregator-microservices/etc/information-microservice.urm.puml'
|
||||||
|
pumlid: LSnB3i8m303Hgy016k-vZN5DQXGxaJ_jzUcMtKXFcgSOZTgvV3oEp1Kl0CUhTScZtXNiD2tPij5Ka54N9ZfyySHjvv1ksy9CTWjGZ3i0UtVkcDCt5V9vFquX3k0a4FjCLqoPzgUjNDig7Jy0
|
||||||
|
parent: aggregator-microservices; artifact: inventory-microservice
|
||||||
|
Puml Server ID: LSpB3G8n303HLg20ZUzqOxnMrYXn8d-oedjovJRIIEyfIYrFJckFAsBw2y3mBbNYodSw6mqDrYWqEaZB6mCDFhZmEDcbwZ4nWaqTEleEm5gDAyQmemlPsCOIOWSE0j6riM7VlrVIUfdPsmy0
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'aggregator-microservices/etc/inventory-microservice.urm.puml'
|
||||||
|
pumlid: LSpB3G8n303HLg20ZUzqOxnMrYXn8d-oedjovJRIIEyfIYrFJckFAsBw2y3mBbNYodSw6mqDrYWqEaZB6mCDFhZmEDcbwZ4nWaqTEleEm5gDAyQmemlPsCOIOWSE0j6riM7VlrVIUfdPsmy0
|
||||||
|
parent: bridge; artifact: bridge
|
||||||
|
Puml Server ID: BSR14SCm20J0Lf82BFxf1akCJ4R26ZZYzkE7zxLljJgoIVfu7S2A3v7pLRhYo3r3l9u6CPHwJjAH5uETllpZhKbejsqn86v1a-CExQwj2mdgqv8-oyev_W00
|
||||||
|
parent: servant; artifact: servant
|
||||||
|
Puml Server ID: DSkn4O0m20NGLNG0G-ys63cDbv0SV7HzRUnUy-QYkSOkONKwWU4haV6JZe8pjd2nt1MYIBatAZKU1XjTVFEoYvT3by60c3erzW_qdPiL9CY_KrXB8rfz0G00
|
||||||
|
parent: lazy-loading; artifact: lazy-loading
|
||||||
|
Puml Server ID: LSXB3W8X303Gg-W1e7jlqu66gIc5zED4JwzRTo_lpjeaEwN9xOpO_W0mlEhWEFD89sjBWpHgMnDOyi90WoU-i7Ho7besHf2fmqJ_0GG_xo8BE-i0YlONDMtMdLE-
|
||||||
|
parent: flyweight; artifact: flyweight
|
||||||
|
Puml Server ID: HSV94S8m3030Lg20M7-w4OvYAoCh7Xtnq3ty-Eq-MQlaJcdow17JNm26gpIEdkzqidffa4Qfrm2MN1XeSEADsqxEJRU94MJgCD1_W4C-YxZr08hwNqaRPUQGBm00
|
||||||
|
parent: mutex; artifact: mutex
|
||||||
|
Puml Server ID: 9SR13OCm30NGLSe0n7UsCS62LB69x6zWV2hrdTxKhFRS9Br_3c34GkHybxtXo3L3l9u6CPHwAhMUDuETldpnl4cqtUR1WBW5ASSlf0bvI53_A-bQHcf_0G00
|
||||||
|
parent: mediator; artifact: mediator
|
||||||
|
Puml Server ID: FSV14SCm20J0Lk82BFxf1akCJKOW3JhizfDNVhkRUktP9AE_Bc2kDr7mKqx5bKSkYJeSuYXr66dFXy517xvvRxBqz7qo8E6BZDSFPDAKCO84zP-IOMMczIy0
|
||||||
|
parent: page-object; artifact: page-object
|
||||||
|
Puml Server ID: JSV14OGW30NGLjO28FVj9iOCua1Wme-sxnxtzjvMJLeS6ju-9p3NbyZvoQNYZ3sMkWo36hACJhN5ms2dYszEXwvQB4q6r6rHv_K3JIwQndwfW1Jo_npUyupUNW00
|
||||||
|
parent: factory-kit; artifact: factory-kit
|
||||||
|
Puml Server ID: JST15i8m20N0g-W14lRU1YcsQ4BooCS-RwzBTpDNSscvQKQx7C1SDwBWi-w68--vD6Gur55bTBAM9uE3dlpcikcotSjaGCCNTLu_q8C58pxbPI25_Bzcz3gpjoy0
|
||||||
|
parent: property; artifact: property
|
||||||
|
Puml Server ID: FSV13OCm30NGLTe1YEziumOBKYMEPN-3s9wUUdlltRJst2Izlmx0OYLolihUSEGdGxnEXIXAdODQpul1Jby-UTaasgwBCI2kGOFZ1pAV9ewR1FMVaZwAvUWF
|
||||||
|
parent: dependency-injection; artifact: dependency-injection
|
||||||
|
Puml Server ID: RSdB3SCW303GLPe1mFTkunWhSGG6-PEesxS3zFQajubIpyPf_NL6B7y363xra3XpJsUZgS4QbUO0wVbWeC65DvR6BeUMXH5iwZ3GVu36YxMnqgU8NamXKu63_aPD6tNbw5y0
|
||||||
|
parent: layers; artifact: layers
|
||||||
|
Puml Server ID: BSR13OCm30NGLSe0n7UsCS62L8w9x6yGszD3t-bDpQhc9kdwEO0H2v7pNVQ68zSCyNeQn53gsQbftWns-lB5yoRHTfi70-8Mr3b-8UL7F4XG_otflOpi-W80
|
||||||
|
parent: producer-consumer; artifact: producer-consumer
|
||||||
|
Puml Server ID: PSjB3iCW303HgxG70Ezx6zTO2HKso9_a-c7VtUX9y-vA8nkdZTSPiVm3O7ZNeyUPttGscXgiKMaAz94t1XhyyCBIsFkXPM44cpe8-WvODbiIMzcdfspXe7-jQL9NodW0
|
||||||
|
parent: builder; artifact: builder
|
||||||
|
Puml Server ID: DSR94O0m2030LhG0mzzkC64KXs26GzlNZw_TcRLADagJwOWOlW8OFcNdE79B9wkN1ccKUdLWoGS33KwySMdalEioC89C7Jhw5zYIfNrIrFybhPUHNLu0
|
||||||
|
parent: specification; artifact: specification
|
||||||
|
Puml Server ID: LSX14i8m20NGg-W16lRU1YcsE0d9mCTUNxVkthoxkVJQjQBVJc3bWoZuQeVXh6UbXao7EfhCGTRhOd3Gcp-yxPfs-BOOqF2amVa3vLAnbmd3ffD2_gTLZBPgz2y0
|
||||||
|
parent: state; artifact: state
|
||||||
|
Puml Server ID: 9SRH3O0m20N0LNG0ox_RO2LQqz867hg-9jxNpKLpZLt2wdG2mrSYuoST1MTiuMAvAqIHSczKQZmCDhhuvcKNBuSkWm4nTMhiNyZ141BaVocifH6jlW00
|
||||||
|
parent: reader-writer-lock; artifact: reader-writer-lock
|
||||||
|
Puml Server ID: RSZB4S8m303HLg00MtUw4R8cCP5bZpwuVL80jttxx4gIZTFaSKOiVm4OxdhqEFETpaPJWpKgpG5TScEWmGU_M1fxFxGiZ61JXu5-1nXZOolR-gqYaoxWe3-xfeswSiWF
|
||||||
|
parent: interpreter; artifact: interpreter
|
||||||
|
Puml Server ID: JSf13eCm30NHgz034E-vZGaM62Kcih_BzQ6xxjv8yr6hBJT9RzC1Z5Y8dE-oAuvSCyJhPH13gLSdRNapsEdaBy-RXEus3mR4BQXpl21zVnykFmlgVvVqNaRszW00
|
||||||
|
parent: template-method; artifact: template-method
|
||||||
|
Puml Server ID: NSZ13SCW30NGLPe1mFTkuu0Lg6n0vZjPlpttzlIEFef6bN1zDM3jDv7paw-E5cTiyJ87P22NQTGr7WOxVVZcL6NtQwJ5WFZOPBn_88WjPKWoGPkL1EN_ShZb5QPV
|
||||||
|
parent: feature-toggle; artifact: feature-toggle
|
||||||
|
Puml Server ID: NSZ14G8X30NGLhG0oDrk8XjPd12OvCTjNy_UthpxiAPvIBhUJc37WyZvgdtWp6U6U5i6CTIs9WtDYy5ER_vmEIH6jx8P4BUWoV43lOIHBWMhTnKIjB-gwRFkdFe5
|
||||||
|
parent: business-delegate; artifact: business-delegate
|
||||||
|
Puml Server ID: POl13SCm3CHMQGU8zUysgYCuBcJ5a4x9-l6_Fu84tzsgvYxf-Zg06HyYvxkqZYE_6UBrD8YXr7DGrxmPxFJZYxTTeZVR9WFY5ZGu5j2wkad4wYgD8IIe_xQaZp9pw0C0
|
||||||
|
parent: naked-objects; artifact: naked-objects-integtests
|
||||||
|
Puml Server ID: LSmn4iCW30NHgoG70FMvZGmQ6ni48tt5ru_RT3kls7VJqgDAM7yTmF8FaV6TzuOZjd2nCXMYo6KEQZrk1XkT_ELKnTkkQJ4Wfaw3_GbIlgIckPrIu2Ge_vBQyziX3izX8wyO_GS0
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'naked-objects/etc/naked-objects-integtests.urm.puml'
|
||||||
|
pumlid: LSmn4iCW30NHgoG70FMvZGmQ6ni48tt5ru_RT3kls7VJqgDAM7yTmF8FaV6TzuOZjd2nCXMYo6KEQZrk1XkT_ELKnTkkQJ4Wfaw3_GbIlgIckPrIu2Ge_vBQyziX3izX8wyO_GS0
|
||||||
|
parent: naked-objects; artifact: naked-objects-dom
|
||||||
|
Puml Server ID: LSZ94SCW3030Lf82G7zt8mkDZOC4eyDkF_dcjxFlhZIoSTfudH7BDm33fnuzpjpJsMXgi4QbAT17FXXeSE6DfR7tGyl223Pr4FGVGF73hSpzOWe73lgVqgRKDAahPNm1
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'naked-objects/etc/naked-objects-dom.urm.puml'
|
||||||
|
pumlid: LSZ94SCW3030Lf82G7zt8mkDZOC4eyDkF_dcjxFlhZIoSTfudH7BDm33fnuzpjpJsMXgi4QbAT17FXXeSE6DfR7tGyl223Pr4FGVGF73hSpzOWe73lgVqgRKDAahPNm1
|
||||||
|
parent: naked-objects; artifact: naked-objects-fixture
|
||||||
|
Puml Server ID: LSX15i8W30N0g-W187jlaq9igH1uoO_r-BfrDs_kJKkFAc7zTW3B7qJ6LzuRZjZ2nSfKY2ANEQZrk1XiTFARKnLlkwR5W9Ww3VOVIFabDStjb08dGVcVz6mVX4aE6td5w5y0
|
||||||
|
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'naked-objects/etc/naked-objects-fixture.urm.puml'
|
||||||
|
pumlid: LSX15i8W30N0g-W187jlaq9igH1uoO_r-BfrDs_kJKkFAc7zTW3B7qJ6LzuRZjZ2nSfKY2ANEQZrk1XiTFARKnLlkwR5W9Ww3VOVIFabDStjb08dGVcVz6mVX4aE6td5w5y0
|
||||||
|
parent: model-view-controller; artifact: model-view-controller
|
||||||
|
Puml Server ID: ROl13SCm201NQGUm-NSRQgE42h258Lw_wR-_qvtkoTOaEwNBuuoOwmNWkEl1SUOx5taR5cHHsr1WoOs13X-yi7HQV5YP645k2nJN3Q2ZavIBQPVVwqFajXJjVwdfMcUgV040
|
||||||
|
parent: proxy; artifact: proxy
|
||||||
|
Puml Server ID: 9SR13OCm30NGLM00udktCS62eCI9x6yesrEfx_Jcehd69c5rEe3X7oBZE-q5HwpXOhahH95oRrHgt0msEldYPHClkow30J5rQko_qB3-VKYG_qjXBOrezGK0
|
||||||
|
parent: memento; artifact: memento
|
||||||
|
Puml Server ID: DSgn4OCm30NGLM00h3xR2AC3SvRiaxx2-g59zugtDgiz3qdlomNC-10vF-Lik7BF4A_388PIXrBh-J3OwUOlRuT4EssR38XRa7Ay81Lz_o11_RkaQvcf_GS0
|
||||||
|
parent: decorator; artifact: decorator
|
||||||
|
Puml Server ID: HSV14SCm20J0Lk82BFxf1YF6LaP26ZZizfDVVhjRC-bPDRs_Bc35cyZvAMV3bKU6kao36ehCGQtdms2d3z-yLursshuOKBUWmV43LPNfZEcaaFzA-YWhH_y2
|
||||||
|
parent: data-mapper; artifact: data-mapper
|
||||||
|
Puml Server ID: JShB3OGm303HLg20nFVjnYGM1CN6ycTfVtFSsnjfzY5jPgUqkLqHwXy0mxUU8wuyqidQ8q4IjJqCO-QBWGOtVh5qyd5AKOmW4mT6Nu2-ZiAekapH_hkcSTNa-GC0
|
||||||
|
parent: caching; artifact: caching
|
||||||
|
Puml Server ID: DSRB4OKm2030LhG0m_rrWyWaE0bc-6ZxpujxsbMKUXwSrfSMCVq7OFYKAj5oJsUZIuCr2bq3fEU3WGOdthWTx59rcnZ1fWu3_GqGKXEjm47VIzeeCqV_0m00
|
||||||
|
parent: reactor; artifact: reactor
|
||||||
|
Puml Server ID: DSR14OGm20NGLjO23FVj1f7Hx2Ga0nzjVxtuJc-f9YrtJM-V4vZn9NA-or5nvfQXBiEWXYAZKsrvCzZfnnUlkqOzR9qCg5jGvtX2hYmOJWfvNz9xcTdR7m00
|
||||||
|
parent: iterator; artifact: iterator
|
||||||
|
Puml Server ID: FSV13OGm30NHLg00uljsOu85HeaJsTzB-yjfBwCtgrfjUKXwMovWneV8-IcduiezGxmEWnXA7PsqvSDWfvk_l1qIUjes6H2teCxnWlGDOpW9wdzAUYypU_i1
|
||||||
|
parent: callback; artifact: callback
|
||||||
|
Puml Server ID: FSVB4S8m30N0Lg20M7UwUL4qYOciUFGXxSE9s-wp6sjjKgwF8tF6YyXnjxtdKMk5E5-MOjdu6jIrRYIStlXWsIJwRij4fhW53SGFn51TmIT9yZ-jVBHPGxy0
|
||||||
|
parent: repository; artifact: repository
|
||||||
|
Puml Server ID: JSV13OCm30NGLM00udktCS42eyI9xE-YRjyUUtjlLQij3qblomNCU14vF-LKNBbdYDTX44EfevEsV1ZiTFERjqD2Jzic0-8Mr3b-89SvGZ7yGuBwrvBUoypUlW00
|
||||||
|
parent: mute-idiom; artifact: mute-idiom
|
||||||
|
Puml Server ID: JSf13iCm20NHgxG7iDdtDjH62PKX5luarq-MtSsJvgtUHdR96AyTcEj357pLJR7dDvT4EnpYgEqmqf4NWuD-V7BfidJpCXcGy4N6wmcoX1Jj-lo2ziUQONMcZHi0
|
||||||
|
parent: prototype; artifact: prototype
|
||||||
|
Puml Server ID: HSV13OCm30NGLM00udktCS62eCInxE-YRj_UUdjlRLfx7fBUbmkmU14vF-Lik7BF4AzJ8OfIvw3Mys6mqyrltWw9Tkfc38XhqE3uWSmd9Zuc9AZ_bVHHB4V_0W00
|
||||||
|
parent: step-builder; artifact: step-builder
|
||||||
|
Puml Server ID: LOZ93SCm3C1MQGQmzUysYYqaAcJ5q96i7t_x8KXkh4soKvfypeZfNm33fnuSP-xfPEtI88tQhW4i-M2WmGzlB9sS3oqJ8yZKOQ0lWOLPzcJfAoZQtwXfeyuSyW80
|
||||||
|
parent: double-checked-locking; artifact: double-checked-locking
|
||||||
|
Puml Server ID: TSdH4SCW203GLTe1bFzkGv1J6qGFeLc_MI1_x-wzkv94uJ1vDVUrFm26LwxTMnonsMYgitgcEQ1BNEXeyCKVfiAxLqqBtTbqmy1z0ygCGpXHOpgv99bqTgt0JW-LmqPUCUGF
|
67
_scripts/postPumlsToServer.py
Normal file
67
_scripts/postPumlsToServer.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
import requests, glob, re, os
|
||||||
|
|
||||||
|
# taken from here: http://stackoverflow.com/a/13641746
|
||||||
|
def replace(file, pattern, subst):
|
||||||
|
# Read contents from file as a single string
|
||||||
|
file_handle = open(file, 'r')
|
||||||
|
file_string = file_handle.read()
|
||||||
|
file_handle.close()
|
||||||
|
|
||||||
|
# Use RE package to allow for replacement (also allowing for (multiline) REGEX)
|
||||||
|
file_string = (re.sub(pattern, subst, file_string))
|
||||||
|
|
||||||
|
# Write contents to file.
|
||||||
|
# Using mode 'w' truncates the file.
|
||||||
|
file_handle = open(file, 'w')
|
||||||
|
file_handle.write(file_string)
|
||||||
|
file_handle.close()
|
||||||
|
|
||||||
|
# list of all puml files
|
||||||
|
fileList = glob.glob('*/etc/*.puml')
|
||||||
|
for puml in fileList:
|
||||||
|
pathSplit = puml.split("/")
|
||||||
|
# parent folder
|
||||||
|
parent = pathSplit[0]
|
||||||
|
# individual artifact/project name
|
||||||
|
artifact = pathSplit[2].replace(".urm.puml", "")
|
||||||
|
print "parent: " + parent + "; artifact: " + artifact
|
||||||
|
|
||||||
|
# do a POST to the official plantuml hosting site with a little trick "!includeurl" and raw github content
|
||||||
|
data = {
|
||||||
|
'text': "!includeurl https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/" + puml
|
||||||
|
}
|
||||||
|
r = requests.post('http://plantuml.com/plantuml/uml', data=data)
|
||||||
|
pumlId = r.url.replace("http://plantuml.com/plantuml/uml/", "")
|
||||||
|
|
||||||
|
# the only thing needed to get a png/svg/ascii from the server back
|
||||||
|
print "Puml Server ID: " + pumlId
|
||||||
|
|
||||||
|
# add the id so jekyll/liquid can use it
|
||||||
|
if (parent == artifact):
|
||||||
|
replace("./" + parent + "/README.md", "categories:", "pumlid: {}\\ncategories:".format(pumlId))
|
||||||
|
else:
|
||||||
|
print "I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file '" + puml + "'\npumlid: {}".format(pumlId)
|
||||||
|
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Abstract Document
|
title: Abstract Document
|
||||||
folder: abstract-document
|
folder: abstract-document
|
||||||
permalink: /patterns/abstract-document/
|
permalink: /patterns/abstract-document/
|
||||||
|
pumlid: PSjB3eCm34NHhPG599vtDyQn85L-ifzX-p3lxEf8Twj3MXGDQvyJMFubChxpKN767gucSq07iinEjSNDOACVNvoAUZr6MWoe3QVE_WRnxZ0Mf38b-hkIGlurX_MyehS7
|
||||||
categories: Structural
|
categories: Structural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
59
abstract-document/etc/abstract-document.urm.puml
Normal file
59
abstract-document/etc/abstract-document.urm.puml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.abstractdocument.domain {
|
||||||
|
class Part {
|
||||||
|
+ Part(properties : Map<String, Object>)
|
||||||
|
}
|
||||||
|
interface HasPrice {
|
||||||
|
+ PROPERTY : String {static}
|
||||||
|
+ getPrice() : Optional<Number>
|
||||||
|
}
|
||||||
|
interface HasParts {
|
||||||
|
+ PROPERTY : String {static}
|
||||||
|
+ getParts() : Stream<Part>
|
||||||
|
}
|
||||||
|
class Car {
|
||||||
|
+ Car(properties : Map<String, Object>)
|
||||||
|
}
|
||||||
|
interface HasType {
|
||||||
|
+ PROPERTY : String {static}
|
||||||
|
+ getType() : Optional<String>
|
||||||
|
}
|
||||||
|
interface HasModel {
|
||||||
|
+ PROPERTY : String {static}
|
||||||
|
+ getModel() : Optional<String>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.abstractdocument {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
abstract class AbstractDocument {
|
||||||
|
- properties : Map<String, Object>
|
||||||
|
# AbstractDocument(properties : Map<String, Object>)
|
||||||
|
+ children(key : String, constructor : Function<Map<String, Object>, T>) : Stream<T>
|
||||||
|
+ get(key : String) : Object
|
||||||
|
+ put(key : String, value : Object)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface Document {
|
||||||
|
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
|
||||||
|
+ get(String) : Object {abstract}
|
||||||
|
+ put(String, Object) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractDocument --+ Map
|
||||||
|
Part ..|> HasType
|
||||||
|
Part ..|> HasModel
|
||||||
|
Part ..|> HasPrice
|
||||||
|
Part --|> AbstractDocument
|
||||||
|
AbstractDocument ..|> Document
|
||||||
|
HasPrice --|> Document
|
||||||
|
HasParts --|> Document
|
||||||
|
Car ..|> HasModel
|
||||||
|
Car ..|> HasPrice
|
||||||
|
Car ..|> HasParts
|
||||||
|
Car --|> AbstractDocument
|
||||||
|
HasType --|> Document
|
||||||
|
HasModel --|> Document
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>abstract-document</artifactId>
|
<artifactId>abstract-document</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,8 +3,9 @@ layout: pattern
|
|||||||
title: Abstract Factory
|
title: Abstract Factory
|
||||||
folder: abstract-factory
|
folder: abstract-factory
|
||||||
permalink: /patterns/abstract-factory/
|
permalink: /patterns/abstract-factory/
|
||||||
|
pumlid: PSZB3OD034NHLa81Czwd6sCC39gVxEUWT1_ssLmTtQLqgR5fM7sTmFGtaV6TZu8prd0r6HtQaMKqAZLk1XjT_E6qgPUZfyc0MdTgx0-8LuUn8ErFXdr98NypXxKyezKV
|
||||||
categories: Creational
|
categories: Creational
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
- Gang Of Four
|
- Gang Of Four
|
||||||
- Difficulty-Intermediate
|
- Difficulty-Intermediate
|
||||||
@ -30,6 +31,8 @@ Use the Abstract Factory pattern when
|
|||||||
## Real world examples
|
## Real world examples
|
||||||
|
|
||||||
* [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)
|
* [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
|
## Credits
|
||||||
|
|
||||||
|
88
abstract-factory/etc/abstract-factory.urm.puml
Normal file
88
abstract-factory/etc/abstract-factory.urm.puml
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.abstractfactory {
|
||||||
|
class App {
|
||||||
|
- army : Army
|
||||||
|
- castle : Castle
|
||||||
|
- king : King
|
||||||
|
+ App()
|
||||||
|
+ createKingdom(factory : KingdomFactory)
|
||||||
|
+ getArmy() : Army
|
||||||
|
~ getArmy(factory : KingdomFactory) : Army
|
||||||
|
+ getCastle() : Castle
|
||||||
|
~ getCastle(factory : KingdomFactory) : Castle
|
||||||
|
+ getKing() : King
|
||||||
|
~ getKing(factory : KingdomFactory) : King
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- setArmy(army : Army)
|
||||||
|
- setCastle(castle : Castle)
|
||||||
|
- setKing(king : King)
|
||||||
|
}
|
||||||
|
class OrcKingdomFactory {
|
||||||
|
+ OrcKingdomFactory()
|
||||||
|
+ createArmy() : Army
|
||||||
|
+ createCastle() : Castle
|
||||||
|
+ createKing() : King
|
||||||
|
}
|
||||||
|
class ElfCastle {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ ElfCastle()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class OrcCastle {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ OrcCastle()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
interface KingdomFactory {
|
||||||
|
+ createArmy() : Army {abstract}
|
||||||
|
+ createCastle() : Castle {abstract}
|
||||||
|
+ createKing() : King {abstract}
|
||||||
|
}
|
||||||
|
class ElfKing {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ ElfKing()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class ElfArmy {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ ElfArmy()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
interface Castle {
|
||||||
|
+ getDescription() : String {abstract}
|
||||||
|
}
|
||||||
|
interface Army {
|
||||||
|
+ getDescription() : String {abstract}
|
||||||
|
}
|
||||||
|
class OrcKing {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ OrcKing()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
class OrcArmy {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ OrcArmy()
|
||||||
|
+ getDescription() : String
|
||||||
|
}
|
||||||
|
interface King {
|
||||||
|
+ getDescription() : String {abstract}
|
||||||
|
}
|
||||||
|
class ElfKingdomFactory {
|
||||||
|
+ ElfKingdomFactory()
|
||||||
|
+ createArmy() : Army
|
||||||
|
+ createCastle() : Castle
|
||||||
|
+ createKing() : King
|
||||||
|
}
|
||||||
|
}
|
||||||
|
App --> "-castle" Castle
|
||||||
|
App --> "-king" King
|
||||||
|
App --> "-army" Army
|
||||||
|
OrcKingdomFactory ..|> KingdomFactory
|
||||||
|
ElfCastle ..|> Castle
|
||||||
|
OrcCastle ..|> Castle
|
||||||
|
ElfKing ..|> King
|
||||||
|
ElfArmy ..|> Army
|
||||||
|
OrcKing ..|> King
|
||||||
|
OrcArmy ..|> Army
|
||||||
|
ElfKingdomFactory ..|> KingdomFactory
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>abstract-factory</artifactId>
|
<artifactId>abstract-factory</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Adapter
|
title: Adapter
|
||||||
folder: adapter
|
folder: adapter
|
||||||
permalink: /patterns/adapter/
|
permalink: /patterns/adapter/
|
||||||
|
pumlid: DSR14S8m30J0Lg20M7-wEMnDOiPMFDA9j0yyUEtUkzMHJTF7xI1NF4GSLzaxZtncgDVJgCPIpobzv0N2vOKtjgRHTziMI7KBcOXl10thfxB-Nz9dMJd71m00
|
||||||
categories: Structural
|
categories: Structural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
@ -30,6 +31,10 @@ Use the Adapter pattern when
|
|||||||
## Real world examples
|
## Real world examples
|
||||||
|
|
||||||
* [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29)
|
* [java.util.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
|
## Credits
|
||||||
|
|
||||||
|
35
adapter/etc/adapter.urm.puml
Normal file
35
adapter/etc/adapter.urm.puml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.adapter {
|
||||||
|
interface BattleShip {
|
||||||
|
+ fire() {abstract}
|
||||||
|
+ move() {abstract}
|
||||||
|
}
|
||||||
|
class BattleFishingBoat {
|
||||||
|
- boat : FishingBoat
|
||||||
|
+ BattleFishingBoat()
|
||||||
|
+ fire()
|
||||||
|
+ move()
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Captain {
|
||||||
|
- battleship : BattleShip
|
||||||
|
+ Captain()
|
||||||
|
+ Captain(battleship : BattleShip)
|
||||||
|
+ fire()
|
||||||
|
+ move()
|
||||||
|
+ setBattleship(battleship : BattleShip)
|
||||||
|
}
|
||||||
|
class FishingBoat {
|
||||||
|
+ FishingBoat()
|
||||||
|
+ fish()
|
||||||
|
+ sail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BattleFishingBoat --> "-boat" FishingBoat
|
||||||
|
Captain --> "-battleship" BattleShip
|
||||||
|
BattleFishingBoat ..|> BattleShip
|
||||||
|
Captain ..|> BattleShip
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>adapter</artifactId>
|
<artifactId>adapter</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Aggregator Microservices
|
title: Aggregator Microservices
|
||||||
folder: aggregator-microservices
|
folder: aggregator-microservices
|
||||||
permalink: /patterns/aggregator-microservices/
|
permalink: /patterns/aggregator-microservices/
|
||||||
|
pumlid: JOov3SCm301NIGQGs7iRXYPa1g8ayB7NjuiKwGvtmBrbKC-Tq_hhY5Y-0HXUjKaS-Kbdepc2HrIQ2jBpma23BvvOTdPfeooCO1iEYlu0O6l63MDQKI6Rp-CKOWSE-ey_NzEqhjH-0m00
|
||||||
categories: Architectural
|
categories: Architectural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>aggregator-microservices</artifactId>
|
<artifactId>aggregator-microservices</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
41
aggregator-microservices/etc/aggregator-service.urm.puml
Normal file
41
aggregator-microservices/etc/aggregator-service.urm.puml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.aggregator.microservices {
|
||||||
|
class ProductInventoryClientImpl {
|
||||||
|
+ ProductInventoryClientImpl()
|
||||||
|
+ getProductInventories() : int
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface ProductInventoryClient {
|
||||||
|
+ getProductInventories() : int {abstract}
|
||||||
|
}
|
||||||
|
class Product {
|
||||||
|
- productInventories : int
|
||||||
|
- title : String
|
||||||
|
+ Product()
|
||||||
|
+ getProductInventories() : int
|
||||||
|
+ getTitle() : String
|
||||||
|
+ setProductInventories(productInventories : int)
|
||||||
|
+ setTitle(title : String)
|
||||||
|
}
|
||||||
|
class Aggregator {
|
||||||
|
- informationClient : ProductInformationClient
|
||||||
|
- inventoryClient : ProductInventoryClient
|
||||||
|
+ Aggregator()
|
||||||
|
+ getProduct() : Product
|
||||||
|
}
|
||||||
|
class ProductInformationClientImpl {
|
||||||
|
+ ProductInformationClientImpl()
|
||||||
|
+ getProductTitle() : String
|
||||||
|
}
|
||||||
|
interface ProductInformationClient {
|
||||||
|
+ getProductTitle() : String {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Aggregator --> "-inventoryClient" ProductInventoryClient
|
||||||
|
Aggregator --> "-informationClient" ProductInformationClient
|
||||||
|
ProductInventoryClientImpl ..|> ProductInventoryClient
|
||||||
|
ProductInformationClientImpl ..|> ProductInformationClient
|
||||||
|
@enduml
|
@ -0,0 +1,12 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.information.microservice {
|
||||||
|
class InformationApplication {
|
||||||
|
+ InformationApplication()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class InformationController {
|
||||||
|
+ InformationController()
|
||||||
|
+ getProductTitle() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
12
aggregator-microservices/etc/inventory-microservice.urm.puml
Normal file
12
aggregator-microservices/etc/inventory-microservice.urm.puml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.inventory.microservice {
|
||||||
|
class InventoryController {
|
||||||
|
+ InventoryController()
|
||||||
|
+ getProductInventories() : int
|
||||||
|
}
|
||||||
|
class InventoryApplication {
|
||||||
|
+ InventoryApplication()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>aggregator-microservices</artifactId>
|
<artifactId>aggregator-microservices</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>aggregator-microservices</artifactId>
|
<artifactId>aggregator-microservices</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -29,15 +29,35 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>aggregator-microservices</artifactId>
|
<artifactId>aggregator-microservices</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.github.markusmo3.urm</groupId>
|
||||||
|
<artifactId>urm-maven-plugin</artifactId>
|
||||||
|
<version>${urm.version}</version>
|
||||||
|
<configuration combine.self="override">
|
||||||
|
<outputDirectory>${project.basedir}/../etc</outputDirectory>
|
||||||
|
<packages>
|
||||||
|
<param>com.iluwatar</param>
|
||||||
|
</packages>
|
||||||
|
<skipForProjects>
|
||||||
|
<!-- skip for parent project -->
|
||||||
|
<param>aggregator-microservices</param>
|
||||||
|
</skipForProjects>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>information-microservice</module>
|
<module>information-microservice</module>
|
||||||
<module>aggregator-service</module>
|
<module>aggregator-service</module>
|
||||||
<module>inventory-microservice</module>
|
<module>inventory-microservice</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: API Gateway
|
title: API Gateway
|
||||||
folder: api-gateway
|
folder: api-gateway
|
||||||
permalink: /patterns/api-gateway/
|
permalink: /patterns/api-gateway/
|
||||||
|
pumlid: JSox3SCm303HLP819FRUXg49cO542_nOyFPncUvUSszHwhbpMdyT4TCt0CDLcyIHdtGsEZLOez8vG7ek33JuueLbPvUcPM84cpeCz2S0fvI6mGjluA1_b-Tt2N5D6tNcw3y0
|
||||||
categories: Architectural
|
categories: Architectural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>api-gateway</artifactId>
|
<artifactId>api-gateway</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>api-gateway-service</artifactId>
|
<artifactId>api-gateway-service</artifactId>
|
||||||
|
48
api-gateway/etc/api-gateway-service.urm.puml
Normal file
48
api-gateway/etc/api-gateway-service.urm.puml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.api.gateway {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class PriceClientImpl {
|
||||||
|
+ PriceClientImpl()
|
||||||
|
+ getPrice() : String
|
||||||
|
}
|
||||||
|
class ImageClientImpl {
|
||||||
|
+ ImageClientImpl()
|
||||||
|
+ getImagePath() : String
|
||||||
|
}
|
||||||
|
class MobileProduct {
|
||||||
|
- price : String
|
||||||
|
+ MobileProduct()
|
||||||
|
+ getPrice() : String
|
||||||
|
+ setPrice(price : String)
|
||||||
|
}
|
||||||
|
interface ImageClient {
|
||||||
|
+ getImagePath() : String {abstract}
|
||||||
|
}
|
||||||
|
class ApiGateway {
|
||||||
|
- imageClient : ImageClient
|
||||||
|
- priceClient : PriceClient
|
||||||
|
+ ApiGateway()
|
||||||
|
+ getProductDesktop() : DesktopProduct
|
||||||
|
+ getProductMobile() : MobileProduct
|
||||||
|
}
|
||||||
|
class DesktopProduct {
|
||||||
|
- imagePath : String
|
||||||
|
- price : String
|
||||||
|
+ DesktopProduct()
|
||||||
|
+ getImagePath() : String
|
||||||
|
+ getPrice() : String
|
||||||
|
+ setImagePath(imagePath : String)
|
||||||
|
+ setPrice(price : String)
|
||||||
|
}
|
||||||
|
interface PriceClient {
|
||||||
|
+ getPrice() : String {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ApiGateway --> "-imageClient" ImageClient
|
||||||
|
ApiGateway --> "-priceClient" PriceClient
|
||||||
|
PriceClientImpl ..|> PriceClient
|
||||||
|
ImageClientImpl ..|> ImageClient
|
||||||
|
@enduml
|
12
api-gateway/etc/image-microservice.urm.puml
Normal file
12
api-gateway/etc/image-microservice.urm.puml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.image.microservice {
|
||||||
|
class ImageApplication {
|
||||||
|
+ ImageApplication()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class ImageController {
|
||||||
|
+ ImageController()
|
||||||
|
+ getImagePath() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
12
api-gateway/etc/price-microservice.urm.puml
Normal file
12
api-gateway/etc/price-microservice.urm.puml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.price.microservice {
|
||||||
|
class PriceApplication {
|
||||||
|
+ PriceApplication()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class PriceController {
|
||||||
|
+ PriceController()
|
||||||
|
+ getPrice() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>api-gateway</artifactId>
|
<artifactId>api-gateway</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -29,15 +29,35 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>api-gateway</artifactId>
|
<artifactId>api-gateway</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.github.markusmo3.urm</groupId>
|
||||||
|
<artifactId>urm-maven-plugin</artifactId>
|
||||||
|
<version>${urm.version}</version>
|
||||||
|
<configuration combine.self="override">
|
||||||
|
<outputDirectory>${project.basedir}/../etc</outputDirectory>
|
||||||
|
<packages>
|
||||||
|
<param>com.iluwatar</param>
|
||||||
|
</packages>
|
||||||
|
<skipForProjects>
|
||||||
|
<!-- skip for parent project -->
|
||||||
|
<param>api-gateway</param>
|
||||||
|
</skipForProjects>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>image-microservice</module>
|
<module>image-microservice</module>
|
||||||
<module>price-microservice</module>
|
<module>price-microservice</module>
|
||||||
<module>api-gateway-service</module>
|
<module>api-gateway-service</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>api-gateway</artifactId>
|
<artifactId>api-gateway</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -3,11 +3,13 @@ layout: pattern
|
|||||||
title: Async Method Invocation
|
title: Async Method Invocation
|
||||||
folder: async-method-invocation
|
folder: async-method-invocation
|
||||||
permalink: /patterns/async-method-invocation/
|
permalink: /patterns/async-method-invocation/
|
||||||
|
pumlid: TSdB3SCW303GLTe1mFTkunWhk0A3_4dKxTi5UdlIUuhIoCPfuz4Zjhy03EzwIlGyqjbeQR16fJL1HjuOQF362qjZbrFBnWWsTPZeFm3wHwbCZhvQ4RqMOSXIuA1_LzDctJd75m00
|
||||||
categories: Concurrency
|
categories: Concurrency
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
- Difficulty-Intermediate
|
- Difficulty-Intermediate
|
||||||
- Functional
|
- Functional
|
||||||
|
- Reactive
|
||||||
---
|
---
|
||||||
|
|
||||||
## Intent
|
## Intent
|
||||||
|
50
async-method-invocation/etc/async-method-invocation.urm.puml
Normal file
50
async-method-invocation/etc/async-method-invocation.urm.puml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.async.method.invocation {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
- callback(name : String) : AsyncCallback<T> {static}
|
||||||
|
- lazyval(value : T, delayMillis : long) : Callable<T> {static}
|
||||||
|
- log(msg : String) {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface AsyncResult<T> {
|
||||||
|
+ await() {abstract}
|
||||||
|
+ getValue() : T {abstract}
|
||||||
|
+ isCompleted() : boolean {abstract}
|
||||||
|
}
|
||||||
|
interface AsyncExecutor {
|
||||||
|
+ endProcess(AsyncResult<T>) : T {abstract}
|
||||||
|
+ startProcess(Callable<T>) : AsyncResult<T> {abstract}
|
||||||
|
+ startProcess(Callable<T>, AsyncCallback<T>) : AsyncResult<T> {abstract}
|
||||||
|
}
|
||||||
|
class ThreadAsyncExecutor {
|
||||||
|
- idx : AtomicInteger
|
||||||
|
+ ThreadAsyncExecutor()
|
||||||
|
+ endProcess(asyncResult : AsyncResult<T>) : T
|
||||||
|
+ startProcess(task : Callable<T>) : AsyncResult<T>
|
||||||
|
+ startProcess(task : Callable<T>, callback : AsyncCallback<T>) : AsyncResult<T>
|
||||||
|
}
|
||||||
|
interface AsyncCallback<T> {
|
||||||
|
+ onComplete(T, Optional<Exception>) {abstract}
|
||||||
|
}
|
||||||
|
-class CompletableResult<T> {
|
||||||
|
~ COMPLETED : int {static}
|
||||||
|
~ FAILED : int {static}
|
||||||
|
~ RUNNING : int {static}
|
||||||
|
~ callback : Optional<AsyncCallback<T>>
|
||||||
|
~ exception : Exception
|
||||||
|
~ lock : Object
|
||||||
|
~ state : int
|
||||||
|
~ value : T
|
||||||
|
~ CompletableResult<T>(callback : AsyncCallback<T>)
|
||||||
|
+ await()
|
||||||
|
+ getValue() : T
|
||||||
|
+ isCompleted() : boolean
|
||||||
|
~ setException(exception : Exception)
|
||||||
|
~ setValue(value : T)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CompletableResult ..+ ThreadAsyncExecutor
|
||||||
|
ThreadAsyncExecutor ..|> AsyncExecutor
|
||||||
|
CompletableResult ..|> AsyncResult
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>async-method-invocation</artifactId>
|
<artifactId>async-method-invocation</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Bridge
|
title: Bridge
|
||||||
folder: bridge
|
folder: bridge
|
||||||
permalink: /patterns/bridge/
|
permalink: /patterns/bridge/
|
||||||
|
pumlid: BSR14SCm20J0Lf82BFxf1akCJ4R26ZZYzkE7zxLljJgoIVfu7S2A3v7pLRhYo3r3l9u6CPHwJjAH5uETllpZhKbejsqn86v1a-CExQwj2mdgqv8-oyev_W00
|
||||||
categories: Structural
|
categories: Structural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
89
bridge/etc/bridge.urm.puml
Normal file
89
bridge/etc/bridge.urm.puml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.bridge {
|
||||||
|
class FlyingMagicWeapon {
|
||||||
|
+ FlyingMagicWeapon(imp : FlyingMagicWeaponImpl)
|
||||||
|
+ fly()
|
||||||
|
+ getImp() : FlyingMagicWeaponImpl
|
||||||
|
+ swing()
|
||||||
|
+ unwield()
|
||||||
|
+ wield()
|
||||||
|
}
|
||||||
|
class Stormbringer {
|
||||||
|
+ Stormbringer()
|
||||||
|
+ eatSoulImp()
|
||||||
|
+ swingImp()
|
||||||
|
+ unwieldImp()
|
||||||
|
+ wieldImp()
|
||||||
|
}
|
||||||
|
abstract class FlyingMagicWeaponImpl {
|
||||||
|
+ FlyingMagicWeaponImpl()
|
||||||
|
+ flyImp() {abstract}
|
||||||
|
}
|
||||||
|
class SoulEatingMagicWeapon {
|
||||||
|
+ SoulEatingMagicWeapon(imp : SoulEatingMagicWeaponImpl)
|
||||||
|
+ eatSoul()
|
||||||
|
+ getImp() : SoulEatingMagicWeaponImpl
|
||||||
|
+ swing()
|
||||||
|
+ unwield()
|
||||||
|
+ wield()
|
||||||
|
}
|
||||||
|
abstract class MagicWeaponImpl {
|
||||||
|
+ MagicWeaponImpl()
|
||||||
|
+ swingImp() {abstract}
|
||||||
|
+ unwieldImp() {abstract}
|
||||||
|
+ wieldImp() {abstract}
|
||||||
|
}
|
||||||
|
abstract class SoulEatingMagicWeaponImpl {
|
||||||
|
+ SoulEatingMagicWeaponImpl()
|
||||||
|
+ eatSoulImp() {abstract}
|
||||||
|
}
|
||||||
|
class Excalibur {
|
||||||
|
+ Excalibur()
|
||||||
|
+ blindImp()
|
||||||
|
+ swingImp()
|
||||||
|
+ unwieldImp()
|
||||||
|
+ wieldImp()
|
||||||
|
}
|
||||||
|
class Mjollnir {
|
||||||
|
+ Mjollnir()
|
||||||
|
+ flyImp()
|
||||||
|
+ swingImp()
|
||||||
|
+ unwieldImp()
|
||||||
|
+ wieldImp()
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
abstract class MagicWeapon {
|
||||||
|
# imp : MagicWeaponImpl
|
||||||
|
+ MagicWeapon(imp : MagicWeaponImpl)
|
||||||
|
+ getImp() : MagicWeaponImpl
|
||||||
|
+ swing() {abstract}
|
||||||
|
+ unwield() {abstract}
|
||||||
|
+ wield() {abstract}
|
||||||
|
}
|
||||||
|
abstract class BlindingMagicWeaponImpl {
|
||||||
|
+ BlindingMagicWeaponImpl()
|
||||||
|
+ blindImp() {abstract}
|
||||||
|
}
|
||||||
|
class BlindingMagicWeapon {
|
||||||
|
+ BlindingMagicWeapon(imp : BlindingMagicWeaponImpl)
|
||||||
|
+ blind()
|
||||||
|
+ getImp() : BlindingMagicWeaponImpl
|
||||||
|
+ swing()
|
||||||
|
+ unwield()
|
||||||
|
+ wield()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MagicWeapon --> "-imp" MagicWeaponImpl
|
||||||
|
FlyingMagicWeapon --|> MagicWeapon
|
||||||
|
Stormbringer --|> SoulEatingMagicWeaponImpl
|
||||||
|
FlyingMagicWeaponImpl --|> MagicWeaponImpl
|
||||||
|
SoulEatingMagicWeapon --|> MagicWeapon
|
||||||
|
SoulEatingMagicWeaponImpl --|> MagicWeaponImpl
|
||||||
|
Excalibur --|> BlindingMagicWeaponImpl
|
||||||
|
Mjollnir --|> FlyingMagicWeaponImpl
|
||||||
|
BlindingMagicWeaponImpl --|> MagicWeaponImpl
|
||||||
|
BlindingMagicWeapon --|> MagicWeapon
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>bridge</artifactId>
|
<artifactId>bridge</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Builder
|
title: Builder
|
||||||
folder: builder
|
folder: builder
|
||||||
permalink: /patterns/builder/
|
permalink: /patterns/builder/
|
||||||
|
pumlid: DSR94O0m2030LhG0mzzkC64KXs26GzlNZw_TcRLADagJwOWOlW8OFcNdE79B9wkN1ccKUdLWoGS33KwySMdalEioC89C7Jhw5zYIfNrIrFybhPUHNLu0
|
||||||
categories: Creational
|
categories: Creational
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
@ -26,6 +27,9 @@ Use the Builder pattern when
|
|||||||
## Real world examples
|
## Real world examples
|
||||||
|
|
||||||
* [java.lang.StringBuilder](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html)
|
* [java.lang.StringBuilder](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html)
|
||||||
|
* [java.nio.ByteBuffer](http://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html#put-byte-) as well as similar buffers such as FloatBuffer, IntBuffer and so on.
|
||||||
|
* [java.lang.StringBuffer](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html#append-boolean-)
|
||||||
|
* All implementations of [java.lang.Appendable](http://docs.oracle.com/javase/8/docs/api/java/lang/Appendable.html)
|
||||||
* [Apache Camel builders](https://github.com/apache/camel/tree/0e195428ee04531be27a0b659005e3aa8d159d23/camel-core/src/main/java/org/apache/camel/builder)
|
* [Apache Camel builders](https://github.com/apache/camel/tree/0e195428ee04531be27a0b659005e3aa8d159d23/camel-core/src/main/java/org/apache/camel/builder)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
100
builder/etc/builder.urm.puml
Normal file
100
builder/etc/builder.urm.puml
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.builder {
|
||||||
|
class Builder {
|
||||||
|
- armor : Armor
|
||||||
|
- hairColor : HairColor
|
||||||
|
- hairType : HairType
|
||||||
|
- name : String
|
||||||
|
- profession : Profession
|
||||||
|
- weapon : Weapon
|
||||||
|
+ Builder(profession : Profession, name : String)
|
||||||
|
+ build() : Hero
|
||||||
|
+ withArmor(armor : Armor) : Builder
|
||||||
|
+ withHairColor(hairColor : HairColor) : Builder
|
||||||
|
+ withHairType(hairType : HairType) : Builder
|
||||||
|
+ withWeapon(weapon : Weapon) : Builder
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Hero {
|
||||||
|
- armor : Armor
|
||||||
|
- hairColor : HairColor
|
||||||
|
- hairType : HairType
|
||||||
|
- name : String
|
||||||
|
- profession : Profession
|
||||||
|
- weapon : Weapon
|
||||||
|
- Hero(builder : Builder)
|
||||||
|
+ getArmor() : Armor
|
||||||
|
+ getHairColor() : HairColor
|
||||||
|
+ getHairType() : HairType
|
||||||
|
+ getName() : String
|
||||||
|
+ getProfession() : Profession
|
||||||
|
+ getWeapon() : Weapon
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
enum Weapon {
|
||||||
|
+ AXE {static}
|
||||||
|
+ BOW {static}
|
||||||
|
+ DAGGER {static}
|
||||||
|
+ SWORD {static}
|
||||||
|
+ WARHAMMER {static}
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Weapon {static}
|
||||||
|
+ values() : Weapon[] {static}
|
||||||
|
}
|
||||||
|
enum HairColor {
|
||||||
|
+ BLACK {static}
|
||||||
|
+ BLOND {static}
|
||||||
|
+ BROWN {static}
|
||||||
|
+ RED {static}
|
||||||
|
+ WHITE {static}
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : HairColor {static}
|
||||||
|
+ values() : HairColor[] {static}
|
||||||
|
}
|
||||||
|
enum Profession {
|
||||||
|
+ MAGE {static}
|
||||||
|
+ PRIEST {static}
|
||||||
|
+ THIEF {static}
|
||||||
|
+ WARRIOR {static}
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Profession {static}
|
||||||
|
+ values() : Profession[] {static}
|
||||||
|
}
|
||||||
|
enum Armor {
|
||||||
|
+ CHAIN_MAIL {static}
|
||||||
|
+ CLOTHES {static}
|
||||||
|
+ LEATHER {static}
|
||||||
|
+ PLATE_MAIL {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Armor {static}
|
||||||
|
+ values() : Armor[] {static}
|
||||||
|
}
|
||||||
|
enum HairType {
|
||||||
|
+ BALD {static}
|
||||||
|
+ CURLY {static}
|
||||||
|
+ LONG_CURLY {static}
|
||||||
|
+ LONG_STRAIGHT {static}
|
||||||
|
+ SHORT {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : HairType {static}
|
||||||
|
+ values() : HairType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Hero --> "-profession" Profession
|
||||||
|
Builder ..+ Hero
|
||||||
|
Hero --> "-armor" Armor
|
||||||
|
App --+ Hero
|
||||||
|
Builder --> "-weapon" Weapon
|
||||||
|
Builder --> "-hairColor" HairColor
|
||||||
|
Builder --> "-hairType" HairType
|
||||||
|
Hero --> "-hairColor" HairColor
|
||||||
|
Builder --> "-profession" Profession
|
||||||
|
Hero --> "-weapon" Weapon
|
||||||
|
Hero --> "-hairType" HairType
|
||||||
|
Builder --> "-armor" Armor
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>builder</artifactId>
|
<artifactId>builder</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Business Delegate
|
title: Business Delegate
|
||||||
folder: business-delegate
|
folder: business-delegate
|
||||||
permalink: /patterns/business-delegate/
|
permalink: /patterns/business-delegate/
|
||||||
|
pumlid: POl13SCm3CHMQGU8zUysgYCuBcJ5a4x9-l6_Fu84tzsgvYxf-Zg06HyYvxkqZYE_6UBrD8YXr7DGrxmPxFJZYxTTeZVR9WFY5ZGu5j2wkad4wYgD8IIe_xQaZp9pw0C0
|
||||||
categories: Business Tier
|
categories: Business Tier
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
55
business-delegate/etc/business-delegate.urm.puml
Normal file
55
business-delegate/etc/business-delegate.urm.puml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.business.delegate {
|
||||||
|
class EjbService {
|
||||||
|
+ EjbService()
|
||||||
|
+ doProcessing()
|
||||||
|
}
|
||||||
|
class BusinessLookup {
|
||||||
|
- ejbService : EjbService
|
||||||
|
- jmsService : JmsService
|
||||||
|
+ BusinessLookup()
|
||||||
|
+ getBusinessService(serviceType : ServiceType) : BusinessService
|
||||||
|
+ setEjbService(ejbService : EjbService)
|
||||||
|
+ setJmsService(jmsService : JmsService)
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface BusinessService {
|
||||||
|
+ doProcessing() {abstract}
|
||||||
|
}
|
||||||
|
class Client {
|
||||||
|
- businessDelegate : BusinessDelegate
|
||||||
|
+ Client(businessDelegate : BusinessDelegate)
|
||||||
|
+ doTask()
|
||||||
|
}
|
||||||
|
class BusinessDelegate {
|
||||||
|
- businessService : BusinessService
|
||||||
|
- lookupService : BusinessLookup
|
||||||
|
- serviceType : ServiceType
|
||||||
|
+ BusinessDelegate()
|
||||||
|
+ doTask()
|
||||||
|
+ setLookupService(businessLookup : BusinessLookup)
|
||||||
|
+ setServiceType(serviceType : ServiceType)
|
||||||
|
}
|
||||||
|
class JmsService {
|
||||||
|
+ JmsService()
|
||||||
|
+ doProcessing()
|
||||||
|
}
|
||||||
|
enum ServiceType {
|
||||||
|
+ EJB {static}
|
||||||
|
+ JMS {static}
|
||||||
|
+ valueOf(name : String) : ServiceType {static}
|
||||||
|
+ values() : ServiceType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BusinessDelegate --> "-serviceType" ServiceType
|
||||||
|
BusinessLookup --> "-ejbService" EjbService
|
||||||
|
Client --> "-businessDelegate" BusinessDelegate
|
||||||
|
BusinessDelegate --> "-businessService" BusinessService
|
||||||
|
BusinessDelegate --> "-lookupService" BusinessLookup
|
||||||
|
BusinessLookup --> "-jmsService" JmsService
|
||||||
|
EjbService ..|> BusinessService
|
||||||
|
JmsService ..|> BusinessService
|
||||||
|
@enduml
|
@ -30,7 +30,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>business-delegate</artifactId>
|
<artifactId>business-delegate</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Caching
|
title: Caching
|
||||||
folder: caching
|
folder: caching
|
||||||
permalink: /patterns/caching/
|
permalink: /patterns/caching/
|
||||||
|
pumlid: DSRB4OKm2030LhG0m_rrWyWaE0bc-6ZxpujxsbMKUXwSrfSMCVq7OFYKAj5oJsUZIuCr2bq3fEU3WGOdthWTx59rcnZ1fWu3_GqGKXEjm47VIzeeCqV_0m00
|
||||||
categories: Other
|
categories: Other
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
100
caching/etc/caching.urm.puml
Normal file
100
caching/etc/caching.urm.puml
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.caching {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
+ useReadAndWriteThroughStrategy()
|
||||||
|
+ useReadThroughAndWriteAroundStrategy()
|
||||||
|
+ useReadThroughAndWriteBehindStrategy()
|
||||||
|
}
|
||||||
|
~class Node {
|
||||||
|
~ next : Node
|
||||||
|
~ previous : Node
|
||||||
|
~ userAccount : UserAccount
|
||||||
|
~ userId : String
|
||||||
|
+ Node(this$0 : String, userId : UserAccount)
|
||||||
|
}
|
||||||
|
class CacheStore {
|
||||||
|
~ cache : LruCache {static}
|
||||||
|
- CacheStore()
|
||||||
|
+ clearCache() {static}
|
||||||
|
+ flushCache() {static}
|
||||||
|
+ initCapacity(capacity : int) {static}
|
||||||
|
+ print() : String {static}
|
||||||
|
+ readThrough(userId : String) : UserAccount {static}
|
||||||
|
+ readThroughWithWriteBackPolicy(userId : String) : UserAccount {static}
|
||||||
|
+ writeAround(userAccount : UserAccount) {static}
|
||||||
|
+ writeBehind(userAccount : UserAccount) {static}
|
||||||
|
+ writeThrough(userAccount : UserAccount) {static}
|
||||||
|
}
|
||||||
|
class AppManager {
|
||||||
|
- cachingPolicy : CachingPolicy {static}
|
||||||
|
- AppManager()
|
||||||
|
+ find(userId : String) : UserAccount {static}
|
||||||
|
+ initCacheCapacity(capacity : int) {static}
|
||||||
|
+ initCachingPolicy(policy : CachingPolicy) {static}
|
||||||
|
+ initDb(useMongoDb : boolean) {static}
|
||||||
|
+ printCacheContent() : String {static}
|
||||||
|
+ save(userAccount : UserAccount) {static}
|
||||||
|
}
|
||||||
|
class UserAccount {
|
||||||
|
- additionalInfo : String
|
||||||
|
- userId : String
|
||||||
|
- userName : String
|
||||||
|
+ UserAccount(userId : String, userName : String, additionalInfo : String)
|
||||||
|
+ getAdditionalInfo() : String
|
||||||
|
+ getUserId() : String
|
||||||
|
+ getUserName() : String
|
||||||
|
+ setAdditionalInfo(additionalInfo : String)
|
||||||
|
+ setUserId(userId : String)
|
||||||
|
+ setUserName(userName : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class LruCache {
|
||||||
|
~ cache : Map<String, Node>
|
||||||
|
~ capacity : int
|
||||||
|
~ end : Node
|
||||||
|
~ head : Node
|
||||||
|
+ LruCache(capacity : int)
|
||||||
|
+ clear()
|
||||||
|
+ contains(userId : String) : boolean
|
||||||
|
+ get(userId : String) : UserAccount
|
||||||
|
+ getCacheDataInListForm() : List<UserAccount>
|
||||||
|
+ getLruData() : UserAccount
|
||||||
|
+ invalidate(userId : String)
|
||||||
|
+ isFull() : boolean
|
||||||
|
+ remove(node : Node)
|
||||||
|
+ set(userId : String, userAccount : UserAccount)
|
||||||
|
+ setCapacity(newCapacity : int)
|
||||||
|
+ setHead(node : Node)
|
||||||
|
}
|
||||||
|
class DbManager {
|
||||||
|
- db : MongoDatabase {static}
|
||||||
|
- mongoClient : MongoClient {static}
|
||||||
|
- useMongoDB : boolean {static}
|
||||||
|
- virtualDB : Map<String, UserAccount> {static}
|
||||||
|
- DbManager()
|
||||||
|
+ connect() {static}
|
||||||
|
+ createVirtualDb() {static}
|
||||||
|
+ readFromDb(userId : String) : UserAccount {static}
|
||||||
|
+ updateDb(userAccount : UserAccount) {static}
|
||||||
|
+ upsertDb(userAccount : UserAccount) {static}
|
||||||
|
+ writeToDb(userAccount : UserAccount) {static}
|
||||||
|
}
|
||||||
|
enum CachingPolicy {
|
||||||
|
+ AROUND {static}
|
||||||
|
+ BEHIND {static}
|
||||||
|
+ THROUGH {static}
|
||||||
|
- policy : String
|
||||||
|
+ getPolicy() : String
|
||||||
|
+ valueOf(name : String) : CachingPolicy {static}
|
||||||
|
+ values() : CachingPolicy[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Node --+ LruCache
|
||||||
|
LruCache --> "-head" Node
|
||||||
|
Node --> "-previous" Node
|
||||||
|
AppManager --> "-cachingPolicy" CachingPolicy
|
||||||
|
Node --> "-userAccount" UserAccount
|
||||||
|
CacheStore --> "-cache" LruCache
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>caching</artifactId>
|
<artifactId>caching</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Callback
|
title: Callback
|
||||||
folder: callback
|
folder: callback
|
||||||
permalink: /patterns/callback/
|
permalink: /patterns/callback/
|
||||||
|
pumlid: FSVB4S8m30N0Lg20M7UwUL4qYOciUFGXxSE9s-wp6sjjKgwF8tF6YyXnjxtdKMk5E5-MOjdu6jIrRYIStlXWsIJwRij4fhW53SGFn51TmIT9yZ-jVBHPGxy0
|
||||||
categories: Other
|
categories: Other
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
25
callback/etc/callback.urm.puml
Normal file
25
callback/etc/callback.urm.puml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.callback {
|
||||||
|
interface Callback {
|
||||||
|
+ call() {abstract}
|
||||||
|
}
|
||||||
|
abstract class Task {
|
||||||
|
+ Task()
|
||||||
|
+ execute() {abstract}
|
||||||
|
+ executeWith(callback : Callback)
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class SimpleTask {
|
||||||
|
+ SimpleTask()
|
||||||
|
+ execute()
|
||||||
|
}
|
||||||
|
class LambdasApp {
|
||||||
|
+ LambdasApp()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SimpleTask --|> Task
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>callback</artifactId>
|
<artifactId>callback</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Chain of responsibility
|
title: Chain of responsibility
|
||||||
folder: chain
|
folder: chain
|
||||||
permalink: /patterns/chain/
|
permalink: /patterns/chain/
|
||||||
|
pumlid: 9SR13SCm20NGLTe1OkxTXX0KKzd4Wa-pVYlrdTxJN4OTMZ4U7LZv8Wg-ssdejLTgoELGHvDhaesw6HpqvWzlXwQTlYq6D3nfSlv2qjcS5F9VgvXjrHnV
|
||||||
categories: Behavioral
|
categories: Behavioral
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
@ -28,6 +29,7 @@ Use Chain of Responsibility when
|
|||||||
|
|
||||||
* [java.util.logging.Logger#log()](http://docs.oracle.com/javase/8/docs/api/java/util/logging/Logger.html#log%28java.util.logging.Level,%20java.lang.String%29)
|
* [java.util.logging.Logger#log()](http://docs.oracle.com/javase/8/docs/api/java/util/logging/Logger.html#log%28java.util.logging.Level,%20java.lang.String%29)
|
||||||
* [Apache Commons Chain](https://commons.apache.org/proper/commons-chain/index.html)
|
* [Apache Commons Chain](https://commons.apache.org/proper/commons-chain/index.html)
|
||||||
|
* [javax.servlet.Filter#doFilter()](http://docs.oracle.com/javaee/7/api/javax/servlet/Filter.html#doFilter-javax.servlet.ServletRequest-javax.servlet.ServletResponse-javax.servlet.FilterChain-)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
60
chain/etc/chain.urm.puml
Normal file
60
chain/etc/chain.urm.puml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.chain {
|
||||||
|
class OrcSoldier {
|
||||||
|
+ OrcSoldier(handler : RequestHandler)
|
||||||
|
+ handleRequest(req : Request)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class OrcCommander {
|
||||||
|
+ OrcCommander(handler : RequestHandler)
|
||||||
|
+ handleRequest(req : Request)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class OrcKing {
|
||||||
|
~ chain : RequestHandler
|
||||||
|
+ OrcKing()
|
||||||
|
- buildChain()
|
||||||
|
+ makeRequest(req : Request)
|
||||||
|
}
|
||||||
|
class Request {
|
||||||
|
- handled : boolean
|
||||||
|
- requestDescription : String
|
||||||
|
- requestType : RequestType
|
||||||
|
+ Request(requestType : RequestType, requestDescription : String)
|
||||||
|
+ getRequestDescription() : String
|
||||||
|
+ getRequestType() : RequestType
|
||||||
|
+ isHandled() : boolean
|
||||||
|
+ markHandled()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
abstract class RequestHandler {
|
||||||
|
- next : RequestHandler
|
||||||
|
+ RequestHandler(next : RequestHandler)
|
||||||
|
+ handleRequest(req : Request)
|
||||||
|
# printHandling(req : Request)
|
||||||
|
+ toString() : String {abstract}
|
||||||
|
}
|
||||||
|
class OrcOfficer {
|
||||||
|
+ OrcOfficer(handler : RequestHandler)
|
||||||
|
+ handleRequest(req : Request)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
enum RequestType {
|
||||||
|
+ COLLECT_TAX {static}
|
||||||
|
+ DEFEND_CASTLE {static}
|
||||||
|
+ TORTURE_PRISONER {static}
|
||||||
|
+ valueOf(name : String) : RequestType {static}
|
||||||
|
+ values() : RequestType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RequestHandler --> "-next" RequestHandler
|
||||||
|
Request --> "-requestType" RequestType
|
||||||
|
OrcKing --> "-chain" RequestHandler
|
||||||
|
OrcSoldier --|> RequestHandler
|
||||||
|
OrcCommander --|> RequestHandler
|
||||||
|
OrcOfficer --|> RequestHandler
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>chain</artifactId>
|
<artifactId>chain</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,11 +3,13 @@ layout: pattern
|
|||||||
title: Command
|
title: Command
|
||||||
folder: command
|
folder: command
|
||||||
permalink: /patterns/command/
|
permalink: /patterns/command/
|
||||||
|
pumlid: DSgn4OCm30NGLM00h3xR25i7vYpXaxx2-g59zugtTgiZcwIFvGHcV8YSdt9qdBbdYDVR88PIRwK-yc6mqyLVtff4FsoR38XRa7Aye3SgMoD1_RkaQvcfumS0
|
||||||
categories: Behavioral
|
categories: Behavioral
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
- Gang Of Four
|
- Gang Of Four
|
||||||
- Difficulty-Intermediate
|
- Difficulty-Intermediate
|
||||||
|
- Functional
|
||||||
---
|
---
|
||||||
|
|
||||||
## Also known as
|
## Also known as
|
||||||
@ -39,6 +41,7 @@ Use the Command pattern when you want to
|
|||||||
|
|
||||||
* [java.lang.Runnable](http://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html)
|
* [java.lang.Runnable](http://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html)
|
||||||
* [Netflix Hystrix](https://github.com/Netflix/Hystrix/wiki)
|
* [Netflix Hystrix](https://github.com/Netflix/Hystrix/wiki)
|
||||||
|
* [javax.swing.Action](http://docs.oracle.com/javase/8/docs/api/javax/swing/Action.html)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
84
command/etc/command.urm.puml
Normal file
84
command/etc/command.urm.puml
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.command {
|
||||||
|
class InvisibilitySpell {
|
||||||
|
- target : Target
|
||||||
|
+ InvisibilitySpell()
|
||||||
|
+ execute(target : Target)
|
||||||
|
+ redo()
|
||||||
|
+ toString() : String
|
||||||
|
+ undo()
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
abstract class Command {
|
||||||
|
+ Command()
|
||||||
|
+ execute(Target) {abstract}
|
||||||
|
+ redo() {abstract}
|
||||||
|
+ toString() : String {abstract}
|
||||||
|
+ undo() {abstract}
|
||||||
|
}
|
||||||
|
class Goblin {
|
||||||
|
+ Goblin()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
abstract class Target {
|
||||||
|
- size : Size
|
||||||
|
- visibility : Visibility
|
||||||
|
+ Target()
|
||||||
|
+ getSize() : Size
|
||||||
|
+ getVisibility() : Visibility
|
||||||
|
+ printStatus()
|
||||||
|
+ setSize(size : Size)
|
||||||
|
+ setVisibility(visibility : Visibility)
|
||||||
|
+ toString() : String {abstract}
|
||||||
|
}
|
||||||
|
class Wizard {
|
||||||
|
- redoStack : Deque<Command>
|
||||||
|
- undoStack : Deque<Command>
|
||||||
|
+ Wizard()
|
||||||
|
+ castSpell(command : Command, target : Target)
|
||||||
|
+ redoLastSpell()
|
||||||
|
+ toString() : String
|
||||||
|
+ undoLastSpell()
|
||||||
|
}
|
||||||
|
class ShrinkSpell {
|
||||||
|
- oldSize : Size
|
||||||
|
- target : Target
|
||||||
|
+ ShrinkSpell()
|
||||||
|
+ execute(target : Target)
|
||||||
|
+ redo()
|
||||||
|
+ toString() : String
|
||||||
|
+ undo()
|
||||||
|
}
|
||||||
|
enum Size {
|
||||||
|
+ LARGE {static}
|
||||||
|
+ NORMAL {static}
|
||||||
|
+ SMALL {static}
|
||||||
|
+ UNDEFINED {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Size {static}
|
||||||
|
+ values() : Size[] {static}
|
||||||
|
}
|
||||||
|
enum Visibility {
|
||||||
|
+ INVISIBLE {static}
|
||||||
|
+ UNDEFINED {static}
|
||||||
|
+ VISIBLE {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Visibility {static}
|
||||||
|
+ values() : Visibility[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Target --> "-size" Size
|
||||||
|
Wizard --> "-undoStack" Command
|
||||||
|
ShrinkSpell --> "-oldSize" Size
|
||||||
|
InvisibilitySpell --> "-target" Target
|
||||||
|
ShrinkSpell --> "-target" Target
|
||||||
|
Target --> "-visibility" Visibility
|
||||||
|
InvisibilitySpell --|> Command
|
||||||
|
Goblin --|> Target
|
||||||
|
ShrinkSpell --|> Command
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>command</artifactId>
|
<artifactId>command</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Composite
|
title: Composite
|
||||||
folder: composite
|
folder: composite
|
||||||
permalink: /patterns/composite/
|
permalink: /patterns/composite/
|
||||||
|
pumlid: HSf13eCm30NHgy01YFUzZGaM62LEP7-NwvTTT_EaMTLgoqFIst81Cpv4payv5LVk6U9r6CHGwkYaBHy6EztyvUsGqDEsoO2u1NMED-WTvmY5aA3-LT9xcTdR3m00
|
||||||
categories: Structural
|
categories: Structural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
42
composite/etc/composite.urm.puml
Normal file
42
composite/etc/composite.urm.puml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.composite {
|
||||||
|
class Word {
|
||||||
|
+ Word(letters : List<Letter>)
|
||||||
|
# printThisAfter()
|
||||||
|
# printThisBefore()
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Messenger {
|
||||||
|
+ Messenger()
|
||||||
|
~ messageFromElves() : LetterComposite
|
||||||
|
~ messageFromOrcs() : LetterComposite
|
||||||
|
}
|
||||||
|
class Letter {
|
||||||
|
- c : char
|
||||||
|
+ Letter(c : char)
|
||||||
|
# printThisAfter()
|
||||||
|
# printThisBefore()
|
||||||
|
}
|
||||||
|
class Sentence {
|
||||||
|
+ Sentence(words : List<Word>)
|
||||||
|
# printThisAfter()
|
||||||
|
# printThisBefore()
|
||||||
|
}
|
||||||
|
abstract class LetterComposite {
|
||||||
|
- children : List<LetterComposite>
|
||||||
|
+ LetterComposite()
|
||||||
|
+ add(letter : LetterComposite)
|
||||||
|
+ count() : int
|
||||||
|
+ print()
|
||||||
|
# printThisAfter() {abstract}
|
||||||
|
# printThisBefore() {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LetterComposite --> "-children" LetterComposite
|
||||||
|
Word --|> LetterComposite
|
||||||
|
Letter --|> LetterComposite
|
||||||
|
Sentence --|> LetterComposite
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>composite</artifactId>
|
<artifactId>composite</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Data Access Object
|
title: Data Access Object
|
||||||
folder: dao
|
folder: dao
|
||||||
permalink: /patterns/dao/
|
permalink: /patterns/dao/
|
||||||
|
pumlid: 5SR14OKW30N0LhG0oVrt4o6ZE12Ov4NR_thQNQlc5aN2sd82qtz4naywAixOmyNoK8WYvT6fjdWOR7JnpLiHhuTkam4nTUhiRwZm847-J64zpUZj3m00
|
||||||
categories: Persistence Tier
|
categories: Persistence Tier
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
65
dao/etc/dao.urm.puml
Normal file
65
dao/etc/dao.urm.puml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.dao {
|
||||||
|
class InMemoryCustomerDao {
|
||||||
|
- idToCustomer : Map<Integer, Customer>
|
||||||
|
+ InMemoryCustomerDao()
|
||||||
|
+ add(customer : Customer) : boolean
|
||||||
|
+ delete(customer : Customer) : boolean
|
||||||
|
+ getAll() : Stream<Customer>
|
||||||
|
+ getById(id : int) : Optional<Customer>
|
||||||
|
+ update(customer : Customer) : boolean
|
||||||
|
}
|
||||||
|
interface CustomerSchemaSql {
|
||||||
|
+ CREATE_SCHEMA_SQL : String {static}
|
||||||
|
+ DELETE_SCHEMA_SQL : String {static}
|
||||||
|
}
|
||||||
|
interface CustomerDao {
|
||||||
|
+ add(Customer) : boolean {abstract}
|
||||||
|
+ delete(Customer) : boolean {abstract}
|
||||||
|
+ getAll() : Stream<Customer> {abstract}
|
||||||
|
+ getById(int) : Optional<Customer> {abstract}
|
||||||
|
+ update(Customer) : boolean {abstract}
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
- DB_URL : String {static}
|
||||||
|
- log : Logger {static}
|
||||||
|
+ App()
|
||||||
|
- addCustomers(customerDao : CustomerDao) {static}
|
||||||
|
- createDataSource() : DataSource {static}
|
||||||
|
- createSchema(dataSource : DataSource) {static}
|
||||||
|
- deleteSchema(dataSource : DataSource) {static}
|
||||||
|
+ generateSampleCustomers() : List<Customer> {static}
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- performOperationsUsing(customerDao : CustomerDao) {static}
|
||||||
|
}
|
||||||
|
class DbCustomerDao {
|
||||||
|
- dataSource : DataSource
|
||||||
|
+ DbCustomerDao(dataSource : DataSource)
|
||||||
|
+ add(customer : Customer) : boolean
|
||||||
|
- createCustomer(resultSet : ResultSet) : Customer
|
||||||
|
+ delete(customer : Customer) : boolean
|
||||||
|
+ getAll() : Stream<Customer>
|
||||||
|
+ getById(id : int) : Optional<Customer>
|
||||||
|
- getConnection() : Connection
|
||||||
|
- mutedClose(connection : Connection)
|
||||||
|
+ update(customer : Customer) : boolean
|
||||||
|
}
|
||||||
|
class Customer {
|
||||||
|
- firstName : String
|
||||||
|
- id : int
|
||||||
|
- lastName : String
|
||||||
|
+ Customer(id : int, firstName : String, lastName : String)
|
||||||
|
+ equals(that : Object) : boolean
|
||||||
|
+ getFirstName() : String
|
||||||
|
+ getId() : int
|
||||||
|
+ getLastName() : String
|
||||||
|
+ hashCode() : int
|
||||||
|
+ setFirstName(firstName : String)
|
||||||
|
+ setId(id : int)
|
||||||
|
+ setLastName(lastName : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
InMemoryCustomerDao ..|> CustomerDao
|
||||||
|
DbCustomerDao ..|> CustomerDao
|
||||||
|
@enduml
|
@ -30,7 +30,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>dao</artifactId>
|
<artifactId>dao</artifactId>
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Data Mapper
|
title: Data Mapper
|
||||||
folder: data-mapper
|
folder: data-mapper
|
||||||
permalink: /patterns/data-mapper/
|
permalink: /patterns/data-mapper/
|
||||||
|
pumlid: JShB3OGm303HLg20nFVjnYGM1CN6ycTfVtFSsnjfzY5jPgUqkLqHwXy0mxUU8wuyqidQ8q4IjJqCO-QBWGOtVh5qyd5AKOmW4mT6Nu2-ZiAekapH_hkcSTNa-GC0
|
||||||
categories: Persistence Tier
|
categories: Persistence Tier
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
42
data-mapper/etc/data-mapper.urm.puml
Normal file
42
data-mapper/etc/data-mapper.urm.puml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.datamapper {
|
||||||
|
interface StudentDataMapper {
|
||||||
|
+ delete(Student) {abstract}
|
||||||
|
+ find(int) : Optional<Student> {abstract}
|
||||||
|
+ insert(Student) {abstract}
|
||||||
|
+ update(Student) {abstract}
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
- log : Logger {static}
|
||||||
|
- App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Student {
|
||||||
|
- grade : char
|
||||||
|
- name : String
|
||||||
|
- serialVersionUID : long {static}
|
||||||
|
- studentId : int
|
||||||
|
+ Student(studentId : int, name : String, grade : char)
|
||||||
|
+ equals(inputObject : Object) : boolean
|
||||||
|
+ getGrade() : char
|
||||||
|
+ getName() : String
|
||||||
|
+ getStudentId() : int
|
||||||
|
+ hashCode() : int
|
||||||
|
+ setGrade(grade : char)
|
||||||
|
+ setName(name : String)
|
||||||
|
+ setStudentId(studentId : int)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class StudentDataMapperImpl {
|
||||||
|
- students : List<Student>
|
||||||
|
+ StudentDataMapperImpl()
|
||||||
|
+ delete(studentToBeDeleted : Student)
|
||||||
|
+ find(studentId : int) : Optional<Student>
|
||||||
|
+ getStudents() : List<Student>
|
||||||
|
+ insert(studentToBeInserted : Student)
|
||||||
|
+ update(studentToBeUpdated : Student)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StudentDataMapperImpl --> "-students" Student
|
||||||
|
StudentDataMapperImpl ..|> StudentDataMapper
|
||||||
|
@enduml
|
@ -28,7 +28,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>data-mapper</artifactId>
|
<artifactId>data-mapper</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Decorator
|
title: Decorator
|
||||||
folder: decorator
|
folder: decorator
|
||||||
permalink: /patterns/decorator/
|
permalink: /patterns/decorator/
|
||||||
|
pumlid: HSV14SCm20J0Lk82BFxf1YF6LaP26ZZizfDVVhjRC-bPDRs_Bc35cyZvAMV3bKU6kao36ehCGQtdms2d3z-yLursshuOKBUWmV43LPNfZEcaaFzA-YWhH_y2
|
||||||
categories: Structural
|
categories: Structural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
@ -27,6 +28,14 @@ Use Decorator
|
|||||||
* for responsibilities that can be withdrawn
|
* for responsibilities that can be withdrawn
|
||||||
* when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing
|
* when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing
|
||||||
|
|
||||||
|
## Real world examples
|
||||||
|
* [java.io.InputStream](http://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html), [java.io.OutputStream](http://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html),
|
||||||
|
[java.io.Reader](http://docs.oracle.com/javase/8/docs/api/java/io/Reader.html) and [java.io.Writer](http://docs.oracle.com/javase/8/docs/api/java/io/Writer.html)
|
||||||
|
* [java.util.Collections#synchronizedXXX()](http://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#synchronizedCollection-java.util.Collection-)
|
||||||
|
* [java.util.Collections#unmodifiableXXX()](http://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#unmodifiableCollection-java.util.Collection-)
|
||||||
|
* [java.util.Collections#checkedXXX()](http://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#checkedCollection-java.util.Collection-java.lang.Class-)
|
||||||
|
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
|
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
|
||||||
|
29
decorator/etc/decorator.urm.puml
Normal file
29
decorator/etc/decorator.urm.puml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.decorator {
|
||||||
|
interface Hostile {
|
||||||
|
+ attack() {abstract}
|
||||||
|
+ fleeBattle() {abstract}
|
||||||
|
+ getAttackPower() : int {abstract}
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Troll {
|
||||||
|
+ Troll()
|
||||||
|
+ attack()
|
||||||
|
+ fleeBattle()
|
||||||
|
+ getAttackPower() : int
|
||||||
|
}
|
||||||
|
class SmartHostile {
|
||||||
|
- decorated : Hostile
|
||||||
|
+ SmartHostile(decorated : Hostile)
|
||||||
|
+ attack()
|
||||||
|
+ fleeBattle()
|
||||||
|
+ getAttackPower() : int
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SmartHostile --> "-decorated" Hostile
|
||||||
|
Troll ..|> Hostile
|
||||||
|
SmartHostile ..|> Hostile
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>decorator</artifactId>
|
<artifactId>decorator</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Delegation
|
title: Delegation
|
||||||
folder: delegation
|
folder: delegation
|
||||||
permalink: /patterns/delegation/
|
permalink: /patterns/delegation/
|
||||||
|
pumlid: JSV14GCX20NGLf82LkxfXbN69OFeu2VRVdBCxRsdUhLiac6F2rZxHHHybwwuyimjKQT37ANEGMfvCpZepHy-ccpjVYm697pJuFq3DJ7f39rEWlhNaZ7Aoc5V
|
||||||
categories: Behavioral
|
categories: Behavioral
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
36
delegation/etc/delegation.urm.puml
Normal file
36
delegation/etc/delegation.urm.puml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.delegation.simple.printers {
|
||||||
|
class HpPrinter {
|
||||||
|
+ HpPrinter()
|
||||||
|
+ print(message : String)
|
||||||
|
}
|
||||||
|
class EpsonPrinter {
|
||||||
|
+ EpsonPrinter()
|
||||||
|
+ print(message : String)
|
||||||
|
}
|
||||||
|
class CanonPrinter {
|
||||||
|
+ CanonPrinter()
|
||||||
|
+ print(message : String)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.delegation.simple {
|
||||||
|
class App {
|
||||||
|
+ MESSAGE_TO_PRINT : String {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class PrinterController {
|
||||||
|
- printer : Printer
|
||||||
|
+ PrinterController(printer : Printer)
|
||||||
|
+ print(message : String)
|
||||||
|
}
|
||||||
|
interface Printer {
|
||||||
|
+ print(String) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PrinterController --> "-printer" Printer
|
||||||
|
HpPrinter ..|> Printer
|
||||||
|
PrinterController ..|> Printer
|
||||||
|
EpsonPrinter ..|> Printer
|
||||||
|
CanonPrinter ..|> Printer
|
||||||
|
@enduml
|
@ -30,7 +30,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Dependency Injection
|
title: Dependency Injection
|
||||||
folder: dependency-injection
|
folder: dependency-injection
|
||||||
permalink: /patterns/dependency-injection/
|
permalink: /patterns/dependency-injection/
|
||||||
|
pumlid: RSdB3SCW303GLPe1mFTkunWhSGG6-PEesxS3zFQajubIpyPf_NL6B7y363xra3XpJsUZgS4QbUO0wVbWeC65DvR6BeUMXH5iwZ3GVu36YxMnqgU8NamXKu63_aPD6tNbw5y0
|
||||||
categories: Behavioral
|
categories: Behavioral
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
48
dependency-injection/etc/dependency-injection.urm.puml
Normal file
48
dependency-injection/etc/dependency-injection.urm.puml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.dependency.injection {
|
||||||
|
class AdvancedWizard {
|
||||||
|
- tobacco : Tobacco
|
||||||
|
+ AdvancedWizard(tobacco : Tobacco)
|
||||||
|
+ smoke()
|
||||||
|
}
|
||||||
|
interface Wizard {
|
||||||
|
+ smoke() {abstract}
|
||||||
|
}
|
||||||
|
class RivendellTobacco {
|
||||||
|
+ RivendellTobacco()
|
||||||
|
}
|
||||||
|
class SimpleWizard {
|
||||||
|
- tobacco : OldTobyTobacco
|
||||||
|
+ SimpleWizard()
|
||||||
|
+ smoke()
|
||||||
|
}
|
||||||
|
class OldTobyTobacco {
|
||||||
|
+ OldTobyTobacco()
|
||||||
|
}
|
||||||
|
class SecondBreakfastTobacco {
|
||||||
|
+ SecondBreakfastTobacco()
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
abstract class Tobacco {
|
||||||
|
+ Tobacco()
|
||||||
|
+ smoke(wizard : Wizard)
|
||||||
|
}
|
||||||
|
class GuiceWizard {
|
||||||
|
- tobacco : Tobacco
|
||||||
|
+ GuiceWizard(tobacco : Tobacco)
|
||||||
|
+ smoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SimpleWizard --> "-tobacco" OldTobyTobacco
|
||||||
|
AdvancedWizard --> "-tobacco" Tobacco
|
||||||
|
GuiceWizard --> "-tobacco" Tobacco
|
||||||
|
AdvancedWizard ..|> Wizard
|
||||||
|
RivendellTobacco --|> Tobacco
|
||||||
|
SimpleWizard ..|> Wizard
|
||||||
|
OldTobyTobacco --|> Tobacco
|
||||||
|
SecondBreakfastTobacco --|> Tobacco
|
||||||
|
GuiceWizard ..|> Wizard
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>dependency-injection</artifactId>
|
<artifactId>dependency-injection</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -43,10 +43,9 @@
|
|||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.inject</groupId>
|
<groupId>com.google.inject</groupId>
|
||||||
<artifactId>guice</artifactId>
|
<artifactId>guice</artifactId>
|
||||||
<version>4.0</version>
|
</dependency>
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Double Checked Locking
|
title: Double Checked Locking
|
||||||
folder: double-checked-locking
|
folder: double-checked-locking
|
||||||
permalink: /patterns/double-checked-locking/
|
permalink: /patterns/double-checked-locking/
|
||||||
|
pumlid: TSdH4SCW203GLTe1bFzkGv1J6qGFeLc_MI1_x-wzkv94uJ1vDVUrFm26LwxTMnonsMYgitgcEQ1BNEXeyCKVfiAxLqqBtTbqmy1z0ygCGpXHOpgv99bqTgt0JW-LmqPUCUGF
|
||||||
categories: Concurrency
|
categories: Concurrency
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
20
double-checked-locking/etc/double-checked-locking.urm.puml
Normal file
20
double-checked-locking/etc/double-checked-locking.urm.puml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.doublechecked.locking {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class Inventory {
|
||||||
|
- inventorySize : int
|
||||||
|
- items : List<Item>
|
||||||
|
- lock : Lock
|
||||||
|
+ Inventory(inventorySize : int)
|
||||||
|
+ addItem(item : Item) : boolean
|
||||||
|
+ getItems() : List<Item>
|
||||||
|
}
|
||||||
|
class Item {
|
||||||
|
+ Item()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Inventory --> "-items" Item
|
||||||
|
@enduml
|
@ -27,7 +27,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>double-checked-locking</artifactId>
|
<artifactId>double-checked-locking</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Double Dispatch
|
title: Double Dispatch
|
||||||
folder: double-dispatch
|
folder: double-dispatch
|
||||||
permalink: /patterns/double-dispatch/
|
permalink: /patterns/double-dispatch/
|
||||||
|
pumlid: NSbB3iCW303HgpG70Ezx6yTOWSeOv4zp_MRTtUZDCPGa6wV9gqTiVmCOtlKQqVDCPwEbmHgLreGXUMEWmGU_M1hxkBHiZ61JXud-1BILft1fmvz37JZetshQh3kd_000
|
||||||
categories: Other
|
categories: Other
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
65
double-dispatch/etc/double-dispatch.urm.puml
Normal file
65
double-dispatch/etc/double-dispatch.urm.puml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.doubledispatch {
|
||||||
|
abstract class GameObject {
|
||||||
|
- damaged : boolean
|
||||||
|
- onFire : boolean
|
||||||
|
+ GameObject(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(GameObject) {abstract}
|
||||||
|
+ collisionResolve(FlamingAsteroid) {abstract}
|
||||||
|
+ collisionResolve(Meteoroid) {abstract}
|
||||||
|
+ collisionResolve(SpaceStationIss) {abstract}
|
||||||
|
+ collisionResolve(SpaceStationMir) {abstract}
|
||||||
|
+ isDamaged() : boolean
|
||||||
|
+ isOnFire() : boolean
|
||||||
|
+ setDamaged(damaged : boolean)
|
||||||
|
+ setOnFire(onFire : boolean)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class SpaceStationIss {
|
||||||
|
+ SpaceStationIss(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(gameObject : GameObject)
|
||||||
|
}
|
||||||
|
class FlamingAsteroid {
|
||||||
|
+ FlamingAsteroid(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(gameObject : GameObject)
|
||||||
|
}
|
||||||
|
class SpaceStationMir {
|
||||||
|
+ SpaceStationMir(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(gameObject : GameObject)
|
||||||
|
+ collisionResolve(asteroid : FlamingAsteroid)
|
||||||
|
+ collisionResolve(iss : SpaceStationIss)
|
||||||
|
+ collisionResolve(meteoroid : Meteoroid)
|
||||||
|
+ collisionResolve(mir : SpaceStationMir)
|
||||||
|
}
|
||||||
|
class Meteoroid {
|
||||||
|
+ Meteoroid(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ collision(gameObject : GameObject)
|
||||||
|
+ collisionResolve(asteroid : FlamingAsteroid)
|
||||||
|
+ collisionResolve(iss : SpaceStationIss)
|
||||||
|
+ collisionResolve(meteoroid : Meteoroid)
|
||||||
|
+ collisionResolve(mir : SpaceStationMir)
|
||||||
|
}
|
||||||
|
class Rectangle {
|
||||||
|
- bottom : int
|
||||||
|
- left : int
|
||||||
|
- right : int
|
||||||
|
- top : int
|
||||||
|
+ Rectangle(left : int, top : int, right : int, bottom : int)
|
||||||
|
+ getBottom() : int
|
||||||
|
+ getLeft() : int
|
||||||
|
+ getRight() : int
|
||||||
|
+ getTop() : int
|
||||||
|
~ intersectsWith(r : Rectangle) : boolean
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameObject --|> Rectangle
|
||||||
|
SpaceStationIss --|> SpaceStationMir
|
||||||
|
FlamingAsteroid --|> Meteoroid
|
||||||
|
SpaceStationMir --|> GameObject
|
||||||
|
Meteoroid --|> GameObject
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>double-dispatch</artifactId>
|
<artifactId>double-dispatch</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,10 +3,12 @@ layout: pattern
|
|||||||
title: Event Aggregator
|
title: Event Aggregator
|
||||||
folder: event-aggregator
|
folder: event-aggregator
|
||||||
permalink: /patterns/event-aggregator/
|
permalink: /patterns/event-aggregator/
|
||||||
|
pumlid: PSf13iCW30NHgxG70Ezx6uTOX0eCih-JwvTzTwEdUJSjFKu9wwyBMFuXCdvoRRZY21ShKo6ANEQWrkDXiD6NRqwdUAkQ5WDYwZJOTv3SUqzSgqbbp0qeVvZ3Hbun-Wy0
|
||||||
categories: Structural
|
categories: Structural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
- Difficulty-Beginner
|
- Difficulty-Beginner
|
||||||
|
- Reactive
|
||||||
---
|
---
|
||||||
|
|
||||||
## Intent
|
## Intent
|
||||||
|
73
event-aggregator/etc/event-aggregator.urm.puml
Normal file
73
event-aggregator/etc/event-aggregator.urm.puml
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.event.aggregator {
|
||||||
|
class LordVarys {
|
||||||
|
+ LordVarys()
|
||||||
|
+ LordVarys(obs : EventObserver)
|
||||||
|
+ timePasses(day : Weekday)
|
||||||
|
}
|
||||||
|
abstract class EventEmitter {
|
||||||
|
- observers : List<EventObserver>
|
||||||
|
+ EventEmitter()
|
||||||
|
+ EventEmitter(obs : EventObserver)
|
||||||
|
# notifyObservers(e : Event)
|
||||||
|
+ registerObserver(obs : EventObserver)
|
||||||
|
+ timePasses(Weekday) {abstract}
|
||||||
|
}
|
||||||
|
class KingJoffrey {
|
||||||
|
+ KingJoffrey()
|
||||||
|
+ onEvent(e : Event)
|
||||||
|
}
|
||||||
|
class LordBaelish {
|
||||||
|
+ LordBaelish()
|
||||||
|
+ LordBaelish(obs : EventObserver)
|
||||||
|
+ timePasses(day : Weekday)
|
||||||
|
}
|
||||||
|
interface EventObserver {
|
||||||
|
+ onEvent(Event) {abstract}
|
||||||
|
}
|
||||||
|
class KingsHand {
|
||||||
|
+ KingsHand()
|
||||||
|
+ KingsHand(obs : EventObserver)
|
||||||
|
+ onEvent(e : Event)
|
||||||
|
+ timePasses(day : Weekday)
|
||||||
|
}
|
||||||
|
class Scout {
|
||||||
|
+ Scout()
|
||||||
|
+ Scout(obs : EventObserver)
|
||||||
|
+ timePasses(day : Weekday)
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
enum Weekday {
|
||||||
|
+ FRIDAY {static}
|
||||||
|
+ MONDAY {static}
|
||||||
|
+ SATURDAY {static}
|
||||||
|
+ SUNDAY {static}
|
||||||
|
+ THURSDAY {static}
|
||||||
|
+ TUESDAY {static}
|
||||||
|
+ WEDNESDAY {static}
|
||||||
|
- description : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Weekday {static}
|
||||||
|
+ values() : Weekday[] {static}
|
||||||
|
}
|
||||||
|
enum Event {
|
||||||
|
+ STARK_SIGHTED {static}
|
||||||
|
+ TRAITOR_DETECTED {static}
|
||||||
|
+ WARSHIPS_APPROACHING {static}
|
||||||
|
- description : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : Event {static}
|
||||||
|
+ values() : Event[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EventEmitter --> "-observers" EventObserver
|
||||||
|
LordVarys --|> EventEmitter
|
||||||
|
KingJoffrey ..|> EventObserver
|
||||||
|
LordBaelish --|> EventEmitter
|
||||||
|
KingsHand ..|> EventObserver
|
||||||
|
KingsHand --|> EventEmitter
|
||||||
|
Scout --|> EventEmitter
|
||||||
|
@enduml
|
@ -28,7 +28,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>event-aggregator</artifactId>
|
<artifactId>event-aggregator</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
|
---
|
||||||
layout: pattern
|
layout: pattern
|
||||||
title: Event Driven Architecture
|
title: Event Driven Architecture
|
||||||
folder: event-driven-architecture
|
folder: event-driven-architecture
|
||||||
permalink: /patterns/event-driven-architecture
|
permalink: /patterns/event-driven-architecture/
|
||||||
|
pumlid: TOhH3SCW30LNQGS0_tSRnrZ15H1adfFromBzkfFktZQaHT7mzgh0N1yYvoUVXXf7B7Mv1dGWozN9MZmCTlhopQdeidEaoO3wMDHvRI6zzvwAssPYbsfGGRYIGlxN7DxpZDv-
|
||||||
|
categories: Architectural
|
||||||
|
tags:
|
||||||
|
- Java
|
||||||
|
- Difficulty-Intermediate
|
||||||
|
- Reactive
|
||||||
|
---
|
||||||
|
|
||||||
## Intent
|
## Intent
|
||||||
Send and notify state changes of your objects to other applications using an Event-driven Architecture.
|
Send and notify state changes of your objects to other applications using an Event-driven Architecture.
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.eda.handler {
|
||||||
|
class UserCreatedEventHandler {
|
||||||
|
+ UserCreatedEventHandler()
|
||||||
|
+ onEvent(event : UserCreatedEvent)
|
||||||
|
}
|
||||||
|
class UserUpdatedEventHandler {
|
||||||
|
+ UserUpdatedEventHandler()
|
||||||
|
+ onEvent(event : UserUpdatedEvent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eda.event {
|
||||||
|
abstract class AbstractEvent {
|
||||||
|
+ AbstractEvent()
|
||||||
|
+ getType() : Class<? extends Event>
|
||||||
|
}
|
||||||
|
class UserCreatedEvent {
|
||||||
|
- user : User
|
||||||
|
+ UserCreatedEvent(user : User)
|
||||||
|
+ getUser() : User
|
||||||
|
}
|
||||||
|
class UserUpdatedEvent {
|
||||||
|
- user : User
|
||||||
|
+ UserUpdatedEvent(user : User)
|
||||||
|
+ getUser() : User
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eda.framework {
|
||||||
|
interface Handler<E extends Event> {
|
||||||
|
+ onEvent(E extends Event) {abstract}
|
||||||
|
}
|
||||||
|
class EventDispatcher {
|
||||||
|
- handlers : Map<Class<? extends Event>, Handler<? extends Event>>
|
||||||
|
+ EventDispatcher()
|
||||||
|
+ dispatch(event : E extends Event)
|
||||||
|
+ registerHandler(eventType : Class<E extends Event>, handler : Handler<E extends Event>)
|
||||||
|
}
|
||||||
|
interface Event {
|
||||||
|
+ getType() : Class<? extends Event> {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eda.model {
|
||||||
|
class User {
|
||||||
|
- username : String
|
||||||
|
+ User(username : String)
|
||||||
|
+ getUsername() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.eda {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UserUpdatedEvent --> "-user" User
|
||||||
|
UserCreatedEvent --> "-user" User
|
||||||
|
AbstractEvent ..|> Event
|
||||||
|
UserCreatedEvent --|> AbstractEvent
|
||||||
|
UserCreatedEventHandler ..|> Handler
|
||||||
|
UserUpdatedEvent --|> AbstractEvent
|
||||||
|
UserUpdatedEventHandler ..|> Handler
|
||||||
|
@enduml
|
@ -31,7 +31,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>event-driven-architecture</artifactId>
|
<artifactId>event-driven-architecture</artifactId>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Execute Around
|
title: Execute Around
|
||||||
folder: execute-around
|
folder: execute-around
|
||||||
permalink: /patterns/execute-around/
|
permalink: /patterns/execute-around/
|
||||||
|
pumlid: NSZ14G8n20NGLhI0XBlT865suoGa0n_NylNixSsxTvEHJTF7xGHsF8YShtfqdFdCK9TbK4ELDQcFl1ZizE8tbwRH3okR0NKBcXm_a7vK4bhOLreZXVnLJPzrvnnV
|
||||||
categories: Other
|
categories: Other
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
14
execute-around/etc/execute-around.urm.puml
Normal file
14
execute-around/etc/execute-around.urm.puml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.execute.around {
|
||||||
|
class SimpleFileWriter {
|
||||||
|
+ SimpleFileWriter(filename : String, action : FileWriterAction)
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface FileWriterAction {
|
||||||
|
+ writeFile(FileWriter) {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>execute-around</artifactId>
|
<artifactId>execute-around</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Facade
|
title: Facade
|
||||||
folder: facade
|
folder: facade
|
||||||
permalink: /patterns/facade/
|
permalink: /patterns/facade/
|
||||||
|
pumlid: BSP15eCm20N0gxG7CEoz3ILKqvTW7dpq-hhehERTJ7fMJU-l7PYn4ZbVPMlOyvEXBeT13KMEGQtdnM2d7v-yL8sssJ8PKBUWmV64lYnSbHJoRqaVPUReDm00
|
||||||
categories: Structural
|
categories: Structural
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
57
facade/etc/facade.urm.puml
Normal file
57
facade/etc/facade.urm.puml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.facade {
|
||||||
|
class DwarvenGoldDigger {
|
||||||
|
+ DwarvenGoldDigger()
|
||||||
|
+ name() : String
|
||||||
|
+ work()
|
||||||
|
}
|
||||||
|
class DwarvenGoldmineFacade {
|
||||||
|
- workers : List<DwarvenMineWorker>
|
||||||
|
+ DwarvenGoldmineFacade()
|
||||||
|
+ digOutGold()
|
||||||
|
+ endDay()
|
||||||
|
- makeActions(workers : Collection<DwarvenMineWorker>, actions : Action[]) {static}
|
||||||
|
+ startNewDay()
|
||||||
|
}
|
||||||
|
class DwarvenTunnelDigger {
|
||||||
|
+ DwarvenTunnelDigger()
|
||||||
|
+ name() : String
|
||||||
|
+ work()
|
||||||
|
}
|
||||||
|
abstract class DwarvenMineWorker {
|
||||||
|
+ DwarvenMineWorker()
|
||||||
|
- action(action : Action)
|
||||||
|
+ action(actions : Action[])
|
||||||
|
+ goHome()
|
||||||
|
+ goToMine()
|
||||||
|
+ goToSleep()
|
||||||
|
+ name() : String {abstract}
|
||||||
|
+ wakeUp()
|
||||||
|
+ work() {abstract}
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
class DwarvenCartOperator {
|
||||||
|
+ DwarvenCartOperator()
|
||||||
|
+ name() : String
|
||||||
|
+ work()
|
||||||
|
}
|
||||||
|
~enum Action {
|
||||||
|
+ GO_HOME {static}
|
||||||
|
+ GO_TO_MINE {static}
|
||||||
|
+ GO_TO_SLEEP {static}
|
||||||
|
+ WAKE_UP {static}
|
||||||
|
+ WORK {static}
|
||||||
|
+ valueOf(name : String) : Action {static}
|
||||||
|
+ values() : Action[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DwarvenGoldmineFacade --+ DwarvenMineWorker
|
||||||
|
DwarvenGoldmineFacade --> "-workers" DwarvenMineWorker
|
||||||
|
Action ..+ DwarvenMineWorker
|
||||||
|
DwarvenGoldDigger --|> DwarvenMineWorker
|
||||||
|
DwarvenTunnelDigger --|> DwarvenMineWorker
|
||||||
|
DwarvenCartOperator --|> DwarvenMineWorker
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>facade</artifactId>
|
<artifactId>facade</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Factory Kit
|
title: Factory Kit
|
||||||
folder: factory-kit
|
folder: factory-kit
|
||||||
permalink: /patterns/factory-kit/
|
permalink: /patterns/factory-kit/
|
||||||
|
pumlid: JST15i8m20N0g-W14lRU1YcsQ4BooCS-RwzBTpDNSscvQKQx7C1SDwBWi-w68--vD6Gur55bTBAM9uE3dlpcikcotSjaGCCNTLu_q8C58pxbPI25_Bzcz3gpjoy0
|
||||||
categories: Creational
|
categories: Creational
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
45
factory-kit/etc/factory-kit.urm.puml
Normal file
45
factory-kit/etc/factory-kit.urm.puml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.factorykit {
|
||||||
|
class Spear {
|
||||||
|
+ Spear()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
interface Weapon {
|
||||||
|
}
|
||||||
|
interface WeaponFactory {
|
||||||
|
+ create(WeaponType) : Weapon {abstract}
|
||||||
|
+ factory(consumer : Consumer<Builder>) : WeaponFactory {static}
|
||||||
|
}
|
||||||
|
class Axe {
|
||||||
|
+ Axe()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Sword {
|
||||||
|
+ Sword()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class Bow {
|
||||||
|
+ Bow()
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface Builder {
|
||||||
|
+ add(WeaponType, Supplier<Weapon>) {abstract}
|
||||||
|
}
|
||||||
|
enum WeaponType {
|
||||||
|
+ AXE {static}
|
||||||
|
+ BOW {static}
|
||||||
|
+ SPEAR {static}
|
||||||
|
+ SWORD {static}
|
||||||
|
+ valueOf(name : String) : WeaponType {static}
|
||||||
|
+ values() : WeaponType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spear ..|> Weapon
|
||||||
|
Axe ..|> Weapon
|
||||||
|
Sword ..|> Weapon
|
||||||
|
Bow ..|> Weapon
|
||||||
|
@enduml
|
@ -30,7 +30,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>factory-kit</artifactId>
|
<artifactId>factory-kit</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,8 +3,9 @@ layout: pattern
|
|||||||
title: Factory Method
|
title: Factory Method
|
||||||
folder: factory-method
|
folder: factory-method
|
||||||
permalink: /patterns/factory-method/
|
permalink: /patterns/factory-method/
|
||||||
|
pumlid: NSZB3G8n30N0Lg20n7UwCOxPP9MVx6TMT0zdRgEvjoazYeRrMmMsFuYChtmqr7Y6gycQq8aiQr3hSJ7OwEGtfwBUZfas0shJQR3_G2yMBFkaeQYha4B-AeUDl6FqBm00
|
||||||
categories: Creational
|
categories: Creational
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
- Difficulty-Beginner
|
- Difficulty-Beginner
|
||||||
- Gang Of Four
|
- Gang Of Four
|
||||||
@ -27,6 +28,16 @@ Use the Factory Method pattern when
|
|||||||
* a class wants its subclasses to specify the objects it creates
|
* a class wants its subclasses to specify the objects it creates
|
||||||
* classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate
|
* classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate
|
||||||
|
|
||||||
|
## Known uses
|
||||||
|
|
||||||
|
* [java.util.Calendar](http://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getInstance--)
|
||||||
|
* [java.util.ResourceBundle](http://docs.oracle.com/javase/8/docs/api/java/util/ResourceBundle.html#getBundle-java.lang.String-)
|
||||||
|
* [java.text.NumberFormat](http://docs.oracle.com/javase/8/docs/api/java/text/NumberFormat.html#getInstance--)
|
||||||
|
* [java.nio.charset.Charset](http://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html#forName-java.lang.String-)
|
||||||
|
* [java.net.URLStreamHandlerFactory](http://docs.oracle.com/javase/8/docs/api/java/net/URLStreamHandlerFactory.html#createURLStreamHandler-java.lang.String-)
|
||||||
|
* [java.util.EnumSet](https://docs.oracle.com/javase/8/docs/api/java/util/EnumSet.html#of-E-)
|
||||||
|
* [javax.xml.bind.JAXBContext](https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/JAXBContext.html#createMarshaller--)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
|
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
|
||||||
|
53
factory-method/etc/factory-method.urm.puml
Normal file
53
factory-method/etc/factory-method.urm.puml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.factory.method {
|
||||||
|
class OrcBlacksmith {
|
||||||
|
+ OrcBlacksmith()
|
||||||
|
+ manufactureWeapon(weaponType : WeaponType) : Weapon
|
||||||
|
}
|
||||||
|
class ElfBlacksmith {
|
||||||
|
+ ElfBlacksmith()
|
||||||
|
+ manufactureWeapon(weaponType : WeaponType) : Weapon
|
||||||
|
}
|
||||||
|
class OrcWeapon {
|
||||||
|
- weaponType : WeaponType
|
||||||
|
+ OrcWeapon(weaponType : WeaponType)
|
||||||
|
+ getWeaponType() : WeaponType
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
interface Blacksmith {
|
||||||
|
+ manufactureWeapon(WeaponType) : Weapon {abstract}
|
||||||
|
}
|
||||||
|
class ElfWeapon {
|
||||||
|
- weaponType : WeaponType
|
||||||
|
+ ElfWeapon(weaponType : WeaponType)
|
||||||
|
+ getWeaponType() : WeaponType
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class App {
|
||||||
|
- blacksmith : Blacksmith
|
||||||
|
+ App(blacksmith : Blacksmith)
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
- manufactureWeapons()
|
||||||
|
}
|
||||||
|
interface Weapon {
|
||||||
|
+ getWeaponType() : WeaponType {abstract}
|
||||||
|
}
|
||||||
|
enum WeaponType {
|
||||||
|
+ AXE {static}
|
||||||
|
+ SHORT_SWORD {static}
|
||||||
|
+ SPEAR {static}
|
||||||
|
+ UNDEFINED {static}
|
||||||
|
- title : String
|
||||||
|
+ toString() : String
|
||||||
|
+ valueOf(name : String) : WeaponType {static}
|
||||||
|
+ values() : WeaponType[] {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ElfWeapon --> "-weaponType" WeaponType
|
||||||
|
OrcWeapon --> "-weaponType" WeaponType
|
||||||
|
App --> "-blacksmith" Blacksmith
|
||||||
|
OrcBlacksmith ..|> Blacksmith
|
||||||
|
ElfBlacksmith ..|> Blacksmith
|
||||||
|
OrcWeapon ..|> Weapon
|
||||||
|
ElfWeapon ..|> Weapon
|
||||||
|
@enduml
|
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>factory-method</artifactId>
|
<artifactId>factory-method</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
10
faq.md
10
faq.md
@ -3,7 +3,7 @@ layout: page
|
|||||||
title: FAQ
|
title: FAQ
|
||||||
permalink: /faq/
|
permalink: /faq/
|
||||||
icon: fa-question
|
icon: fa-question
|
||||||
page-index: 1
|
page-index: 5
|
||||||
---
|
---
|
||||||
|
|
||||||
### Q1: What is the difference between State and Strategy patterns? {#Q1}
|
### Q1: What is the difference between State and Strategy patterns? {#Q1}
|
||||||
@ -65,3 +65,11 @@ Flyweight.
|
|||||||
### Q7: What are the differences between FluentInterface and Builder patterns? {#Q7}
|
### Q7: What are the differences between FluentInterface and Builder patterns? {#Q7}
|
||||||
|
|
||||||
Fluent interfaces are sometimes confused with the Builder pattern, because they share method chaining and a fluent usage. However, fluent interfaces are not primarily used to create shared (mutable) objects, but to configure complex objects without having to respecify the target object on every property change.
|
Fluent interfaces are sometimes confused with the Builder pattern, because they share method chaining and a fluent usage. However, fluent interfaces are not primarily used to create shared (mutable) objects, but to configure complex objects without having to respecify the target object on every property change.
|
||||||
|
|
||||||
|
### Q8: What is the difference between java.io.Serialization and Memento pattern? {#Q8}
|
||||||
|
|
||||||
|
Memento is typically used to implement rollback/save-point support. Example we might want to mark the state of an object at a point in time, do some work and then decide to rollback to the previous state.
|
||||||
|
|
||||||
|
On the other hand serialization may be used as a tool to save the state of an object into byte[] and preserving the contents in memory or disk. When someone invokes the memento to revert object's previous state then we can deserialize the information stored and recreate previous state.
|
||||||
|
|
||||||
|
So Memento is a pattern and serialization is a tool that can be used to implement this pattern. Other ways to implement the pattern can be to clone the contents of the object and keep track of those clones.
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Feature Toggle
|
title: Feature Toggle
|
||||||
folder: feature-toggle
|
folder: feature-toggle
|
||||||
permalink: /patterns/feature-toggle/
|
permalink: /patterns/feature-toggle/
|
||||||
|
pumlid: NSZ14G8X30NGLhG0oDrk8XjPd12OvCTjNy_UthpxiAPvIBhUJc37WyZvgdtWp6U6U5i6CTIs9WtDYy5ER_vmEIH6jx8P4BUWoV43lOIHBWMhTnKIjB-gwRFkdFe5
|
||||||
categories: Behavioral
|
categories: Behavioral
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
47
feature-toggle/etc/feature-toggle.urm.puml
Normal file
47
feature-toggle/etc/feature-toggle.urm.puml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
@startuml
|
||||||
|
package com.iluwatar.featuretoggle.pattern {
|
||||||
|
interface Service {
|
||||||
|
+ getWelcomeMessage(User) : String {abstract}
|
||||||
|
+ isEnhanced() : boolean {abstract}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.featuretoggle.user {
|
||||||
|
class User {
|
||||||
|
- name : String
|
||||||
|
+ User(name : String)
|
||||||
|
+ toString() : String
|
||||||
|
}
|
||||||
|
class UserGroup {
|
||||||
|
- freeGroup : List<User> {static}
|
||||||
|
- paidGroup : List<User> {static}
|
||||||
|
+ UserGroup()
|
||||||
|
+ addUserToFreeGroup(user : User) {static}
|
||||||
|
+ addUserToPaidGroup(user : User) {static}
|
||||||
|
+ isPaid(user : User) : boolean {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.featuretoggle.pattern.tieredversion {
|
||||||
|
class TieredFeatureToggleVersion {
|
||||||
|
+ TieredFeatureToggleVersion()
|
||||||
|
+ getWelcomeMessage(user : User) : String
|
||||||
|
+ isEnhanced() : boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.featuretoggle.pattern.propertiesversion {
|
||||||
|
class PropertiesFeatureToggleVersion {
|
||||||
|
- isEnhanced : boolean
|
||||||
|
+ PropertiesFeatureToggleVersion(properties : Properties)
|
||||||
|
+ getWelcomeMessage(user : User) : String
|
||||||
|
+ isEnhanced() : boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package com.iluwatar.featuretoggle {
|
||||||
|
class App {
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UserGroup --> "-freeGroup" User
|
||||||
|
PropertiesFeatureToggleVersion ..|> Service
|
||||||
|
TieredFeatureToggleVersion ..|> Service
|
||||||
|
@enduml
|
@ -30,7 +30,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.12.0</version>
|
<version>1.13.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ layout: pattern
|
|||||||
title: Fluent Interface
|
title: Fluent Interface
|
||||||
folder: fluentinterface
|
folder: fluentinterface
|
||||||
permalink: /patterns/fluentinterface/
|
permalink: /patterns/fluentinterface/
|
||||||
|
pumlid: NOj93eCm302_KXv0VEzlN6F0bMCYB_3zvjpRQ3IpY97MnkNwEZD7l04SdtP8dlMfOAVBaYqRNHr4wy54Xo_Uk6uSSjWwC9FT0Zh61DYrPY_pyXs9WPF-NIllRLJN7m00
|
||||||
categories: Other
|
categories: Other
|
||||||
tags:
|
tags:
|
||||||
- Java
|
- Java
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user