From a85936e76995b3c6cee2633670f8b2cf7c061029 Mon Sep 17 00:00:00 2001 From: Iulian Manda Date: Mon, 31 May 2021 15:50:18 +0300 Subject: [PATCH] Revert "iulian.manda@gmail evaluation article "A quick and practical example of Hexagonal Architecture in Java"" This reverts commit 5cb49ba8 --- patterns/hexagonal/pom.xml | 17 ------- .../hexagonal/WeatherForecasterApp.java | 17 ------- .../repository/MockWeatherRepository.java | 17 ------- .../repository/RepositoryFactory.java | 11 ----- .../repository/WeatherRepository.java | 5 -- .../service/WeatherForecasterService.java | 20 -------- .../ui/WeatherForecasterConsoleUI.java | 48 ------------------- .../hexagonal/ui/WeatherForecasterUI.java | 5 -- patterns/pom.xml | 3 +- 9 files changed, 1 insertion(+), 142 deletions(-) delete mode 100644 patterns/hexagonal/pom.xml delete mode 100644 patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/WeatherForecasterApp.java delete mode 100644 patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/MockWeatherRepository.java delete mode 100644 patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/RepositoryFactory.java delete mode 100644 patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/WeatherRepository.java delete mode 100644 patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/service/WeatherForecasterService.java delete mode 100644 patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/ui/WeatherForecasterConsoleUI.java delete mode 100644 patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/ui/WeatherForecasterUI.java diff --git a/patterns/hexagonal/pom.xml b/patterns/hexagonal/pom.xml deleted file mode 100644 index 7f6cbf176b..0000000000 --- a/patterns/hexagonal/pom.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - 4.0.0 - hexagonal - 1.0 - hexagonal - A quick and practical example of Hexagonal Architecture in Java - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - diff --git a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/WeatherForecasterApp.java b/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/WeatherForecasterApp.java deleted file mode 100644 index fb21f9a877..0000000000 --- a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/WeatherForecasterApp.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.pattern.hexagonal; - -import com.baeldung.pattern.hexagonal.repository.RepositoryFactory; -import com.baeldung.pattern.hexagonal.repository.WeatherRepository; -import com.baeldung.pattern.hexagonal.service.WeatherForecasterService; -import com.baeldung.pattern.hexagonal.ui.WeatherForecasterConsoleUI; -import com.baeldung.pattern.hexagonal.ui.WeatherForecasterUI; - -public class WeatherForecasterApp { - public static void main(String[] args) { - WeatherRepository repository = RepositoryFactory.getMockWeatherRepository(); - WeatherForecasterService service = new WeatherForecasterService(repository); - WeatherForecasterUI ui = new WeatherForecasterConsoleUI(service); - - ui.start(); - } -} diff --git a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/MockWeatherRepository.java b/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/MockWeatherRepository.java deleted file mode 100644 index cdb68b9086..0000000000 --- a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/MockWeatherRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.pattern.hexagonal.repository; - -public class MockWeatherRepository implements WeatherRepository { - @Override - public double getTemperature(String location) { - switch (location) { - case "cluj-napoca": - return 17; - case "bucharest": - return 22; - case "new york": - return 15; - default: - return 20; - } - } -} diff --git a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/RepositoryFactory.java b/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/RepositoryFactory.java deleted file mode 100644 index d1c74f4b6d..0000000000 --- a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/RepositoryFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.pattern.hexagonal.repository; - -public class RepositoryFactory { - private RepositoryFactory() { - super(); - } - - public static WeatherRepository getMockWeatherRepository() { - return new MockWeatherRepository(); - } -} diff --git a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/WeatherRepository.java b/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/WeatherRepository.java deleted file mode 100644 index 4c41c712ec..0000000000 --- a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/repository/WeatherRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.pattern.hexagonal.repository; - -public interface WeatherRepository { - double getTemperature(String location); -} diff --git a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/service/WeatherForecasterService.java b/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/service/WeatherForecasterService.java deleted file mode 100644 index c39f01235b..0000000000 --- a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/service/WeatherForecasterService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.pattern.hexagonal.service; - -import com.baeldung.pattern.hexagonal.repository.WeatherRepository; - -public class WeatherForecasterService { - private final WeatherRepository repository; - - public WeatherForecasterService(WeatherRepository repository) { - this.repository = repository; - } - - public double forecast(String location) { - String normalizedLocation = getNormalizedLocation(location); - return repository.getTemperature(normalizedLocation); - } - - private String getNormalizedLocation(String location) { - return location == null ? "" : location.toLowerCase(); - } -} diff --git a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/ui/WeatherForecasterConsoleUI.java b/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/ui/WeatherForecasterConsoleUI.java deleted file mode 100644 index 3877563694..0000000000 --- a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/ui/WeatherForecasterConsoleUI.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.baeldung.pattern.hexagonal.ui; - -import com.baeldung.pattern.hexagonal.service.WeatherForecasterService; - -import java.io.PrintStream; -import java.nio.charset.StandardCharsets; -import java.util.Scanner; - -public class WeatherForecasterConsoleUI implements WeatherForecasterUI { - private WeatherForecasterService service; - private Scanner in; - private PrintStream out; - - public WeatherForecasterConsoleUI(WeatherForecasterService service) { - this.service = service; - this.in = new Scanner(System.in); - this.out = new PrintStream(System.out, true, StandardCharsets.UTF_8); - } - - @Override - public void start() { - String input = getInput(); - while (isNotExit(input)) { - showTemperature(input); - input = getInput(); - } - stop(); - } - - private String getInput() { - out.print("Location: "); - return in.nextLine(); - } - - private boolean isNotExit(String input) { - return !input.equalsIgnoreCase("exit"); - } - - private void showTemperature(String input) { - double temperature = service.forecast(input); - out.printf("%.2f\u00B0C%n", temperature); - } - - private void stop() { - in.close(); - out.close(); - } -} diff --git a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/ui/WeatherForecasterUI.java b/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/ui/WeatherForecasterUI.java deleted file mode 100644 index da25cec7bb..0000000000 --- a/patterns/hexagonal/src/main/java/com/baeldung/pattern/hexagonal/ui/WeatherForecasterUI.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.pattern.hexagonal.ui; - -public interface WeatherForecasterUI { - void start(); -} diff --git a/patterns/pom.xml b/patterns/pom.xml index be419ace86..112eecb606 100644 --- a/patterns/pom.xml +++ b/patterns/pom.xml @@ -1,5 +1,5 @@ - 4.0.0 patterns @@ -22,7 +22,6 @@ cqrs-es front-controller hexagonal-architecture - hexagonal intercepting-filter solid clean-architecture