Skip to content

Commit 5e3c951

Browse files
committed
synced with remote branch
2 parents 24b87bb + 203548e commit 5e3c951

File tree

2,038 files changed

+20254
-17975
lines changed

Some content is hidden

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

2,038 files changed

+20254
-17975
lines changed

Diff for: .all-contributorsrc

+73
Original file line numberDiff line numberDiff line change
@@ -3420,6 +3420,79 @@
34203420
"contributions": [
34213421
"code"
34223422
]
3423+
},
3424+
{
3425+
"login": "smile-ab",
3426+
"name": "smile-ab",
3427+
"avatar_url": "https://avatars.githubusercontent.com/u/202159894?v=4",
3428+
"profile": "https://github.com/smile-ab",
3429+
"contributions": [
3430+
"translation",
3431+
"code"
3432+
]
3433+
},
3434+
{
3435+
"login": "Francisco-G-P",
3436+
"name": "Francisco-G-P",
3437+
"avatar_url": "https://avatars.githubusercontent.com/u/186766789?v=4",
3438+
"profile": "https://github.com/Francisco-G-P",
3439+
"contributions": [
3440+
"translation"
3441+
]
3442+
},
3443+
{
3444+
"login": "Duartegdm",
3445+
"name": "Gabriel Duarte",
3446+
"avatar_url": "https://avatars.githubusercontent.com/u/137895372?v=4",
3447+
"profile": "https://github.com/Duartegdm",
3448+
"contributions": [
3449+
"doc"
3450+
]
3451+
},
3452+
{
3453+
"login": "DenizAltunkapan",
3454+
"name": "Deniz Altunkapan",
3455+
"avatar_url": "https://avatars.githubusercontent.com/u/93663085?v=4",
3456+
"profile": "https://github.com/DenizAltunkapan",
3457+
"contributions": [
3458+
"translation"
3459+
]
3460+
},
3461+
{
3462+
"login": "johnklint81",
3463+
"name": "John Klint",
3464+
"avatar_url": "https://avatars.githubusercontent.com/u/70539458?v=4",
3465+
"profile": "https://github.com/johnklint81",
3466+
"contributions": [
3467+
"code"
3468+
]
3469+
},
3470+
{
3471+
"login": "sanurah",
3472+
"name": "Sanura Hettiarachchi",
3473+
"avatar_url": "https://avatars.githubusercontent.com/u/16178588?v=4",
3474+
"profile": "https://github.com/sanurah",
3475+
"contributions": [
3476+
"code"
3477+
]
3478+
},
3479+
{
3480+
"login": "2897robo",
3481+
"name": "Kim Gi Uk",
3482+
"avatar_url": "https://avatars.githubusercontent.com/u/31699375?v=4",
3483+
"profile": "https://github.com/2897robo",
3484+
"contributions": [
3485+
"code"
3486+
]
3487+
},
3488+
{
3489+
"login": "Suchismita-Deb",
3490+
"name": "Suchismita Deb",
3491+
"avatar_url": "https://avatars.githubusercontent.com/u/68535074?v=4",
3492+
"profile": "https://github.com/Suchismita-Deb",
3493+
"contributions": [
3494+
"code"
3495+
]
34233496
}
34243497
],
34253498
"contributorsPerLine": 6,

Diff for: .github/workflows/maven-ci.yml

+41-70
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
#
2-
# The MIT License
3-
# Copyright © 2014-2021 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-
# This workflow will build a Java project with Maven
25-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
26-
27-
# We are using two jobs here for testing our code on the latest JDK 11 build as well as a more satble build version of 11.0.3
28-
# You can see the full discussion here https://github.com/iluwatar/java-design-patterns/pull/1868#issue-1029459688
29-
301
name: Java CI
312

323
on:
@@ -37,46 +8,46 @@ jobs:
378

389
build-and-analyze:
3910

40-
name: Build and Run Sonar analysis on JDK 17
41-
runs-on: ubuntu-20.04
11+
name: Build and Run Sonar analysis on JDK 21
12+
runs-on: ubuntu-22.04
4213
steps:
4314

