Skip to content

Commit f2de89d

Browse files
authored
Merge pull request #1 from iluwatar/master
update
2 parents 886ad7e + 124fd33 commit f2de89d

454 files changed

Lines changed: 17962 additions & 656 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ target
1111
.idea
1212
*.iml
1313
*.swp
14-
datanucleus.log
14+
datanucleus.log
15+
/bin/
16+
/bin/
17+
/bin/
18+
19+
data-mapper/src/main/resources/log4j.xml

.travis.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,34 @@ env:
66
global:
77
- GH_REF: github.com/iluwatar/java-design-patterns.git
88
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
9+
- secure: "eoWlW9GyTJY04P8K3pxayXwU9/hmptQg/LfirispQkV9YvmziCfSzXnatnBhNfud98sCzY8BScXnb+OWLTnjLKpId4rtEqb0aJ40Jc32cUKzgzFAUn7cNcDAbUIfyPAGVqyQqfj/11wYSADwWMMOPlW97ExUtoyiH2WenXuRHso="
910

1011
before_install:
1112
- export DISPLAY=:99.0
1213
- sh -e /etc/init.d/xvfb start
1314

15+
# default install command is just "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V"
16+
install:
17+
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -e
18+
1419
after_success:
15-
- mvn clean test jacoco:report coveralls:report
20+
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN
1621
- bash update-ghpages.sh
1722

23+
# use latest java version available instead of travis default
24+
addons:
25+
apt:
26+
packages:
27+
- oracle-java8-installer
28+
29+
notifications:
30+
email:
31+
- iluwatar@gmail.com
32+
webhooks:
33+
urls:
34+
- https://webhooks.gitter.im/e/3319623945358a093a6f
35+
on_success: change # options: [always|never|change] default: always
36+
on_failure: always # options: [always|never|change] default: always
37+
on_start: never # options: [always|never|change] default: always
38+
1839
sudo: false # route the build to the container-based infrastructure for a faster build

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
# Design patterns implemented in Java
66

