Skip to content

Resync to remove conflicts #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a204383
init repo for role object
Oct 19, 2019
c365610
add to init
Oct 19, 2019
f09a7eb
add to init
Oct 19, 2019
20b4195
add first impl
Oct 20, 2019
630532c
add pattern
Oct 24, 2019
9403d53
add license
Oct 24, 2019
e382794
add changes
Oct 26, 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
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
09b4663
add choreogr
Nov 9, 2019
8f85353
merge changes
Nov 9, 2019
74c7273
rem space
Nov 9, 2019
de56cbb
change according to cgeckstyle
Nov 10, 2019
87af122
add changes according to google style
Nov 13, 2019
51b444d
Merge branch 'master' of https://github.com/besok/java-design-patterns
iluwatar 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
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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion abstract-document/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>abstract-document</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion abstract-factory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>abstract-factory</artifactId>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.junit.jupiter.api.Test;

/**
* Test for abstract factory
* Test for abstract factory.
*/
public class AbstractFactoryTest {

Expand Down
2 changes: 1 addition & 1 deletion acyclic-visitor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>

<artifactId>acyclic-visitor</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>adapter</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion aggregator-microservices/aggregator-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-service</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion aggregator-microservices/information-microservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion aggregator-microservices/inventory-microservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>inventory-microservice</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion aggregator-microservices/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-microservices</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ambassador/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ambassador</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion api-gateway/api-gateway-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway-service</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion api-gateway/image-microservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>image-microservice</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion api-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion api-gateway/price-microservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion async-method-invocation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>async-method-invocation</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion balking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bridge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>bridge</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>builder</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion business-delegate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>business-delegate</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion bytecode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion caching/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>caching</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion callback/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>callback</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion chain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>chain</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion circuit-breaker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: pattern
title: CircuitBreaker
title: Circuit Breaker
folder: circuit-breaker
permalink: /patterns/circuit-breaker/
categories: Other
Expand Down
2 changes: 1 addition & 1 deletion circuit-breaker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>circuit-breaker</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion collection-pipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: pattern
title: Collection Pipeline
folder: collection-pipeline
permalink: /patterns/collection-pipeline/
categories: Functional
categories: Other
tags:
- Java
- Difficulty-Beginner
Expand Down
2 changes: 1 addition & 1 deletion collection-pipeline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>collection-pipeline</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion command/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>command</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion commander/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: pattern
title: Commander
folder: commander
permalink: /patterns/commander/
categories:
categories: Other
tags:
- Java
- Difficulty-Intermediate
Expand Down
2 changes: 1 addition & 1 deletion commander/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>commander</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion composite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>composite</artifactId>
<dependencies>
Expand Down
4 changes: 4 additions & 0 deletions composite/src/main/java/com/iluwatar/composite/Word.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public Word(List<Letter> letters) {
letters.forEach(this::add);
}

/**
* Constructor.
* @param letters to include
*/
public Word(char... letters) {
for (char letter : letters) {
this.add(new Letter(letter));
Expand Down
65 changes: 65 additions & 0 deletions converter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,71 @@ mapping, reducing a boilerplate code to minimum.

![alt text](./etc/converter.png "Converter Pattern")

## Explanation

Real world example

> In real world applications it is often the case that database layer consists of entities that need to be mapped into DTOs for use on the business logic layer. Similar mapping is done for potentially huge amount of classes and we need a generic way to achieve this.

In plain words

> Converter pattern makes it easy to map instances of one class into instances of another class.

**Programmatic Example**

We need a generic solution for the mapping problem. To achieve this, let's introduce a generic converter.

```java
public class Converter<T, U> {

private final Function<T, U> fromDto;
private final Function<U, T> fromEntity;

public Converter(final Function<T, U> fromDto, final Function<U, T> fromEntity) {
this.fromDto = fromDto;
this.fromEntity = fromEntity;
}

public final U convertFromDto(final T dto) {
return fromDto.apply(dto);
}

public final T convertFromEntity(final U entity) {
return fromEntity.apply(entity);
}

public final List<U> createFromDtos(final Collection<T> dtos) {
return dtos.stream().map(this::convertFromDto).collect(Collectors.toList());
}

public final List<T> createFromEntities(final Collection<U> entities) {
return entities.stream().map(this::convertFromEntity).collect(Collectors.toList());
}
}
```

The specialized converters inherit from this base class as follows.

```java
public class UserConverter extends Converter<UserDto, User> {

public UserConverter() {
super(userDto -> new User(userDto.getFirstName(), userDto.getLastName(), userDto.isActive(),
userDto.getEmail()),
user -> new UserDto(user.getFirstName(), user.getLastName(), user.isActive(),
user.getUserId()));
}
}
```

Now mapping between User and UserDto becomes trivial.

```java
Converter<UserDto, User> userConverter = new UserConverter();
UserDto dtoUser = new UserDto("John", "Doe", true, "whatever[at]wherever.com");
User user = userConverter.convertFromDto(dtoUser);
```

## Applicability
Use the Converter Pattern in the following situations:

Expand Down
2 changes: 1 addition & 1 deletion converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion cqrs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>cqrs</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion dao/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>dao</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion data-bus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.22.0-SNAPSHOT</version>
<version>1.23.0-SNAPSHOT</version>
</parent>
<artifactId>data-bus</artifactId>
<dependencies>
Expand Down
Loading