44-
- name: Checkout Code
45-
uses: actions/checkout@v4
46-
with:
47-
# Disabling shallow clone for improving relevancy of SonarQube reporting
48-
fetch-depth: 0
49-
50-
- name: Set up JDK 17
51-
uses: actions/setup-java@v4
52-
with:
53-
java-version: '17'
54-
distribution: 'temurin'
55-
cache: 'maven'
56-
57-
- name: Cache local Maven repository
58-
uses: actions/cache@v4
59-
with:
60-
path: ~/.m2/repository
61-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
62-
restore-keys: |
63-
${{ runner.os }}-maven-
64-
65-
# Cache Sonar packages which as used to run analysis and collect metrics
66-
- name: Cache SonarCloud packages
67-
uses: actions/cache@v4
68-
with:
69-
path: ~/.sonar/cache
70-
key: ${{ runner.os }}-sonar
71-
restore-keys: ${{ runner.os }}-sonar
72-
73-
# Some tests need screen access
74-
- name: Install xvfb
75-
run: sudo apt-get install -y xvfb
76-
77-
- name: Build with Maven and run SonarQube analysis
78-
run: xvfb-run ./mvnw clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
79-
env:
80-
# These two env variables are needed for sonar analysis
81-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
with:
18+
# Disabling shallow clone for improving relevancy of SonarQube reporting
19+
fetch-depth: 0
20+
21+
- name: Set up JDK 21
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: '21'
25+
distribution: 'temurin'
26+
cache: 'maven'
27+
28+
- name: Cache local Maven repository
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.m2/repository
32+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
33+
restore-keys: |
34+
${{ runner.os }}-maven-
35+
36+
# Cache Sonar packages which are used to run analysis and collect metrics
37+
- name: Cache SonarCloud packages
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.sonar/cache
41+
key: ${{ runner.os }}-sonar
42+
restore-keys: ${{ runner.os }}-sonar
43+
44+
# Some tests need screen access
45+
- name: Install xvfb
46+
run: sudo apt-get install -y xvfb
47+
48+
- name: Build with Maven and run SonarQube analysis
49+
run: xvfb-run ./mvnw clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
50+
env:
51+
# These two env variables are needed for sonar analysis
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Diff for: .github/workflows/maven-pr-builder.yml

+42-68
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
#
2-
# The MIT License
3-
# Copyright © 2014-2021 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-
# This workflow will build a Java project with Maven
25-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
26-
271
name: Java PR Builder
282

293
on:
@@ -37,47 +11,47 @@ permissions:
3711
jobs:
3812
build-and-analyze:
3913

40-
name: Build on JDK 17
41-
runs-on: ubuntu-20.04
14+
name: Build on JDK 21
15+
runs-on: ubuntu-22.04
4216
steps:
43-
44-
- name: Checkout Code
45-
uses: actions/checkout@v4
46-
with:
47-
ref: ${{ github.event.pull_request.head.sha }}
48-
49-
- name: Set up JDK 17
50-
uses: actions/setup-java@v4
51-
with:
52-
java-version: '17'
53-
distribution: 'temurin'
54-
cache: 'maven'
55-
56-
- name: Cache local Maven repository
57-
uses: actions/cache@v4
58-
with:
59-
path: ~/.m2/repository
60-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
61-
restore-keys: |
62-
${{ runner.os }}-maven-
63-
64-
# Cache Sonar packages which as used to run analysis and collect metrics
65-
- name: Cache SonarCloud packages
66-
uses: actions/cache@v4
67-
with:
68-
path: ~/.sonar/cache
69-
key: ${{ runner.os }}-sonar
70-
restore-keys: ${{ runner.os }}-sonar
71-
72-
# Some tests need screen access
73-
- name: Install xvfb
74-
run: sudo apt-get install -y xvfb
7517

76-
- name: Build with Maven and run SonarQube analysis
77-
env:
78-
# Intermediate variable
79-
HEAD_REF: ${{ github.head_ref }}
80-
# These two env variables are needed for sonar analysis
81-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
83-
run: xvfb-run ./mvnw clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=iluwatar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.base=${{ github.base_ref }} -Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
18+
- name: Checkout Code
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.event.pull_request.head.sha }}
22+
23+
- name: Set up JDK 21
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
cache: 'maven'
29+
30+
- name: Cache local Maven repository
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.m2/repository
34+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
35+
restore-keys: |
36+
${{ runner.os }}-maven-
37+
38+
# Cache Sonar packages which are used to run analysis and collect metrics
39+
- name: Cache SonarCloud packages
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.sonar/cache
43+
key: ${{ runner.os }}-sonar
44+
restore-keys: ${{ runner.os }}-sonar
45+
46+
# Some tests need screen access
47+
- name: Install xvfb
48+
run: sudo apt-get install -y xvfb
49+
50+
- name: Build with Maven and run SonarQube analysis
51+
env:
52+
# Intermediate variable
53+
HEAD_REF: ${{ github.head_ref }}
54+
# These two env variables are needed for sonar analysis
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
57+
run: xvfb-run ./mvnw clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=iluwatar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.base=${{ github.base_ref }} -Dsonar.pullrequest.key=${{ github.event.pull_request.number }}

