Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
201 commits
Select commit Hold shift + click to select a range
0c6237c
Type object pattern #555 (#848)
AnaghaSasikumar Jul 24, 2019
17bfc91
Change Travis CI build env. to Trusty (#911)
ptrax Jul 28, 2019
c6ecf58
508 : sonar qube critical issue fixes (#852)
kanwarpreet25 Jul 28, 2019
f7e22a1
508 : Sonar qube critical Issue Fix (#854)
kanwarpreet25 Jul 28, 2019
a113de6
Add licenses
iluwatar Jul 28, 2019
d9a567c
Commander pattern #505 (#857)
AnaghaSasikumar Jul 29, 2019
2757b21
Best practice when compare enum (#869)
hoangnam2261 Jul 29, 2019
aaabc8f
Fix the dependency conflict issue (#872)
HelloCoCooo Jul 29, 2019
b497d41
Modify Observer pattern UML (#877)
dRadest Jul 29, 2019
3454941
Typo coresponding -> corresponding (#879)
pierDipi Jul 29, 2019
36e80c4
fixed failing tests (#860) (#880)
id4us Jul 29, 2019
517c209
Added one more Credit/Article about the benefits of Repository patter…
tomrlh Jul 29, 2019
6daaeec
Remove the transitive dependency(junit-jupiter-api) (#916)
hoangnam2261 Jul 30, 2019
ccb257d
fixed bug #883 (#885)
ranjeet-floyd Aug 4, 2019
61ef59d
fix code example containing syntax error (#890)
makaravind Aug 11, 2019
085e47b
Update SonarCloud badge
iluwatar Aug 21, 2019
11c0550
Create .sonarcloud.properties
iluwatar Aug 21, 2019
7f6067f
Added priority queue design pattern (#888)
ranjeet-floyd Aug 31, 2019
318f811
Bytecode pattern #553 (#896)
pzawitowski Sep 3, 2019
35dc25d
MInor bug fix Issue #895 -> Code comment change (https://github.com/i…
saksham93 Sep 7, 2019
c653edf
fix must override a superclass method (#919)
anancds Sep 7, 2019
8c865e6
clean code (#910)
ibrahimAlii Sep 7, 2019
f141033
Fix issue #761: ThreadSafeDoubleCheckLocking.java: Instantiating by R…
Azureyjt Sep 7, 2019
88fae07
Fix broken links #915 (#921)
snehalatapandit Sep 7, 2019
9bf7a05
Java Design Patterns v1.21.0
iluwatar Sep 8, 2019
b874adc
Set version for next development iteration
iluwatar Sep 8, 2019
019abc9
Add license headers
iluwatar Sep 10, 2019
5f39f7f
Updating README.md file to update doc as suggested in issue#925 (#926)
hbothra15 Sep 20, 2019
6b297b7
Data Locality pattern #559 (#889)
ranjeet-floyd Sep 30, 2019
06fa92a
Removing the dead link to resove automagic issue as mentioned in issu…
hbothra15 Sep 30, 2019
3d62e02
fixed bug #929: close async service before the main thread finishes (…
npczwh Sep 30, 2019
b03e0b8
Fix for BallThreadTest#testResume (#935)
wanirudh Oct 1, 2019
823c58b
added new information (#937)
dignat Oct 2, 2019
05d0f0b
#834 Fix dependency management issue for POM files (#940)
perwramdemark Oct 3, 2019
218ba44
Upgrade of maven plugins (#951)
perwramdemark Oct 5, 2019
364c43a
Get rid of build warnings WARNING about problems found when building …
perwramdemark Oct 5, 2019
933de30
Add JXR plugin to get rid of WARNING Unable to locate Source XRef to …
perwramdemark Oct 5, 2019
60171e3
Fix for Issue #549 : Update Exception Handling Code in Aggregator Mic…
jarpit96 Oct 6, 2019
94ca254
Fix for issue #954 : Add external Dependencies to run with Java11 (#957)
jarpit96 Oct 6, 2019
2b1c09a
Fix link in Acyclic Visitor
iluwatar Oct 7, 2019
f5455f9
update buggy dependencies (#968)
Scuilion Oct 7, 2019
84c4b03
Fix: Github reports security vulnerabilities #933 (#960)
gaurav9822 Oct 8, 2019
f903d7e
#496 Pipeline pattern (#967)
jjjimenez100 Oct 8, 2019
41b8d80
Close #969 (#972)
erikgajdos1997 Oct 8, 2019
90ea450
Leader Election Pattern (#923)
Azureyjt Oct 8, 2019
795b6be
Configure Travis to build on JDK8 and JDK11
iluwatar Oct 11, 2019
71f26c3
Fix Travis xvfb
iluwatar Oct 11, 2019
e36bbbb
Maven profiles to support jdk 11 builds. #948 (#975)
lbroman Oct 11, 2019
6faec99
Bump java language to 11 (#980)
lbroman Oct 12, 2019
fcc1c0a
[mvn] - Remove maven-pmd-plugin from the project (#977) (#979)
Shumyk Oct 12, 2019
9ebbc42
Update license headers
iluwatar Oct 12, 2019
72b1746
#996 Fix SonarCloud analysis failure (#997)
iluwatar Oct 13, 2019
cfdfedb
#970 single logging framework should be enforced (#982)
jjjimenez100 Oct 13, 2019
47d92bb
#996 set sonar host url
iluwatar Oct 14, 2019
088bb76
#996 disable sonar analysis for pull requests (#999)
iluwatar Oct 14, 2019
7e698a9
Fix for issue #413: Circuit Breaker Pattern (#986)
PalAditya Oct 14, 2019
e6c71b6
988: Replaced all of the Apache HttpClients with Java's java.net.http…
oconnelc Oct 15, 2019
dd5997b
993: Fixed the pipeines project layout so that it will load in Eclips…
oconnelc Oct 15, 2019
c438ec0
Intermittent test failure in Spatial Partition pattern #1001 (#1006)
afflato Oct 15, 2019
27c131c
#1001 fix intermittent test failure (#1008)
Smirne Oct 15, 2019
a5646b6
#554: Subclass Sandbox pattern (#998)
Azureyjt Oct 16, 2019
880b234
Fixes #1007 by updating JUnit to 5.5.2 (#1015)
kaiwinter Oct 17, 2019
c308ca0
1011: Fixed all of the SonarCloud blocking errors (#1017)
oconnelc Oct 18, 2019
2982db4
Update README.md
iluwatar Oct 18, 2019
a204383
init repo for role object
Oct 19, 2019
c365610
add to init
Oct 19, 2019
0c60a95
Switched to embedded Google checkstyle rules (#1018)
kaiwinter Oct 19, 2019
8a48447
Remove obsolete file
iluwatar Oct 19, 2019
7c5d5f6
1010: Fixed all of the blocking and critical Sonarcloud errors (#1020)
oconnelc Oct 19, 2019
f09a7eb
add to init
Oct 19, 2019
f671f03
Update FAQ metadata
iluwatar Oct 19, 2019
82f9a6c
1010: Fixed the two remaining SonarCloud errors (#1023)
oconnelc Oct 20, 2019
2217fbc
Issue#550: double buffer pattern (#1024)
Azureyjt Oct 20, 2019
f00ebe1
#984 local variable inference changes (#1025)
Anurag870 Oct 20, 2019
20b4195
add first impl
Oct 20, 2019
5fc03ee
improve grammar of README (#945)
jonlaokan Oct 20, 2019
c81c3ff
Use local variable type inference (#995)
Oct 21, 2019
4904d7e
#1021: Fix checkstyle warnings by changing the license header templat…
vanogrid Oct 22, 2019
acaa6cd
local variable type inference changes (#1028)
gvsharma Oct 23, 2019
630532c
add pattern
Oct 24, 2019
9403d53
add license
Oct 24, 2019
1b6cecd
Update keywords
iluwatar Oct 24, 2019
1cb1bdc
https://github.com/iluwatar/java-design-patterns/issues/1009 - remove…
akrystian Oct 25, 2019
6aeafcf
https://github.com/iluwatar/java-design-patterns/issues/1016 - decrea…
akrystian Oct 26, 2019
70ddeaa
Create FUNDING.yml
iluwatar Oct 26, 2019
f7a53f2
service-layer local type inference changes (#1034)
gvsharma Oct 26, 2019
58d8fa1
local variable type inference changes (#1035)
gvsharma Oct 26, 2019
0b8d78e
local variable type inference changes (#1036)
gvsharma Oct 26, 2019
12f13a6
local variable infere changes (#1038)
gvsharma Oct 26, 2019
349d8ed
local variable type inference changes (#1039)
gvsharma Oct 26, 2019
af8c5ed
local variable type inference changes (#1040)
gvsharma Oct 26, 2019
03e1e92
local variable type inference changes (#1041)
gvsharma Oct 26, 2019
954e730
local variable type inference changes (#1043)
gvsharma Oct 26, 2019
c7fee7b
local variable type inference changes (#1042)
gvsharma Oct 26, 2019
fadad43
#984 for unitofwork, tolerantreader, twin (#1044)
Anurag870 Oct 26, 2019
e382794
add changes
Oct 26, 2019
d01a3a6
Update Github token
iluwatar Oct 26, 2019
5d47488
Fix error when building from a submodule directory (#1045)
vanogrid Oct 26, 2019
d1767bb
The pattern Role object (#1031)
besok Oct 26, 2019
9f7e3fe
Update license headers
iluwatar Oct 26, 2019
b50189e
Fix Role Object front matter
iluwatar Oct 26, 2019
63fb8dc
Add java 11 (#1048)
leonmak Oct 27, 2019
6bb3438
Add java 11 (#1049)
leonmak Oct 27, 2019
dd971d8
Use java 11 (#1050)
leonmak Oct 28, 2019
c8a481b
Add java 11 support for #987 (o-t) (#1051)
leonmak Oct 29, 2019
a65a601
Update web site logic
iluwatar Oct 29, 2019
ccc1a63
Update script
iluwatar Oct 29, 2019
ff52848
Update script
iluwatar Oct 29, 2019
91a085d
Update script
iluwatar Oct 30, 2019
fca7e9c
https://github.com/iluwatar/java-design-patterns/issues/1021 - decrea…
akrystian Oct 30, 2019
a9dfd7e
Update license header
iluwatar Oct 30, 2019
cdb80b8
Issue 893 (#1014)
hbothra15 Oct 30, 2019
cc85c73
Move faq.md to java-design-patterns-web repository
iluwatar Oct 30, 2019
1eb1961
Remove presentations
iluwatar Oct 30, 2019
3b1a281
decrease number of checkstyle errors in singleton, strategy and visit…
leonorader Oct 31, 2019
55b0341
Fix remaining Checkstyle errors for Singleton
iluwatar Oct 31, 2019
1d4a768
Fix for Issue #549 : Add Fallbacks in Aggregator Service (#971)
jarpit96 Nov 1, 2019
a8c7771
#1021 style changes for Specification
iluwatar Nov 1, 2019
768e647
add saga init dsc
Nov 2, 2019
564cf12
add init saga dsc
Nov 2, 2019
7ac47b2
add changes to dsc
Nov 2, 2019
0b17abd
#590 Add explanation for Specification pattern
iluwatar Nov 2, 2019
c4c37d7
add
Nov 2, 2019
3a4677c
add orchestrator
Nov 2, 2019
1b32e23
add ch
Nov 3, 2019
ffeee2f
separate pkgs
Nov 3, 2019
fbcfeb0
add info
Nov 3, 2019
7dc47da
#1021 Checkstyle fixes for Composite pattern
iluwatar Nov 5, 2019
47ae477
#1021 Checkstyle changes for Factory Method
iluwatar Nov 5, 2019
8ecdee4
#1021 Checkstyle fixes for Layers
iluwatar Nov 5, 2019
50986fa
#590 arrange Layers into packages and add explanation
iluwatar Nov 5, 2019
1fa8a60
Sharding Pattern (#1056)
Azureyjt Nov 8, 2019
09b4663
add choreogr
Nov 9, 2019
8f85353
merge changes
Nov 9, 2019
74c7273
rem space
Nov 9, 2019
6d1c0b1
Resolves checkstyle errors for ambassador, async-method-invocation, b…
anuragagarwal561994 Nov 9, 2019
efc17fc
Resolves checkstyle errors for business-delegate, bytecode, caching (…
anuragagarwal561994 Nov 9, 2019
31f27a7
Resolves checkstyle errors for callback, chain, circuit-breaker (#1060)
anuragagarwal561994 Nov 9, 2019
2f49648
Resolves checkstyle errors for collection-pipeline, command, commande…
anuragagarwal561994 Nov 9, 2019
de56cbb
change according to cgeckstyle
Nov 10, 2019
4f9ee01
Resolves checkstyle errors for converter, cqrs (#1063)
anuragagarwal561994 Nov 10, 2019
dda0953
Resolves checkstyle errors for guarded-suspension, half-sync-half-asy…
anuragagarwal561994 Nov 10, 2019
7f06f3b
Resolves checkstyle errors for intercepting-filter, interpreter, iter…
anuragagarwal561994 Nov 10, 2019
eae09fc
Resolves checkstyle errors for api-gateway, lazy-loading, leader-elec…
anuragagarwal561994 Nov 10, 2019
01e489c
Resolves checkstyle errors for dao data-bus data-locality data-mapper…
anuragagarwal561994 Nov 10, 2019
f2c91eb
Resolves checkstyle errors for delegation dependency-injection dirty-…
anuragagarwal561994 Nov 10, 2019
7c888e8
Resolves checkstyle errors for eip-* (#1069)
anuragagarwal561994 Nov 10, 2019
5ae2ce6
Resolves checkstyle errors for event-* (#1070)
anuragagarwal561994 Nov 10, 2019
4dae1fa
Resolves checkstyle errors for execute-around extension-objects (#1071)
anuragagarwal561994 Nov 10, 2019
9c8ad44
Resolves checkstyle errors for patterns starting with letter r (#1072)
anuragagarwal561994 Nov 10, 2019
b92eb52
Resolves checkstyle errors for template-method thread-pool throttling…
anuragagarwal561994 Nov 10, 2019
f0f0143
Resolves checkstyle errors for trampoline twin typeobjectpattern unit…
anuragagarwal561994 Nov 10, 2019
c441831
Java 11 migration: ambassador async-method-invocation balking bridge …
anuragagarwal561994 Nov 11, 2019
329479d
#984 update Ambassador readme
iluwatar Nov 11, 2019
0272d71
#984 update Bridge readme
iluwatar Nov 11, 2019
2628cc0
#984 update Builder readme
iluwatar Nov 11, 2019
c954a43
Resolves checkstyle errors for facade factory-kit spatial-partition s…
anuragagarwal561994 Nov 11, 2019
37599eb
Resolves checkstyle errors for feature-toggle fluentinterface flux fl…
anuragagarwal561994 Nov 11, 2019
3907951
Resolves checkstyle issues for semaphore servant serverless service-l…
anuragagarwal561994 Nov 11, 2019
1e76d91
Resolves checkstyle errors for abstract-document abstract-factory acy…
anuragagarwal561994 Nov 11, 2019
6ef840f
Resolves checkstyle errors for naked-objects null-object object-mothe…
anuragagarwal561994 Nov 12, 2019
33ea733
Java 11 migration: patterns (remaining b-c) (#1081)
anuragagarwal561994 Nov 12, 2019
3c57bf7
#984 #987 update readmes
iluwatar Nov 12, 2019
f04fc3c
Java 11 migration: patterns starting with a (#1084)
anuragagarwal561994 Nov 13, 2019
160b737
Add another real world example for Builder
iluwatar Nov 13, 2019
87af122
add changes according to google style
Nov 13, 2019
50467c9
Java 11 migration: patterns (t-v) (#1085)
anuragagarwal561994 Nov 14, 2019
51b444d
Merge branch 'master' of https://github.com/besok/java-design-patterns
iluwatar Nov 14, 2019
cc571f4
Saga pattern (#1062)
besok Nov 14, 2019
df8a4e3
Adding parameterized specification (Issue#1055) (#1088)
MaVdbussche Nov 16, 2019
3ccc9ba
Game Loop Pattern (#1083)
Azureyjt Nov 16, 2019
1fdc650
Resolves checkstyle errors for remaining m (#1090)
anuragagarwal561994 Nov 16, 2019
26f4aa8
Merge branch 'master' of https://github.com/iluwatar/java-design-patt…
iluwatar Nov 16, 2019
271d7ae
Resolves checkstyle errors for remaining p (#1091)
anuragagarwal561994 Nov 16, 2019
9e58edf
Merge branch 'master' of https://github.com/iluwatar/java-design-patt…
iluwatar Nov 16, 2019
8747f1f
#1021 enforce Checkstyle rules in the build
iluwatar Nov 16, 2019
cc4b990
#590 Add explanation for Converter pattern
iluwatar Nov 16, 2019
63c707f
Add game-loop to parent pom.xml
iluwatar Nov 16, 2019
19b129c
Fix several frontmatter issues
iluwatar Nov 16, 2019
73f9b8b
Adding composite specification (Issue#1093) (#1094)
MaVdbussche Nov 17, 2019
7d84550
Java Design Patterns 1.22.0
iluwatar Nov 17, 2019
6941e65
Set version for next development iteration
iluwatar Nov 17, 2019
8037495
Add some formatting to Specification pattern readme
iluwatar Nov 17, 2019
7e4d0b4
Changes aggregation to composition (as described in issue #1095) (#1096)
dgruntz Nov 18, 2019
d4b2496
Update App.java (#1098)
dgruntz Nov 18, 2019
515b7e7
Changes the implementation of the prototype pattern (#1103)
dgruntz Nov 19, 2019
e0b728c
Package patterns into executable jars setup (#1092)
hbothra15 Nov 19, 2019
1fbe9bb
Changes the description of the template method pattern (as discussed …
dgruntz Nov 19, 2019
a9c3df7
Changes the description of the prototype pattern (#1102)
dgruntz Nov 19, 2019
05e582c
Pattern combinator (#1105)
besok Nov 26, 2019
55769e9
Update Method pattern (#1106)
Azureyjt Dec 1, 2019
0685a50
#1113 Add uml-reverse-mapper plugin
iluwatar Dec 7, 2019
b09b100
#1113 Link uml-reverse-mapper created class diagrams to readme, where…
iluwatar Dec 7, 2019
fb2c026
Java 11 migrate remaining e (#1112)
anuragagarwal561994 Dec 9, 2019
0335c61
Fix Acyclic Visitor readme layout
iluwatar Dec 13, 2019
b2b1ba9
https://github.com/iluwatar/java-design-patterns-web/issues/8 Update …
iluwatar Dec 13, 2019
5681684
https://github.com/iluwatar/java-design-patterns-web/issues/8 Fix typ…
iluwatar Dec 13, 2019
ea57934
Java 11 migrate c-d (remaining) (#1111)
anuragagarwal561994 Dec 14, 2019
7d0a5c0
Issue 989 batch-2 (#1108)
hbothra15 Dec 18, 2019
f835d3d
Java 11 migrate remaining (g,h,i) (#1116)
anuragagarwal561994 Dec 20, 2019
670c4e4
Java 11 migrate 7 remaining f (#1115)
anuragagarwal561994 Dec 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [iluwatar]
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ datanucleus.log
/bin/
/bin/
*.log
data-mapper/src/main/resources/log4j.xml
event-sourcing/Journal.json
39 changes: 18 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
language: java
dist: bionic
jdk:
- oraclejdk8
- openjdk11
sudo: required

env:
global:
- GH_REF: github.com/iluwatar/java-design-patterns.git
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
- secure: "eoWlW9GyTJY04P8K3pxayXwU9/hmptQg/LfirispQkV9YvmziCfSzXnatnBhNfud98sCzY8BScXnb+OWLTnjLKpId4rtEqb0aJ40Jc32cUKzgzFAUn7cNcDAbUIfyPAGVqyQqfj/11wYSADwWMMOPlW97ExUtoyiH2WenXuRHso="

before_install:
- export DISPLAY=:99.0
- 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
- secure: "DCpazS3nkLnter3sguXEAS2fC/1ZWNfM+XLyif9MfNFxlZdpni2vCD/jA0Rdpga8puQWHNVLyAec+RPFH/2qSmJ1c1UTV5MaLv8tPqwUX0VFA+1I6XoSv6oX4ldHTBWHEWqQHkRFOLoil0h0edc0tTOWQwXF8U+DLAB+HkRb4gw="

after_success:
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN
- bash update-ghpages.sh
services:
- xvfb

# use latest java version available instead of travis default
addons:
apt:
packages:
- oracle-java8-installer
sonarcloud:
organization: "iluwatar"
token:
secure: "FpHwMYPMkdWU6CeIB7+O3qIeIM4vJMp47UjkKK53f0w0s6tPZofZZkab+gcL2TqKSil7sFVB/AQXU1cUubflRszwcLbNsc8H2yFehD79o0o0Mqd1Dd5ip/q0KQbHkkln+InFlVLfvrLB4Xd4mlQVxbGhqpULBhXjKzFzQlRFcuU="
script:
# Because of Travis security restrictions, SonarCloud analysis cannot be run on pull requests originated from forks
# See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then mvn clean verify; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then mvn clean verify sonar:sonar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.host.url=https://sonarcloud.io; fi'

after_success:
- bash update-website.sh

notifications:
email:
Expand All @@ -35,5 +34,3 @@ notifications:
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always

sudo: required
13 changes: 0 additions & 13 deletions CODE_COVERAGE.md

This file was deleted.

22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Build status](https://travis-ci.org/iluwatar/java-design-patterns.svg?branch=master)](https://travis-ci.org/iluwatar/java-design-patterns)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=com.iluwatar%3Ajava-design-patterns&metric=alert_status)](https://sonarcloud.io/dashboard/index/com.iluwatar%3Ajava-design-patterns)
[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=alert_status)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)

# Introduction

Expand All @@ -17,14 +17,21 @@ solve common problems when designing an application or system.
Design patterns can speed up the development process by providing tested, proven
development paradigms.

Reusing design patterns help prevent subtle issues which cause major
Reusing design patterns help prevent subtle issues that cause major
problems, and it also improves code readability for coders and architects who
are familiar with the patterns.

# Getting started

This site showcases Java Design Patterns. The solutions have been developed by
experienced programmers and architects from the open source community. The
patterns can be browsed by their high level descriptions or by looking at their
source code. The source code examples are well commented and can be thought as
programming tutorials how to implement a specific pattern. We use the most
popular battle-proven open source Java technologies.

Before you dive into the material, you should be familiar with various
Programming/Software Design Principles.
software design principles.

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
Expand All @@ -35,12 +42,17 @@ Once you are familiar with these concepts you can start drilling down into
patterns by any of the following approaches

- Using difficulty tags, `Difficulty-Beginner`, `Difficulty-Intermediate` & `Difficulty-Expert`.
- Using pattern categories, `Creational`, `Behavioral` and others.
- Using pattern categories, `Creational`, `Behavioral`, and others.
- Search for a specific pattern. Can't find one? Please report a new pattern [here](https://github.com/iluwatar/java-design-patterns/issues).

Hopefully you find the object oriented solutions presented on this site useful
in your architectures and have as much fun learning them as we had developing them.

# How to contribute

If you are willing to contribute to the project you will find the relevant information in our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki). We will help you and answer your questions in the [Gitter chatroom](https://gitter.im/iluwatar/java-design-patterns).
If you are willing to contribute to the project you will find the relevant information in
our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki). We will help
you and answer your questions in the [Gitter chatroom](https://gitter.im/iluwatar/java-design-patterns).

# License

Expand Down
6 changes: 3 additions & 3 deletions abstract-document/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ folder: abstract-document
permalink: /patterns/abstract-document/
categories: Structural
tags:
- Java
- Difficulty-Intermediate
- Extensibility
---

## Intent
Achieve flexibility of untyped languages and keep the type-safety

## Class diagram
![alt text](./etc/abstract-document.png "Abstract Document Traits and Domain")


Expand All @@ -26,4 +26,4 @@ Use the Abstract Document Pattern when
## Credits

* [Wikipedia: Abstract Document Pattern](https://en.wikipedia.org/wiki/Abstract_Document_Pattern)
* [Martin Fowler: Dealing with properties](http://martinfowler.com/apsupp/properties.pdf)
* [Martin Fowler: Dealing with properties](http://martinfowler.com/apsupp/properties.pdf)
65 changes: 65 additions & 0 deletions abstract-document/etc/abstract-document.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@startuml
package com.iluwatar.abstractdocument.domain.enums {
enum Property {
+ MODEL {static}
+ PARTS {static}
+ PRICE {static}
+ TYPE {static}
+ valueOf(name : String) : Property {static}
+ values() : Property[] {static}
}
}
package com.iluwatar.abstractdocument.domain {
class Car {
+ Car(properties : Map<String, Object>)
}
interface HasModel {
+ getModel() : Optional<String>
}
interface HasParts {
+ getParts() : Stream<Part>
}
interface HasPrice {
+ getPrice() : Optional<Number>
}
interface HasType {
+ getType() : Optional<String>
}
class Part {
+ Part(properties : Map<String, Object>)
}
}
package com.iluwatar.abstractdocument {
abstract class AbstractDocument {
- properties : Map<String, Object>
# AbstractDocument(properties : Map<String, Object>)
+ children(key : String, constructor : Function<Map<String, Object>, T>) : Stream<T>
+ get(key : String) : Object
+ put(key : String, value : Object)
+ toString() : String
}
class App {
- LOGGER : Logger {static}
+ App()
+ main(args : String[]) {static}
}
interface Document {
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
+ get(String) : Object {abstract}
+ put(String, Object) {abstract}
}
}
AbstractDocument ..|> Document
Car ..|> HasModel
Car ..|> HasPrice
Car ..|> HasParts
Car --|> AbstractDocument
HasModel --|> Document
HasParts --|> Document
HasPrice --|> Document
HasType --|> Document
Part ..|> HasType
Part ..|> HasModel
Part ..|> HasPrice
Part --|> AbstractDocument
@enduml
100 changes: 54 additions & 46 deletions abstract-document/pom.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

The MIT License
Copyright (c) 2014-2016 Ilkka Seppälä

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

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

package com.iluwatar.abstractdocument;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;

/**
* Abstract implementation of Document interface
* Abstract implementation of Document interface.
*/
public abstract class AbstractDocument implements Document {

Expand All @@ -54,17 +55,21 @@ public Object get(String key) {

@Override
public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) {
Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null)
.map(el -> (List<Map<String, Object>>) el).findAny();
return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty();
return Stream.ofNullable(get(key))
.filter(Objects::nonNull)
.map(el -> (List<Map<String, Object>>) el)
.findAny()
.stream()
.flatMap(Collection::stream)
.map(constructor);
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
var builder = new StringBuilder();
builder.append(getClass().getName()).append("[");
properties.entrySet()
.forEach(e -> builder.append("[").append(e.getKey()).append(" : ").append(e.getValue()).append("]"));
properties.forEach((key, value) -> builder.append("[").append(key).append(" : ").append(value)
.append("]"));
builder.append("]");
return builder.toString();
}
Expand Down
Loading