merge changes
This commit is contained in:
commit
8f85353baf
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
github: [iluwatar]
|
@ -6,8 +6,7 @@ sudo: required
|
||||
|
||||
env:
|
||||
global:
|
||||
- GH_REF: github.com/iluwatar/java-design-patterns.git
|
||||
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
|
||||
- secure: "DCpazS3nkLnter3sguXEAS2fC/1ZWNfM+XLyif9MfNFxlZdpni2vCD/jA0Rdpga8puQWHNVLyAec+RPFH/2qSmJ1c1UTV5MaLv8tPqwUX0VFA+1I6XoSv6oX4ldHTBWHEWqQHkRFOLoil0h0edc0tTOWQwXF8U+DLAB+HkRb4gw="
|
||||
|
||||
services:
|
||||
- xvfb
|
||||
@ -24,7 +23,7 @@ script:
|
||||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then mvn clean verify sonar:sonar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.host.url=https://sonarcloud.io; fi'
|
||||
|
||||
after_success:
|
||||
- bash update-ghpages.sh
|
||||
- bash update-website.sh
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
@ -1,13 +0,0 @@
|
||||
# Code Coverage Report generation
|
||||
|
||||
To generate the code coverage report, execute the following command:
|
||||
> mvn clean verify jacoco:report
|
||||
|
||||
This will generate code coverage report in each of the modules. In order to view the same, open the following file in your browser.
|
||||
> target/site/jacoco/index.html
|
||||
|
||||
Please note that the above folder is created under each of the modules. For example:
|
||||
* adapter/target/site/jacoco/index.html
|
||||
* business-delegate/target/site/jacoco/index.html
|
||||
|
||||
|
@ -17,7 +17,7 @@ solve common problems when designing an application or system.
|
||||
Design patterns can speed up the development process by providing tested, proven
|
||||
development paradigms.
|
||||
|
||||
Reusing design patterns help prevent subtle issues which cause major
|
||||
Reusing design patterns help prevent subtle issues that cause major
|
||||
problems, and it also improves code readability for coders and architects who
|
||||
are familiar with the patterns.
|
||||
|
||||
@ -42,7 +42,7 @@ Once you are familiar with these concepts you can start drilling down into
|
||||
patterns by any of the following approaches
|
||||
|
||||
- Using difficulty tags, `Difficulty-Beginner`, `Difficulty-Intermediate` & `Difficulty-Expert`.
|
||||
- Using pattern categories, `Creational`, `Behavioral` and others.
|
||||
- Using pattern categories, `Creational`, `Behavioral`, and others.
|
||||
- Search for a specific pattern. Can't find one? Please report a new pattern [here](https://github.com/iluwatar/java-design-patterns/issues).
|
||||
|
||||
Hopefully you find the object oriented solutions presented on this site useful
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import java.util.List;
|
||||
@ -61,7 +62,7 @@ public abstract class AbstractDocument implements Document {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilder();
|
||||
builder.append(getClass().getName()).append("[");
|
||||
properties.forEach((key, value) -> builder.append("[").append(key).append(" : ").append(value).append("]"));
|
||||
builder.append("]");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,17 +20,16 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.iluwatar.abstractdocument.domain.Car;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Abstract Document pattern enables handling additional, non-static
|
||||
@ -52,23 +51,22 @@ public class App {
|
||||
public App() {
|
||||
LOGGER.info("Constructing parts and car");
|
||||
|
||||
Map<String, Object> carProperties = new HashMap<>();
|
||||
carProperties.put(Property.MODEL.toString(), "300SL");
|
||||
carProperties.put(Property.PRICE.toString(), 10000L);
|
||||
var wheelProperties = Map.of(
|
||||
Property.TYPE.toString(), "wheel",
|
||||
Property.MODEL.toString(), "15C",
|
||||
Property.PRICE.toString(), 100L);
|
||||
|
||||
Map<String, Object> wheelProperties = new HashMap<>();
|
||||
wheelProperties.put(Property.TYPE.toString(), "wheel");
|
||||
wheelProperties.put(Property.MODEL.toString(), "15C");
|
||||
wheelProperties.put(Property.PRICE.toString(), 100L);
|
||||
var doorProperties = Map.of(
|
||||
Property.TYPE.toString(), "door",
|
||||
Property.MODEL.toString(), "Lambo",
|
||||
Property.PRICE.toString(), 300L);
|
||||
|
||||
Map<String, Object> doorProperties = new HashMap<>();
|
||||
doorProperties.put(Property.TYPE.toString(), "door");
|
||||
doorProperties.put(Property.MODEL.toString(), "Lambo");
|
||||
doorProperties.put(Property.PRICE.toString(), 300L);
|
||||
var carProperties = Map.of(
|
||||
Property.MODEL.toString(), "300SL",
|
||||
Property.PRICE.toString(), 10000L,
|
||||
Property.PARTS.toString(), List.of(wheelProperties, doorProperties));
|
||||
|
||||
carProperties.put(Property.PARTS.toString(), Arrays.asList(wheelProperties, doorProperties));
|
||||
|
||||
Car car = new Car(carProperties);
|
||||
var car = new Car(carProperties);
|
||||
|
||||
LOGGER.info("Here is our car:");
|
||||
LOGGER.info("-> model: {}", car.getModel().get());
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument.domain.enums;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,19 +20,17 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* AbstractDocument test class
|
||||
@ -59,9 +57,7 @@ public class AbstractDocumentTest {
|
||||
|
||||
@Test
|
||||
public void shouldRetrieveChildren() {
|
||||
Map<String, Object> child1 = new HashMap<>();
|
||||
Map<String, Object> child2 = new HashMap<>();
|
||||
List<Map<String, Object>> children = Arrays.asList(child1, child2);
|
||||
var children = List.of(Map.of(), Map.of());
|
||||
|
||||
document.put(KEY, children);
|
||||
|
||||
@ -79,8 +75,7 @@ public class AbstractDocumentTest {
|
||||
|
||||
@Test
|
||||
public void shouldIncludePropsInToString() {
|
||||
Map<String, Object> props = new HashMap<>();
|
||||
props.put(KEY, VALUE);
|
||||
Map<String, Object> props = Map.of(KEY, VALUE);
|
||||
DocumentImplementation document = new DocumentImplementation(props);
|
||||
assertTrue(document.toString().contains(KEY));
|
||||
assertTrue(document.toString().contains(VALUE));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,19 +20,18 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.iluwatar.abstractdocument.domain.Car;
|
||||
import com.iluwatar.abstractdocument.domain.Part;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Test for Part and Car
|
||||
@ -48,10 +47,10 @@ public class DomainTest {
|
||||
|
||||
@Test
|
||||
public void shouldConstructPart() {
|
||||
Map<String, Object> partProperties = new HashMap<>();
|
||||
partProperties.put(Property.TYPE.toString(), TEST_PART_TYPE);
|
||||
partProperties.put(Property.MODEL.toString(), TEST_PART_MODEL);
|
||||
partProperties.put(Property.PRICE.toString(), TEST_PART_PRICE);
|
||||
Map<String, Object> partProperties = Map.of(
|
||||
Property.TYPE.toString(), TEST_PART_TYPE,
|
||||
Property.MODEL.toString(), TEST_PART_MODEL,
|
||||
Property.PRICE.toString(), TEST_PART_PRICE);
|
||||
Part part = new Part(partProperties);
|
||||
|
||||
assertEquals(TEST_PART_TYPE, part.getType().get());
|
||||
@ -61,10 +60,10 @@ public class DomainTest {
|
||||
|
||||
@Test
|
||||
public void shouldConstructCar() {
|
||||
Map<String, Object> carProperties = new HashMap<>();
|
||||
carProperties.put(Property.MODEL.toString(), TEST_CAR_MODEL);
|
||||
carProperties.put(Property.PRICE.toString(), TEST_CAR_PRICE);
|
||||
carProperties.put(Property.PARTS.toString(), Arrays.asList(new HashMap<>(), new HashMap<>()));
|
||||
Map<String, Object> carProperties = Map.of(
|
||||
Property.MODEL.toString(), TEST_CAR_MODEL,
|
||||
Property.PRICE.toString(), TEST_CAR_PRICE,
|
||||
Property.PARTS.toString(), List.of(Map.of(), Map.of()));
|
||||
Car car = new Car(carProperties);
|
||||
|
||||
assertEquals(TEST_CAR_MODEL, car.getModel().get());
|
||||
|
@ -188,10 +188,6 @@ Use the Abstract Factory pattern when
|
||||
## Tutorial
|
||||
* [Abstract Factory Pattern Tutorial](https://www.journaldev.com/1418/abstract-factory-design-pattern-in-java)
|
||||
|
||||
## Presentations
|
||||
|
||||
* [Abstract Factory Pattern](etc/presentation.html)
|
||||
|
||||
|
||||
## Real world examples
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 57 KiB |
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
@ -1,190 +0,0 @@
|
||||
<!--
|
||||
|
||||
The MIT License
|
||||
Copyright © 2014-2019 Ilkka Seppälä
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Design Patterns - Abstract Factory Presentation</title>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
|
||||
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
|
||||
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
|
||||
|
||||
body { font-family: 'Droid Serif'; }
|
||||
h1, h2, h3 {
|
||||
font-family: 'Yanone Kaffeesatz';
|
||||
font-weight: normal;
|
||||
}
|
||||
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
|
||||
|
||||
blockquote {
|
||||
border-left: 0.3em solid rgba(0,0,0,0.5);
|
||||
padding: 0 15px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width:100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="source">
|
||||
|
||||
class: center, middle
|
||||
|
||||
# Abstract Factory
|
||||
|
||||
---
|
||||
|
||||
# Also known as
|
||||
|
||||
* Kit
|
||||
|
||||
---
|
||||
|
||||
# Intent
|
||||
|
||||
* Provide an interface for creating families of related or dependent objects without specifying their concrete classes
|
||||
|
||||
---
|
||||
|
||||
# Explanation
|
||||
|
||||
* [Wikipedia](https://en.wikipedia.org/wiki/Abstract_factory_pattern) says:
|
||||
> "The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes"
|
||||
|
||||
<br />
|
||||
|
||||
* In plain words:
|
||||
* A factory that groups individual but related/dependent factories together without specifying their concrete classes;
|
||||
* A factory of factories;
|
||||
|
||||
---
|
||||
|
||||
# Example
|
||||
|
||||
* In a factory that creates kingdoms, we need objects with common theme:
|
||||
|
||||
* Elven kingdom needs an Elven king, Elven castle and Elven army;
|
||||
|
||||
* Orcish kingdom needs an Orcish king, Orcish castle and Orcish army;
|
||||
|
||||
<br />
|
||||
|
||||
* There is a dependency between the objects in the kingdom;
|
||||
|
||||
---
|
||||
|
||||
# Diagram
|
||||
|
||||
* Based on the kingdom example, the diagram below showcases the different concrete factories and their concrete products:
|
||||
|
||||
.center[]
|
||||
|
||||
|
||||
---
|
||||
|
||||
# Diagram
|
||||
|
||||
* The class diagram below showcases the factory of factories;
|
||||
|
||||
* At runtime, we can define which Kingdom type is needed and pass it as a parameter to define which concrete KingdomFactory to instantiate;
|
||||
|
||||
* The concrete factory returned will then be able to produce the related objects of the specified type;
|
||||
|
||||
.center[]
|
||||
|
||||
---
|
||||
|
||||
# Applicability
|
||||
|
||||
Use the Abstract Factory pattern when:
|
||||
|
||||
* A system should be independent of how its products are created, composed and represented;
|
||||
|
||||
* A system should be configured with one of multiple families of products;
|
||||
|
||||
* A family of related product objects is designed to be used together, and you need to enforce this constraint;
|
||||
|
||||
* You want to provide a class library of products, and you want to reveal just their interfaces, not their implementations;
|
||||
|
||||
---
|
||||
|
||||
# Applicability
|
||||
|
||||
Use the Abstract Factory pattern when:
|
||||
|
||||
* The lifetime of the dependency is conceptually shorter than the lifetime of the consumer;
|
||||
|
||||
* You need a run-time value to construct a particular dependency;
|
||||
|
||||
* You want to decide which product to call from a family at runtime;
|
||||
|
||||
* You need to supply one or more parameters only known at run-time before you can resolve a dependency;
|
||||
|
||||
---
|
||||
|
||||
#Use Cases
|
||||
|
||||
* Selecting to call the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or NetworkAcmeService at runtime;
|
||||
* Unit test case writing becomes much easier;
|
||||
|
||||
---
|
||||
|
||||
# Consequences
|
||||
|
||||
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time
|
||||
|
||||
---
|
||||
|
||||
# Real world examples
|
||||
|
||||
[javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)
|
||||
|
||||
[javax.xml.transform.TransformerFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/transform/TransformerFactory.html#newInstance--)
|
||||
|
||||
[javax.xml.xpath.XPathFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/xpath/XPathFactory.html#newInstance--)
|
||||
|
||||
---
|
||||
|
||||
# Credits
|
||||
|
||||
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
|
||||
|
||||
---
|
||||
|
||||
# Tutorials
|
||||
|
||||
* Source code http://java-design-patterns.com/patterns/abstract-factory/
|
||||
|
||||
</textarea>
|
||||
<script src="https://remarkjs.com/downloads/remark-latest.min.js">
|
||||
</script>
|
||||
<script>
|
||||
var slideshow = remark.create();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
@ -41,11 +42,11 @@ public class App {
|
||||
*/
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigureForUnixVisitor conUnix = new ConfigureForUnixVisitor();
|
||||
ConfigureForDosVisitor conDos = new ConfigureForDosVisitor();
|
||||
var conUnix = new ConfigureForUnixVisitor();
|
||||
var conDos = new ConfigureForDosVisitor();
|
||||
|
||||
Zoom zoom = new Zoom();
|
||||
Hayes hayes = new Hayes();
|
||||
var zoom = new Zoom();
|
||||
var hayes = new Hayes();
|
||||
|
||||
hayes.accept(conDos); // Hayes modem with Dos configurator
|
||||
zoom.accept(conDos); // Zoom modem with Dos configurator
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,22 +20,15 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.groups.Tuple.tuple;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static uk.org.lidalia.slf4jext.Level.INFO;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.iluwatar.acyclicvisitor.ConfigureForDosVisitor;
|
||||
import com.iluwatar.acyclicvisitor.Hayes;
|
||||
import com.iluwatar.acyclicvisitor.HayesVisitor;
|
||||
import com.iluwatar.acyclicvisitor.Zoom;
|
||||
import com.iluwatar.acyclicvisitor.ZoomVisitor;
|
||||
|
||||
import uk.org.lidalia.slf4jtest.TestLogger;
|
||||
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
|
||||
|
||||
@ -48,8 +41,8 @@ public class ConfigureForDosVisitorTest {
|
||||
|
||||
@Test
|
||||
public void testVisitForZoom() {
|
||||
ConfigureForDosVisitor conDos = new ConfigureForDosVisitor();
|
||||
Zoom zoom = new Zoom();
|
||||
var conDos = new ConfigureForDosVisitor();
|
||||
var zoom = new Zoom();
|
||||
|
||||
conDos.visit(zoom);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -46,8 +47,8 @@ public class ConfigureForUnixVisitorTest {
|
||||
|
||||
@Test
|
||||
public void testVisitForZoom() {
|
||||
ConfigureForUnixVisitor conUnix = new ConfigureForUnixVisitor();
|
||||
Zoom zoom = new Zoom();
|
||||
var conUnix = new ConfigureForUnixVisitor();
|
||||
var zoom = new Zoom();
|
||||
|
||||
conUnix.visit(zoom);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import static org.mockito.Matchers.eq;
|
||||
@ -29,11 +30,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.iluwatar.acyclicvisitor.ConfigureForDosVisitor;
|
||||
import com.iluwatar.acyclicvisitor.ConfigureForUnixVisitor;
|
||||
import com.iluwatar.acyclicvisitor.Hayes;
|
||||
import com.iluwatar.acyclicvisitor.HayesVisitor;
|
||||
|
||||
/**
|
||||
* Hayes test class
|
||||
*/
|
||||
@ -41,8 +37,8 @@ public class HayesTest {
|
||||
|
||||
@Test
|
||||
public void testAcceptForDos() {
|
||||
Hayes hayes = new Hayes();
|
||||
ConfigureForDosVisitor mockVisitor = mock(ConfigureForDosVisitor.class);
|
||||
var hayes = new Hayes();
|
||||
var mockVisitor = mock(ConfigureForDosVisitor.class);
|
||||
|
||||
hayes.accept(mockVisitor);
|
||||
verify((HayesVisitor)mockVisitor).visit(eq(hayes));
|
||||
@ -50,8 +46,8 @@ public class HayesTest {
|
||||
|
||||
@Test
|
||||
public void testAcceptForUnix() {
|
||||
Hayes hayes = new Hayes();
|
||||
ConfigureForUnixVisitor mockVisitor = mock(ConfigureForUnixVisitor.class);
|
||||
var hayes = new Hayes();
|
||||
var mockVisitor = mock(ConfigureForUnixVisitor.class);
|
||||
|
||||
hayes.accept(mockVisitor);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
|
||||
@ -29,11 +30,6 @@ import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.iluwatar.acyclicvisitor.ConfigureForDosVisitor;
|
||||
import com.iluwatar.acyclicvisitor.ConfigureForUnixVisitor;
|
||||
import com.iluwatar.acyclicvisitor.Zoom;
|
||||
import com.iluwatar.acyclicvisitor.ZoomVisitor;
|
||||
|
||||
/**
|
||||
* Zoom test class
|
||||
*/
|
||||
@ -41,8 +37,8 @@ public class ZoomTest {
|
||||
|
||||
@Test
|
||||
public void testAcceptForDos() {
|
||||
Zoom zoom = new Zoom();
|
||||
ConfigureForDosVisitor mockVisitor = mock(ConfigureForDosVisitor.class);
|
||||
var zoom = new Zoom();
|
||||
var mockVisitor = mock(ConfigureForDosVisitor.class);
|
||||
|
||||
zoom.accept(mockVisitor);
|
||||
verify((ZoomVisitor)mockVisitor).visit(eq(zoom));
|
||||
@ -50,8 +46,8 @@ public class ZoomTest {
|
||||
|
||||
@Test
|
||||
public void testAcceptForUnix() {
|
||||
Zoom zoom = new Zoom();
|
||||
ConfigureForUnixVisitor mockVisitor = mock(ConfigureForUnixVisitor.class);
|
||||
var zoom = new Zoom();
|
||||
var mockVisitor = mock(ConfigureForUnixVisitor.class);
|
||||
|
||||
zoom.accept(mockVisitor);
|
||||
verify((ZoomVisitor)mockVisitor).visit(eq(zoom));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,41 +20,49 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
* An adapter helps two incompatible interfaces to work together. This is the real world definition
|
||||
* for an adapter. Interfaces may be incompatible but the inner functionality should suit the need.
|
||||
* The Adapter design pattern allows otherwise incompatible classes to work together by converting
|
||||
* the interface of one class into an interface expected by the clients.
|
||||
* An adapter helps two incompatible interfaces to work together. This is the
|
||||
* real world definition for an adapter. Interfaces may be incompatible but
|
||||
* the inner functionality should suit the need. The Adapter design pattern
|
||||
* allows otherwise incompatible classes to work together by converting the
|
||||
* interface of one class into an interface expected by the clients.
|
||||
*
|
||||
* <p>
|
||||
* There are two variations of the Adapter pattern: The class adapter implements the adaptee's
|
||||
* interface whereas the object adapter uses composition to contain the adaptee in the adapter
|
||||
* object. This example uses the object adapter approach.
|
||||
* There are two variations of the Adapter pattern: The class adapter
|
||||
* implements the adaptee's interface whereas the object adapter uses
|
||||
* composition to contain the adaptee in the adapter object. This example uses
|
||||
* the object adapter approach.
|
||||
*
|
||||
* <p>
|
||||
* The Adapter ({@link FishingBoatAdapter}) converts the interface of the adaptee class (
|
||||
* {@link FishingBoat}) into a suitable one expected by the client ( {@link RowingBoat} ).
|
||||
* The Adapter ({@link FishingBoatAdapter}) converts the interface of the
|
||||
* adaptee class ({@link FishingBoat}) into a suitable one expected by the
|
||||
* client ({@link RowingBoat}).
|
||||
*
|
||||
* <p>
|
||||
* The story of this implementation is this. <br>
|
||||
* Pirates are coming! we need a {@link RowingBoat} to flee! We have a {@link FishingBoat} and our
|
||||
* captain. We have no time to make up a new ship! we need to reuse this {@link FishingBoat}. The
|
||||
* captain needs a rowing boat which he can operate. The spec is in {@link RowingBoat}. We will
|
||||
* use the Adapter pattern to reuse {@link FishingBoat}.
|
||||
* Pirates are coming! we need a {@link RowingBoat} to flee! We have a
|
||||
* {@link FishingBoat} and our captain. We have no time to make up a new ship!
|
||||
* we need to reuse this {@link FishingBoat}. The captain needs a rowing boat
|
||||
* which he can operate. The spec is in {@link RowingBoat}. We will use the
|
||||
* Adapter pattern to reuse {@link FishingBoat}.
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
public final class App {
|
||||
|
||||
private App() { }
|
||||
|
||||
/**
|
||||
* Program entry point.
|
||||
*
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// The captain can only operate rowing boats but with adapter he is able to use fishing boats as well
|
||||
Captain captain = new Captain(new FishingBoatAdapter());
|
||||
public static void main(final String[] args) {
|
||||
// The captain can only operate rowing boats but with adapter he is able to
|
||||
// use fishing boats as well
|
||||
var captain = new Captain(new FishingBoatAdapter());
|
||||
captain.row();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,27 +20,28 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
* The Captain uses {@link RowingBoat} to sail. <br>
|
||||
* This is the client in the pattern.
|
||||
*/
|
||||
public class Captain {
|
||||
public final class Captain {
|
||||
|
||||
private RowingBoat rowingBoat;
|
||||
|
||||
public Captain() {}
|
||||
public Captain() { }
|
||||
|
||||
public Captain(RowingBoat rowingBoat) {
|
||||
this.rowingBoat = rowingBoat;
|
||||
public Captain(final RowingBoat boat) {
|
||||
this.rowingBoat = boat;
|
||||
}
|
||||
|
||||
public void setRowingBoat(RowingBoat rowingBoat) {
|
||||
this.rowingBoat = rowingBoat;
|
||||
void setRowingBoat(final RowingBoat boat) {
|
||||
this.rowingBoat = boat;
|
||||
}
|
||||
|
||||
public void row() {
|
||||
void row() {
|
||||
rowingBoat.row();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,10 +20,12 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -31,11 +33,11 @@ import org.slf4j.LoggerFactory;
|
||||
* Fishing boat moves by sailing.
|
||||
*
|
||||
*/
|
||||
public class FishingBoat {
|
||||
final class FishingBoat {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoat.class);
|
||||
private static final Logger LOGGER = getLogger(FishingBoat.class);
|
||||
|
||||
public void sail() {
|
||||
void sail() {
|
||||
LOGGER.info("The fishing boat is sailing");
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,12 +20,13 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* Adapter class. Adapts the interface of the device ({@link FishingBoat}) into {@link RowingBoat}
|
||||
* interface expected by the client ({@link Captain}).
|
||||
* Adapter class. Adapts the interface of the device ({@link FishingBoat})
|
||||
* into {@link RowingBoat} interface expected by the client ({@link Captain}).
|
||||
*
|
||||
*/
|
||||
public class FishingBoatAdapter implements RowingBoat {
|
||||
@ -36,8 +37,7 @@ public class FishingBoatAdapter implements RowingBoat {
|
||||
boat = new FishingBoat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void row() {
|
||||
public final void row() {
|
||||
boat.sail();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
|
24
adapter/src/main/java/com/iluwatar/adapter/package-info.java
Normal file
24
adapter/src/main/java/com/iluwatar/adapter/package-info.java
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.adapter;
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -53,7 +54,7 @@ public class AdapterPatternTest {
|
||||
FishingBoatAdapter fishingBoatAdapter = spy(new FishingBoatAdapter());
|
||||
beans.put(FISHING_BEAN, fishingBoatAdapter);
|
||||
|
||||
Captain captain = new Captain();
|
||||
var captain = new Captain();
|
||||
captain.setRowingBoat((FishingBoatAdapter) beans.get(FISHING_BEAN));
|
||||
beans.put(ROWING_BEAN, captain);
|
||||
}
|
||||
@ -66,13 +67,13 @@ public class AdapterPatternTest {
|
||||
*/
|
||||
@Test
|
||||
public void testAdapter() {
|
||||
Captain captain = (Captain) beans.get(ROWING_BEAN);
|
||||
var captain = (Captain) beans.get(ROWING_BEAN);
|
||||
|
||||
// when captain moves
|
||||
captain.row();
|
||||
|
||||
// the captain internally calls the battleship object to move
|
||||
RowingBoat adapter = (RowingBoat) beans.get(FISHING_BEAN);
|
||||
var adapter = (RowingBoat) beans.get(FISHING_BEAN);
|
||||
verify(adapter).row();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -50,9 +51,23 @@ public class Aggregator {
|
||||
*/
|
||||
@RequestMapping(path = "/product", method = RequestMethod.GET)
|
||||
public Product getProduct() {
|
||||
Product product = new Product();
|
||||
product.setTitle(informationClient.getProductTitle());
|
||||
product.setProductInventories(inventoryClient.getProductInventories());
|
||||
|
||||
var product = new Product();
|
||||
String productTitle = informationClient.getProductTitle();
|
||||
Integer productInventory = inventoryClient.getProductInventories();
|
||||
|
||||
if (productTitle != null) {
|
||||
product.setTitle(productTitle);
|
||||
} else {
|
||||
product.setTitle("Error: Fetching Product Title Failed"); //Fallback to error message
|
||||
}
|
||||
|
||||
if (productInventory != null) {
|
||||
product.setProductInventories(productInventory);
|
||||
} else {
|
||||
product.setProductInventories(-1); //Fallback to default error inventory
|
||||
}
|
||||
|
||||
return product;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -43,10 +44,10 @@ public class ProductInformationClientImpl implements ProductInformationClient {
|
||||
@Override
|
||||
public String getProductTitle() {
|
||||
String response = null;
|
||||
HttpRequest request = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51515/information")).build();
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
var request = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51515/information")).build();
|
||||
var client = HttpClient.newHttpClient();
|
||||
try {
|
||||
HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
var httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
response = httpResponse.body();
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("IOException Occurred", ioe);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
/**
|
||||
@ -27,5 +28,5 @@ package com.iluwatar.aggregator.microservices;
|
||||
*/
|
||||
public interface ProductInventoryClient {
|
||||
|
||||
int getProductInventories();
|
||||
Integer getProductInventories();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -41,19 +42,23 @@ public class ProductInventoryClientImpl implements ProductInventoryClient {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInventoryClientImpl.class);
|
||||
|
||||
@Override
|
||||
public int getProductInventories() {
|
||||
String response = "0";
|
||||
public Integer getProductInventories() {
|
||||
var response = "";
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51516/inventories")).build();
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
var request = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51516/inventories")).build();
|
||||
var client = HttpClient.newHttpClient();
|
||||
try {
|
||||
HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
var httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
response = httpResponse.body();
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("IOException Occurred", ioe);
|
||||
} catch (InterruptedException ie) {
|
||||
LOGGER.error("InterruptedException Occurred", ie);
|
||||
}
|
||||
return Integer.parseInt(response);
|
||||
if("".equalsIgnoreCase(response)) {
|
||||
return null;
|
||||
} else {
|
||||
return Integer.parseInt(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.information.microservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.information.microservice;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.information.microservice;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.inventory.microservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.inventory.microservice;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.inventory.microservice;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
import com.iluwatar.ambassador.util.RandomProvider;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador.util;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
import com.iluwatar.ambassador.util.RandomProvider;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.image.microservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.image.microservice;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.image.microservice;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.price.microservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.price.microservice;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.price.microservice;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.async.method.invocation;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.async.method.invocation;
|
||||
|
||||
import java.util.Optional;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user