Skip to content

Commit 3894a0b

Browse files
Merge branch 'master' of github.com:iluwatar/java-design-patterns
2 parents 49f8434 + e01d640 commit 3894a0b

25 files changed

Lines changed: 360 additions & 29 deletions

File tree

abstract-factory/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,15 @@ Use the Abstract Factory pattern when
179179

180180
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time.
181181

182+
183+
## Tutorial
184+
* [Abstract Factory Pattern Tutorial](https://www.journaldev.com/1418/abstract-factory-design-pattern-in-java)
185+
182186
## Presentations
183187

184188
* [Abstract Factory Pattern](etc/presentation.html)
185189

190+
186191
## Real world examples
187192

188193
* [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)

bridge/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ Use the Bridge pattern when
188188
* you have a proliferation of classes. Such a class hierarchy indicates the need for splitting an object into two parts. Rumbaugh uses the term "nested generalizations" to refer to such class hierarchies
189189
* you want to share an implementation among multiple objects (perhaps using reference counting), and this fact should be hidden from the client. A simple example is Coplien's String class, in which multiple objects can share the same string representation.
190190

191+
## Tutorial
192+
* [Bridge Pattern Tutorial](https://www.journaldev.com/1491/bridge-design-pattern-java)
193+
191194
## Credits
192195

193196
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

decorator/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ Use Decorator
116116
* For responsibilities that can be withdrawn
117117
* 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
118118

119+
## Tutorial
120+
* [Decorator Pattern Tutorial](https://www.journaldev.com/1540/decorator-design-pattern-in-java-example)
121+
119122
## Real world examples
120123
* [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),
121124
[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)

interpreter/src/test/java/com/iluwatar/interpreter/ExpressionTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package com.iluwatar.interpreter;
2424

2525
import org.junit.jupiter.api.Disabled;
26+
import org.junit.jupiter.api.TestInstance;
2627
import org.junit.jupiter.params.ParameterizedTest;
2728
import org.junit.jupiter.params.provider.Arguments;
2829
import org.junit.jupiter.params.provider.MethodSource;
@@ -43,6 +44,7 @@
4344
* @param <E> Type of Expression
4445
* @author Jeroen Meulemeester
4546
*/
47+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4648
public abstract class ExpressionTest<E extends Expression> {
4749

4850
/**
@@ -88,6 +90,13 @@ static Stream<Arguments> prepareParameters(final IntBinaryOperator resultCalc) {
8890
this.factory = factory;
8991
}
9092

93+
/**
94+
* Create a new set of test entries with the expected result
95+
*
96+
* @return The list of parameters used during this test
97+
*/
98+
public abstract Stream<Arguments> expressionProvider();
99+
91100
/**
92101
* Verify if the expression calculates the correct result when calling {@link E#interpret()}
93102
*/

interpreter/src/test/java/com/iluwatar/interpreter/MinusExpressionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public class MinusExpressionTest extends ExpressionTest<MinusExpression> {
3838
*
3939
* @return The list of parameters used during this test
4040
*/
41-
public static Stream<Arguments> expressionProvider() {
41+
@Override
42+
public Stream<Arguments> expressionProvider() {
4243
return prepareParameters((f, s) -> f - s);
4344
}
4445

interpreter/src/test/java/com/iluwatar/interpreter/MultiplyExpressionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public class MultiplyExpressionTest extends ExpressionTest<MultiplyExpression> {
3838
*
3939
* @return The list of parameters used during this test
4040
*/
41-
public static Stream<Arguments> expressionProvider() {
41+
@Override
42+
public Stream<Arguments> expressionProvider() {
4243
return prepareParameters((f, s) -> f * s);
4344
}
4445

interpreter/src/test/java/com/iluwatar/interpreter/NumberExpressionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public class NumberExpressionTest extends ExpressionTest<NumberExpression> {
4242
*
4343
* @return The list of parameters used during this test
4444
*/
45-
public static Stream<Arguments> expressionProvider() {
45+
@Override
46+
public Stream<Arguments> expressionProvider() {
4647
return prepareParameters((f, s) -> f);
4748
}
4849

interpreter/src/test/java/com/iluwatar/interpreter/PlusExpressionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public class PlusExpressionTest extends ExpressionTest<PlusExpression> {
3838
*
3939
* @return The list of parameters used during this test
4040
*/
41-
public static Stream<Arguments> expressionProvider() {
41+
@Override
42+
public Stream<Arguments> expressionProvider() {
4243
return prepareParameters((f, s) -> f + s);
4344
}
4445

object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public final class RoyaltyObjectMother {
2929

3030
/**
31-
* Method to create a sober and unhappy king. The standard paramters are set.
31+
* Method to create a sober and unhappy king. The standard parameters are set.
3232
* @return An instance of {@link com.iluwatar.objectmother.King} with the standard properties.
3333
*/
3434
public static King createSoberUnhappyKing() {

observer/src/test/java/com/iluwatar/observer/HobbitsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
*/
3434
public class HobbitsTest extends WeatherObserverTest<Hobbits> {
3535

36-
static Collection<Object[]> dataProvider() {
36+
@Override
37+
public Collection<Object[]> dataProvider() {
3738
final List<Object[]> testData = new ArrayList<>();
3839
testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."});
3940
testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."});

0 commit comments

Comments
 (0)