Diff for: README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
77
[![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)
88
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
9-
[![All Contributors](https://img.shields.io/badge/all_contributors-375-orange.svg?style=flat-square)](#contributors-)
9+
[![All Contributors](https://img.shields.io/badge/all_contributors-383-orange.svg?style=flat-square)](#contributors-)
1010
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1111

1212
<br/>
@@ -560,6 +560,16 @@ This project is licensed under the terms of the MIT license.
560560
<td align="center" valign="top" width="16.66%"><a href="https://github.com/MohanedAtef238"><img src="https://avatars.githubusercontent.com/u/105852138?v=4?s=100" width="100px;" alt="Mohaned Atef"/><br /><sub><b>Mohaned Atef</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=MohanedAtef238" title="Code">💻</a></td>
561561
<td align="center" valign="top" width="16.66%"><a href="https://github.com/maximevtush"><img src="https://avatars.githubusercontent.com/u/154841002?v=4?s=100" width="100px;" alt="Maxim Evtush"/><br /><sub><b>Maxim Evtush</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=maximevtush" title="Code">💻</a></td>
562562
<td align="center" valign="top" width="16.66%"><a href="https://github.com/hvgh88"><img src="https://avatars.githubusercontent.com/u/65297242?v=4?s=100" width="100px;" alt="Harshita Vidapanakal"/><br /><sub><b>Harshita Vidapanakal</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=hvgh88" title="Code">💻</a></td>
563+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/smile-ab"><img src="https://avatars.githubusercontent.com/u/202159894?v=4?s=100" width="100px;" alt="smile-ab"/><br /><sub><b>smile-ab</b></sub></a><br /><a href="#translation-smile-ab" title="Translation">🌍</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=smile-ab" title="Code">💻</a></td>
564+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Francisco-G-P"><img src="https://avatars.githubusercontent.com/u/186766789?v=4?s=100" width="100px;" alt="Francisco-G-P"/><br /><sub><b>Francisco-G-P</b></sub></a><br /><a href="#translation-Francisco-G-P" title="Translation">🌍</a></td>
565+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Duartegdm"><img src="https://avatars.githubusercontent.com/u/137895372?v=4?s=100" width="100px;" alt="Gabriel Duarte"/><br /><sub><b>Gabriel Duarte</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Duartegdm" title="Documentation">📖</a></td>
566+
</tr>
567+
<tr>
568+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/DenizAltunkapan"><img src="https://avatars.githubusercontent.com/u/93663085?v=4?s=100" width="100px;" alt="Deniz Altunkapan"/><br /><sub><b>Deniz Altunkapan</b></sub></a><br /><a href="#translation-DenizAltunkapan" title="Translation">🌍</a></td>
569+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/johnklint81"><img src="https://avatars.githubusercontent.com/u/70539458?v=4?s=100" width="100px;" alt="John Klint"/><br /><sub><b>John Klint</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=johnklint81" title="Code">💻</a></td>
570+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/sanurah"><img src="https://avatars.githubusercontent.com/u/16178588?v=4?s=100" width="100px;" alt="Sanura Hettiarachchi"/><br /><sub><b>Sanura Hettiarachchi</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=sanurah" title="Code">💻</a></td>
571+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/2897robo"><img src="https://avatars.githubusercontent.com/u/31699375?v=4?s=100" width="100px;" alt="Kim Gi Uk"/><br /><sub><b>Kim Gi Uk</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=2897robo" title="Code">💻</a></td>
572+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Suchismita-Deb"><img src="https://avatars.githubusercontent.com/u/68535074?v=4?s=100" width="100px;" alt="Suchismita Deb"/><br /><sub><b>Suchismita Deb</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Suchismita-Deb" title="Code">💻</a></td>
563573
</tr>
564574
</tbody>
565575
</table>

Diff for: abstract-document/README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Wikipedia says
3333

3434
> An object-oriented structural design pattern for organizing objects in loosely typed key-value stores and exposing the data using typed views. The purpose of the pattern is to achieve a high degree of flexibility between components in a strongly typed language where new properties can be added to the object-tree on the fly, without losing the support of type-safety. The pattern makes use of traits to separate different properties of a class into different interfaces.
3535
36+
Class diagram
37+
38+
![Abstract Document class diagram](./etc/abstract-document.png "Abstract Document class diagram")
39+
40+
3641
## Programmatic Example of Abstract Document Pattern in Java
3742

3843
Consider a car that consists of multiple parts. However, we don't know if the specific car really has all the parts, or just some of them. Our cars are dynamic and extremely flexible.
@@ -119,6 +124,13 @@ public interface HasParts extends Document {
119124
return children(Property.PARTS.toString(), Part::new);
120125
}
121126
}
127+
128+
public class Part extends AbstractDocument implements HasType, HasModel, HasPrice {
129+
130+
public Part(Map<String, Object> properties) {
131+
super(properties);
132+
}
133+
}
122134
```
123135

124136
Now we are ready to introduce the `Car`.
@@ -179,10 +191,6 @@ The program output:
179191
07:21:57.395 [main] INFO com.iluwatar.abstractdocument.App -- door/Lambo/300
180192
```
181193
182-
## Abstract Document Pattern Class Diagram
183-
184-
![Abstract Document](./etc/abstract-document.png "Abstract Document Traits and Domain")
185-
186194
## When to Use the Abstract Document Pattern in Java
187195
188196
The Abstract Document design pattern is especially beneficial in scenarios requiring management of different document types in Java that share some common attributes or behaviors, but also have unique attributes or behaviors specific to their individual types. Here are some scenarios where the Abstract Document design pattern can be applicable:

0 commit comments

Comments
 (0)