Skip to content

Commit 2963418

Browse files
authored
Merge pull request #3 from iluwatar/master
Sync from master
2 parents 969a2c7 + 50986fa commit 2963418

File tree

210 files changed

+2090
-2252
lines changed

Some content is hidden

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

210 files changed

+2090
-2252
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [iluwatar]

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ sudo: required
66

77
env:
88
global:
9-
- GH_REF: github.com/iluwatar/java-design-patterns.git
10-
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
9+
- secure: "DCpazS3nkLnter3sguXEAS2fC/1ZWNfM+XLyif9MfNFxlZdpni2vCD/jA0Rdpga8puQWHNVLyAec+RPFH/2qSmJ1c1UTV5MaLv8tPqwUX0VFA+1I6XoSv6oX4ldHTBWHEWqQHkRFOLoil0h0edc0tTOWQwXF8U+DLAB+HkRb4gw="
1110

1211
services:
1312
- xvfb
@@ -24,7 +23,7 @@ script:
2423
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then mvn clean verify sonar:sonar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.host.url=https://sonarcloud.io; fi'
2524

2625
after_success:
27-
- bash update-ghpages.sh
26+
- bash update-website.sh
2827

2928
notifications:
3029
email:

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323

2424
package com.iluwatar.abstractdocument;
2525

26-
import java.util.Arrays;
27-
import java.util.HashMap;
28-
26+
import com.iluwatar.abstractdocument.domain.Car;
27+
import com.iluwatar.abstractdocument.domain.enums.Property;
2928
import org.slf4j.Logger;
3029
import org.slf4j.LoggerFactory;
3130

32-
import com.iluwatar.abstractdocument.domain.Car;
33-
import com.iluwatar.abstractdocument.domain.enums.Property;
31+
import java.util.List;
32+
import java.util.Map;
3433