77
[![Build status](https://travis-ci.org/iluwatar/java-design-patterns.svg?branch=master)](https://travis-ci.org/iluwatar/java-design-patterns)
8-
[![Coverage Status](https://coveralls.io/repos/iluwatar/java-design-patterns/badge.svg?branch=master)](https://coveralls.io/r/iluwatar/java-design-patterns?branch=master)
8+
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
99
[![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)
10+
[![Quality Gate](https://sonarqube.com/api/badges/gate?key=com.iluwatar%3Ajava-design-patterns)](https://sonarqube.com/dashboard/index/com.iluwatar%3Ajava-design-patterns)
1011

1112
# Introduction
1213

@@ -23,7 +24,7 @@ are familiar with the patterns.
2324
# Getting started
2425

2526
Before you dive into the material, you should be familiar with various
26-
[Programming/Software Design Principles](http://webpro.github.io/programming-principles/).
27+
Programming/Software Design Principles.
2728

2829
All designs should be as simple as possible. You should start with KISS, YAGNI,
2930
and Do The Simplest Thing That Could Possibly Work principles. Complexity and

_scripts/postPumlsToServer.firstrun.output

Lines changed: 190 additions & 0 deletions
Large diffs are not rendered by default.

_scripts/postPumlsToServer.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#
2+
# The MIT License
3+
# Copyright (c) 2014 Ilkka Seppälä
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
#
23+
24+
import requests, glob, re, os
25+
26+
# taken from here: http://stackoverflow.com/a/13641746
27+
def replace(file, pattern, subst):
28+
# Read contents from file as a single string
29+
file_handle = open(file, 'r')
30+
file_string = file_handle.read()
31+
file_handle.close()
32+
33+
# Use RE package to allow for replacement (also allowing for (multiline) REGEX)
34+
file_string = (re.sub(pattern, subst, file_string))
35+
36+
# Write contents to file.
37+
# Using mode 'w' truncates the file.
38+
file_handle = open(file, 'w')
39+
file_handle.write(file_string)
40+
file_handle.close()
41+
42+
# list of all puml files
43+
fileList = glob.glob('*/etc/*.puml')
44+
for puml in fileList:
45+
pathSplit = puml.split("/")
46+
# parent folder
47+
parent = pathSplit[0]
48+
# individual artifact/project name
49+
artifact = pathSplit[2].replace(".urm.puml", "")
50+
print "parent: " + parent + "; artifact: " + artifact
51+
52+
# do a POST to the official plantuml hosting site with a little trick "!includeurl" and raw github content
53+
data = {
54+
'text': "!includeurl https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/" + puml
55+
}
56+
r = requests.post('http://plantuml.com/plantuml/uml', data=data)
57+
pumlId = r.url.replace("http://plantuml.com/plantuml/uml/", "")
58+
59+
# the only thing needed to get a png/svg/ascii from the server back
60+
print "Puml Server ID: " + pumlId
61+
62+
# add the id so jekyll/liquid can use it
63+
if (parent == artifact):
64+
replace("./" + parent + "/README.md", "categories:", "pumlid: {}\\ncategories:".format(pumlId))
65+
else:
66+
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)
67+

abstract-document/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
layout: pattern
3+
title: Abstract Document
4+
folder: abstract-document
5+
permalink: /patterns/abstract-document/
6+
pumlid: PSjB3eCm34NHhPG599vtDyQn85L-ifzX-p3lxEf8Twj3MXGDQvyJMFubChxpKN767gucSq07iinEjSNDOACVNvoAUZr6MWoe3QVE_WRnxZ0Mf38b-hkIGlurX_MyehS7
7+
categories: Structural
8+
tags:
9+
- Java
10+
- Difficulty-Intermediate
11+
---
12+
13+
## Intent
14+
Achieve flexibility of untyped languages and keep the type-safety
15+
16+
![alt text](./etc/abstract-document-base.png "Abstract Document Base")
17+
18+
![alt text](./etc/abstract-document.png "Abstract Document Traits and Domain")
19+
20+
21+
## Applicability
22+
Use the Abstract Document Pattern when
23+
24+
* there is a need to add new properties on the fly
25+
* you want a flexible way to organize domain in tree like structure
26+
* you want more loosely coupled system
27+
28+
29+
## Credits
30+
31+
* [Wikipedia: Abstract Document Pattern](https://en.wikipedia.org/wiki/Abstract_Document_Pattern)
32+
* [Martin Fowler: Dealing with properties](http://martinfowler.com/apsupp/properties.pdf)
14.6 KB
Loading
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.1.9" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3+
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
4+
<interface id="1" language="java" name="com.iluwatar.abstractdocument.Document" project="design-patterns"
5+
file="/design-patterns/src/com/iluwatar/abstractdocument/Document.java" binary="false" corner="BOTTOM_RIGHT">
6+
<position height="-1" width="-1" x="249" y="405"/>
7+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
8+
sort-features="false" accessors="true" visibility="true">
9+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
10+
<operations public="true" package="true" protected="true" private="true" static="true"/>
11+
</display>
12+
</interface>
13+
<class id="2" language="java" name="com.iluwatar.abstractdocument.AbstractDocument" project="design-patterns"
14+
file="/design-patterns/src/com/iluwatar/abstractdocument/AbstractDocument.java" binary="false" corner="BOTTOM_RIGHT">
15+
<position height="-1" width="-1" x="250" y="237"/>
16+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
17+
sort-features="false" accessors="true" visibility="true">
18+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
19+
<operations public="true" package="true" protected="true" private="true" static="true"/>
20+
</display>
21+
</class>
22+
<class id="3" language="java" name="com.iluwatar.abstractdocument.domain.Car" project="design-patterns"
23+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Car.java" binary="false" corner="BOTTOM_RIGHT">
24+
<position height="-1" width="-1" x="108" y="75"/>
25+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
26+
sort-features="false" accessors="true" visibility="true">
27+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
28+
<operations public="true" package="true" protected="true" private="true" static="true"/>
29+
</display>
30+
</class>
31+
<class id="4" language="java" name="com.iluwatar.abstractdocument.domain.Part" project="design-patterns"
32+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Part.java" binary="false" corner="BOTTOM_RIGHT">
33+
<position height="-1" width="-1" x="400" y="76"/>
34+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
35+
sort-features="false" accessors="true" visibility="true">
36+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
37+
<operations public="true" package="true" protected="true" private="true" static="true"/>
38+
</display>
39+
</class>
40+
<generalization id="5">
41+
<end type="SOURCE" refId="4"/>
42+
<end type="TARGET" refId="2"/>
43+
</generalization>
44+
<realization id="6">
45+
<end type="SOURCE" refId="2"/>
46+
<end type="TARGET" refId="1"/>
47+
</realization>
48+
<generalization id="7">
49+
<end type="SOURCE" refId="3"/>
50+
<end type="TARGET" refId="2"/>
51+
</generalization>
52+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
53+
sort-features="false" accessors="true" visibility="true">
54+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
55+
<operations public="true" package="true" protected="true" private="true" static="true"/>
56+
</classifier-display>
57+
<association-display labels="true" multiplicity="true"/>
58+
</class-diagram>
16.3 KB
Loading
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.1.9" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3+
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
4+
<interface id="1" language="java" name="com.iluwatar.abstractdocument.Document" project="design-patterns"
5+
file="/design-patterns/src/com/iluwatar/abstractdocument/Document.java" binary="false" corner="BOTTOM_RIGHT">
6+
<position height="-1" width="-1" x="341" y="376"/>
7+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
8+
sort-features="false" accessors="true" visibility="true">
9+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
10+
<operations public="true" package="true" protected="true" private="true" static="true"/>
11+
</display>
12+
</interface>
13+
<interface id="2" language="java" name="com.iluwatar.abstractdocument.domain.HasModel" project="design-patterns"
14+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasModel.java" binary="false" corner="BOTTOM_RIGHT">
15+
<position height="81" width="173" x="41" y="194"/>
16+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
17+
sort-features="false" accessors="true" visibility="true">
18+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
19+
<operations public="true" package="true" protected="true" private="true" static="true"/>
20+
</display>
21+
</interface>
22+
<interface id="3" language="java" name="com.iluwatar.abstractdocument.domain.HasPrice" project="design-patterns"
23+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasPrice.java" binary="false" corner="BOTTOM_RIGHT">
24+
<position height="81" width="175" x="254" y="194"/>
25+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
26+
sort-features="false" accessors="true" visibility="true">
27+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
28+
<operations public="true" package="true" protected="true" private="true" static="true"/>
29+
</display>
30+
</interface>
31+
<interface id="4" language="java" name="com.iluwatar.abstractdocument.domain.HasParts" project="design-patterns"
32+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasParts.java" binary="false" corner="BOTTOM_RIGHT">
33+
<position height="81" width="173" x="469" y="194"/>
34+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
35+
sort-features="false" accessors="true" visibility="true">
36+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
37+
<operations public="true" package="true" protected="true" private="true" static="true"/>
38+
</display>
39+
</interface>
40+
<class id="5" language="java" name="com.iluwatar.abstractdocument.domain.Car" project="design-patterns"
41+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Car.java" binary="false" corner="BOTTOM_RIGHT">
42+
<position height="99" width="173" x="254" y="37"/>
43+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
44+
sort-features="false" accessors="true" visibility="true">
45+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
46+
<operations public="true" package="true" protected="true" private="true" static="true"/>
47+
</display>
48+
</class>
49+
<class id="6" language="java" name="com.iluwatar.abstractdocument.domain.Part" project="design-patterns"
50+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Part.java" binary="false" corner="BOTTOM_RIGHT">
51+
<position height="99" width="173" x="41" y="37"/>
52+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
53+
sort-features="false" accessors="true" visibility="true">
54+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
55+
<operations public="true" package="true" protected="true" private="true" static="true"/>
56+
</display>
57+
</class>
58+
<realization id="7">
59+
<end type="SOURCE" refId="5"/>
60+
<end type="TARGET" refId="2"/>
61+
</realization>
62+
<realization id="8">
63+
<end type="SOURCE" refId="6"/>
64+
<end type="TARGET" refId="2"/>
65+
</realization>
66+
<generalization id="9">
67+
<end type="SOURCE" refId="2"/>
68+
<end type="TARGET" refId="1"/>
69+
</generalization>
70+
<realization id="10">
71+
<end type="SOURCE" refId="5"/>
72+
<end type="TARGET" refId="3"/>
73+
</realization>
74+
<realization id="11">
75+
<end type="SOURCE" refId="5"/>
76+
<end type="TARGET" refId="4"/>
77+
</realization>
78+
<generalization id="12">
79+
<end type="SOURCE" refId="3"/>
80+
<end type="TARGET" refId="1"/>
81+
</generalization>
82+
<generalization id="13">
83+
<end type="SOURCE" refId="4"/>
84+
<end type="TARGET" refId="1"/>
85+
</generalization>
86+
<realization id="14">
87+
<end type="SOURCE" refId="6"/>
88+
<end type="TARGET" refId="3"/>
89+
</realization>
90+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
91+
sort-features="false" accessors="true" visibility="true">
92+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
93+
<operations public="true" package="true" protected="true" private="true" static="true"/>
94+
</classifier-display>
95+
<association-display labels="true" multiplicity="true"/>
96+
</class-diagram>

0 commit comments

Comments
 (0)