Skip to content

Commit 02f3bcd

Browse files
authored
. (#1)
* Initial commit of the object mother iluwatar#498 Add a simple king and queen classes which implement the behaviour of the royalty interface. Also wrote the object mother of royalty objects which is final so you can just call the static methods in it to create objects with a specific state to use them fast in tests. The tests are already created for testing the behaviour and the type of the objects which are created by the object mother. I also created the UML diagrams via object aid and updated the readme. * Add PlantUML file for the UML diagram iluwatar#498 * End process logic clause has been corrected. * Unused import removed. * Add SonarQube.com badge * iluwatar#502 Replaced usages of System.out with logger. * Change name of variables in test iluwatar#498 * add entry to parent pom.xml iluwatar#498 * Fix pom.xml * Fix pom.xml Deleted </modules> tag because i added it one time more than neccessary * FirstCut++ FirstCut++ * SecondCut++ SecondCut++ * App++ App++ * App App * checkstyle errors removed checkstyle errors removed * iluwatar#502 Reverted changes in composite example, due to nature of this example using logger isn't good idea * Remove use of coveralls-maven-plugin (sonarqube.com covers this) * iluwatar#502 Adjusted tests for logger introduction * iluwatar#502 Introduced logging in new example * Create presentation template * Link Hexagonal Architecture pattern to corresponding blog entry * Work on Hexagonal Architecture presentation * Add new diagram * Add presentation link to README.md * Update App.java The relationship between decorator and target (in the code example between Troll und SmartTroll) ist not a composition as described in the code comment lines of class App. It's a aggregation. In a composition both instances canncot live without the other one. But the target (Troll) could live without the decorator (Smart Troll). Changed "composition" to "aggregation" in the comment lines. Code lines are unchanged. Greetings Thomas * Review comments++ * Review comments++ * iluwatar#502 Reduced amount of information logged * Issue iluwatar#450. First commit. Queue Based Load Leveling * Issue iluwatar#450. Updated pom.xml * Updated checkstyle errors. * Updated pom.xml with maven-pmd-plugin Added dependency "maven-pmd-plugin" to the pom file. * Reverted pom.xml changes that are done previously. * Fixed PMD issue. * Decorator pattern: Improve the example * Removed unused imports in tests * Proxy pattern: Improve the example * Proxy pattern: Add missing license header * Update URM Version to 1.4.4 and regenerated all puml files * Update license headers * Fixed all the code changes after review * Review comments++ * Sonar bug fixes using Yoda condition in equals expression when comparing String literal with String object. Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources. Minimal refactor. * Sonar bug fixes using Yoda condition in equals expression when comparing String literal with String object. Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources. Minimal refactor. * Adding initialization on demand holder idiom. * Changing constant interface pattern with a Noninstantiable class * Add some material for proxy presentation. * Add presentation for Proxy pattern. * Add link to Proxy presentation. * Achieved milestone 1.14.0 * Set version for next development iteration * iluwatar#525 Add link to Queue-Based Load Leveling blog * iluwatar#525 Add link to proxy blog * Changing code to use interfaces instead of implementations. * Changing code to use interfaces instead of implementations. * Reverting initialization on demand holder idiom. * iluwatar#190 Regenerate puml files * iluwatar#190 Rename package for Queue-Based Load Leveling pattern
1 parent 19cb715 commit 02f3bcd

File tree

1,132 files changed

+8617
-5494
lines changed

Some content is hidden

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

1,132 files changed

+8617
-5494
lines changed

.gitignore

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
target
2-
.metadata
3-
.settings
4-
.classpath
5-
.project
6-
*.class
7-
# Package Files #
8-
*.jar
9-
*.war
10-
*.ear
11-
.idea
12-
*.iml
13-
*.swp
1+
target
2+
.metadata
3+
.settings
4+
.classpath
5+
.project
6+
*.class
7+
# Package Files #
8+
*.jar
9+
*.war
10+
*.ear
11+
.idea
12+
*.iml
13+
*.swp
1414
datanucleus.log
1515
/bin/
1616
/bin/
1717
/bin/
18-
19-
data-mapper/src/main/resources/log4j.xml
18+
*.log
19+
data-mapper/src/main/resources/log4j.xml

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ install:
1717
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -e
1818

1919
after_success:
20-
- mvn clean test jacoco:report coveralls:report
2120
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN
2221
- bash update-ghpages.sh
2322

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +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)
98
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
109
[![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)
1111

1212
# Introduction
1313

_scripts/postPumlsToServer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# The MIT License
3-
# Copyright (c) 2014 Ilkka Seppälä
3+
# Copyright (c) 2014-2016 Ilkka Seppälä
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
@startuml
22
package com.iluwatar.abstractdocument.domain {
3-
class Part {
4-
+ Part(properties : Map<String, Object>)
3+
class Car {
4+
+ Car(properties : Map<String, Object>)
55
}
6-
interface HasPrice {
6+
interface HasModel {
77
+ PROPERTY : String {static}
8-
+ getPrice() : Optional<Number>
8+
+ getModel() : Optional<String>
99
}
1010
interface HasParts {
1111
+ PROPERTY : String {static}
1212
+ getParts() : Stream<Part>
1313
}
14-
class Car {
15-
+ Car(properties : Map<String, Object>)
14+
interface HasPrice {
15+
+ PROPERTY : String {static}
16+
+ getPrice() : Optional<Number>
1617
}
1718
interface HasType {
1819
+ PROPERTY : String {static}
1920
+ getType() : Optional<String>
2021
}
21-
interface HasModel {
22-
+ PROPERTY : String {static}
23-
+ getModel() : Optional<String>
22+
class Part {
23+
+ Part(properties : Map<String, Object>)
2424
}
2525
}
2626
package com.iluwatar.abstractdocument {
27-
class App {
28-
+ App()
29-
+ main(args : String[]) {static}
30-
}
3127
abstract class AbstractDocument {
3228
- properties : Map<String, Object>
3329
# AbstractDocument(properties : Map<String, Object>)
@@ -36,24 +32,28 @@ package com.iluwatar.abstractdocument {
3632
+ put(key : String, value : Object)
3733
+ toString() : String
3834
}
35+
class App {
36+
- LOGGER : Logger {static}
37+
+ App()
38+
+ main(args : String[]) {static}
39+
}
3940
interface Document {
4041
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
4142
+ get(String) : Object {abstract}
4243
+ put(String, Object) {abstract}
4344
}
4445
}
45-
AbstractDocument --+ Map
46-
Part ..|> HasType
47-
Part ..|> HasModel
48-
Part ..|> HasPrice
49-
Part --|> AbstractDocument
5046
AbstractDocument ..|> Document
51-
HasPrice --|> Document
52-
HasParts --|> Document
5347
Car ..|> HasModel
5448
Car ..|> HasPrice
5549
Car ..|> HasParts
5650
Car --|> AbstractDocument
57-
HasType --|> Document
5851
HasModel --|> Document
52+
HasParts --|> Document
53+
HasPrice --|> Document
54+
HasType --|> Document
55+
Part ..|> HasType
56+
Part ..|> HasModel
57+
Part ..|> HasPrice
58+
Part --|> AbstractDocument
5959
@enduml

abstract-document/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
44
The MIT License
5-
Copyright (c) 2014 Ilkka Seppälä
5+
Copyright (c) 2014-2016 Ilkka Seppälä
66
77
Permission is hereby granted, free of charge, to any person obtaining a copy
88
of this software and associated documentation files (the "Software"), to deal
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>java-design-patterns</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.14.0-SNAPSHOT</version>
32+
<version>1.15.0-SNAPSHOT</version>
3333
</parent>
3434
<artifactId>abstract-document</artifactId>
3535
<dependencies>

abstract-document/src/main/java/com/iluwatar/abstractdocument/AbstractDocument.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/main/java/com/iluwatar/abstractdocument/App.java

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal
@@ -27,6 +27,8 @@
2727
import com.iluwatar.abstractdocument.domain.HasParts;
2828
import com.iluwatar.abstractdocument.domain.HasPrice;
2929
import com.iluwatar.abstractdocument.domain.HasType;
30+
import org.slf4j.Logger;
31+
import org.slf4j.LoggerFactory;
3032

3133
import java.util.Arrays;
3234
import java.util.HashMap;
@@ -44,11 +46,13 @@
4446
*/
4547
public class App {
4648

49+
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
50+
4751
/**
4852
* Executes the App
4953
*/
5054
public App() {
51-
System.out.println("Constructing parts and car");
55+
LOGGER.info("Constructing parts and car");
5256

5357
Map<String, Object> carProperties = new HashMap<>();
5458
carProperties.put(HasModel.PROPERTY, "300SL");
@@ -68,12 +72,11 @@ public App() {
6872

6973
Car car = new Car(carProperties);
7074

71-
System.out.println("Here is our car:");
72-
System.out.println("-> model: " + car.getModel().get());
73-
System.out.println("-> price: " + car.getPrice().get());
74-
System.out.println("-> parts: ");
75-
car.getParts().forEach(p -> System.out
76-
.println("\t" + p.getType().get() + "/" + p.getModel().get() + "/" + p.getPrice().get()));
75+
LOGGER.info("Here is our car:");
76+
LOGGER.info("-> model: {}", car.getModel().get());
77+
LOGGER.info("-> price: {}", car.getPrice().get());
78+
LOGGER.info("-> parts: ");
79+
car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get()));
7780
}
7881

7982
/**

abstract-document/src/main/java/com/iluwatar/abstractdocument/Document.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Car.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasModel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasParts.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasPrice.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Part.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/test/java/com/iluwatar/abstractdocument/AbstractDocumentTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/test/java/com/iluwatar/abstractdocument/AppTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

abstract-document/src/test/java/com/iluwatar/abstractdocument/DomainTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* The MIT License
3-
* Copyright (c) 2014 Ilkka Seppälä
3+
* Copyright (c) 2014-2016 Ilkka Seppälä
44
* <p>
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)