3534
/**
3635
* The Abstract Document pattern enables handling additional, non-static
@@ -52,21 +51,20 @@ public class App {
5251
public App() {
5352
LOGGER.info("Constructing parts and car");
5453

55-
var carProperties = new HashMap<String, Object>();
56-
carProperties.put(Property.MODEL.toString(), "300SL");
57-
carProperties.put(Property.PRICE.toString(), 10000L);
58-
59-
var wheelProperties = new HashMap<String, Object>();
60-
wheelProperties.put(Property.TYPE.toString(), "wheel");
61-
wheelProperties.put(Property.MODEL.toString(), "15C");
62-
wheelProperties.put(Property.PRICE.toString(), 100L);
54+
var wheelProperties = Map.of(
55+
Property.TYPE.toString(), "wheel",
56+
Property.MODEL.toString(), "15C",
57+
Property.PRICE.toString(), 100L);
6358

64-
var doorProperties = new HashMap<String, Object>();
65-
doorProperties.put(Property.TYPE.toString(), "door");
66-
doorProperties.put(Property.MODEL.toString(), "Lambo");
67-
doorProperties.put(Property.PRICE.toString(), 300L);
59+
var doorProperties = Map.of(
60+
Property.TYPE.toString(), "door",
61+
Property.MODEL.toString(), "Lambo",
62+
Property.PRICE.toString(), 300L);
6863

69-
carProperties.put(Property.PARTS.toString(), Arrays.asList(wheelProperties, doorProperties));
64+
var carProperties = Map.of(
65+
Property.MODEL.toString(), "300SL",
66+
Property.PRICE.toString(), 10000L,
67+
Property.PARTS.toString(), List.of(wheelProperties, doorProperties));
7068

7169
var car = new Car(carProperties);
7270

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@
2525

2626
import org.junit.jupiter.api.Test;
2727

28-
import java.util.Arrays;
2928
import java.util.HashMap;
3029
import java.util.List;
3130
import java.util.Map;
3231
import java.util.stream.Stream;
3332

34-
import static org.junit.jupiter.api.Assertions.assertEquals;
35-
import static org.junit.jupiter.api.Assertions.assertNotNull;
36-
import static org.junit.jupiter.api.Assertions.assertTrue;
33+
import static org.junit.jupiter.api.Assertions.*;
3734

3835
/**
3936
* AbstractDocument test class
@@ -60,9 +57,7 @@ public void shouldPutAndGetValue() {
6057

6158
@Test
6259
public void shouldRetrieveChildren() {
63-
Map<String, Object> child1 = new HashMap<>();
64-
Map<String, Object> child2 = new HashMap<>();
65-
List<Map<String, Object>> children = Arrays.asList(child1, child2);
60+
var children = List.of(Map.of(), Map.of());
6661

6762
document.put(KEY, children);
6863

@@ -80,8 +75,7 @@ public void shouldRetrieveEmptyStreamForNonExistingChildren() {
8075

8176
@Test
8277
public void shouldIncludePropsInToString() {
83-
Map<String, Object> props = new HashMap<>();
84-
props.put(KEY, VALUE);
78+
Map<String, Object> props = Map.of(KEY, VALUE);
8579
DocumentImplementation document = new DocumentImplementation(props);
8680
assertTrue(document.toString().contains(KEY));
8781
assertTrue(document.toString().contains(VALUE));

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@
2323

2424
package com.iluwatar.abstractdocument;
2525

26-
import static org.junit.jupiter.api.Assertions.assertEquals;
27-
28-
import java.util.Arrays;
29-
import java.util.HashMap;
30-
import java.util.Map;
31-
32-
import org.junit.jupiter.api.Test;
33-
3426
import com.iluwatar.abstractdocument.domain.Car;
3527
import com.iluwatar.abstractdocument.domain.Part;
3628
import com.iluwatar.abstractdocument.domain.enums.Property;
29+
import org.junit.jupiter.api.Test;
30+
31+
import java.util.List;
32+
import java.util.Map;
33+
34+
import static org.junit.jupiter.api.Assertions.assertEquals;
3735

3836
/**
3937
* Test for Part and Car
@@ -49,10 +47,10 @@ public class DomainTest {
4947

5048
@Test
5149
public void shouldConstructPart() {
52-
Map<String, Object> partProperties = new HashMap<>();
53-
partProperties.put(Property.TYPE.toString(), TEST_PART_TYPE);
54-
partProperties.put(Property.MODEL.toString(), TEST_PART_MODEL);
55-
partProperties.put(Property.PRICE.toString(), TEST_PART_PRICE);
50+
Map<String, Object> partProperties = Map.of(
51+
Property.TYPE.toString(), TEST_PART_TYPE,
52+
Property.MODEL.toString(), TEST_PART_MODEL,
53+
Property.PRICE.toString(), TEST_PART_PRICE);
5654
Part part = new Part(partProperties);
5755

5856
assertEquals(TEST_PART_TYPE, part.getType().get());
@@ -62,10 +60,10 @@ public void shouldConstructPart() {
6260

6361
@Test
6462
public void shouldConstructCar() {
65-
Map<String, Object> carProperties = new HashMap<>();
66-
carProperties.put(Property.MODEL.toString(), TEST_CAR_MODEL);
67-
carProperties.put(Property.PRICE.toString(), TEST_CAR_PRICE);
68-
carProperties.put(Property.PARTS.toString(), Arrays.asList(new HashMap<>(), new HashMap<>()));
63+
Map<String, Object> carProperties = Map.of(
64+
Property.MODEL.toString(), TEST_CAR_MODEL,
65+
Property.PRICE.toString(), TEST_CAR_PRICE,
66+
Property.PARTS.toString(), List.of(Map.of(), Map.of()));
6967
Car car = new Car(carProperties);
7068

7169
assertEquals(TEST_CAR_MODEL, car.getModel().get());

abstract-factory/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ Use the Abstract Factory pattern when
188188
## Tutorial
189189
* [Abstract Factory Pattern Tutorial](https://www.journaldev.com/1418/abstract-factory-design-pattern-in-java)
190190

191-
## Presentations
192-
193-
* [Abstract Factory Pattern](etc/presentation.html)
194-
195191

196192
## Real world examples
197193

abstract-factory/etc/diagram1.png

-56.7 KB
Binary file not shown.

abstract-factory/etc/diagram2.png

-25.7 KB
Binary file not shown.

abstract-factory/etc/presentation.html

Lines changed: 0 additions & 190 deletions
This file was deleted.

0 commit comments

Comments
 (0)