Revert "iulian.manda@gmail evaluation article "A quick and practical example of Hexagonal Architecture in Java""

This reverts commit 5cb49ba8
This commit is contained in:
Iulian Manda 2021-05-31 15:50:18 +03:00
parent 7238b3a01f
commit a85936e769
9 changed files with 1 additions and 142 deletions

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>hexagonal</artifactId>
<version>1.0</version>
<name>hexagonal</name>
<description>A quick and practical example of Hexagonal Architecture in Java</description>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-java</relativePath>
</parent>
</project>

View File

@ -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();
}
}

View File

@ -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;
}
}
}

View File

@ -1,11 +0,0 @@
package com.baeldung.pattern.hexagonal.repository;
public class RepositoryFactory {
private RepositoryFactory() {
super();
}
public static WeatherRepository getMockWeatherRepository() {
return new MockWeatherRepository();
}
}

View File

@ -1,5 +0,0 @@
package com.baeldung.pattern.hexagonal.repository;
public interface WeatherRepository {
double getTemperature(String location);
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -1,5 +0,0 @@
package com.baeldung.pattern.hexagonal.ui;
public interface WeatherForecasterUI {
void start();
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>patterns</artifactId>
@ -22,7 +22,6 @@
<module>cqrs-es</module>
<module>front-controller</module>
<module>hexagonal-architecture</module>
<module>hexagonal</module>
<module>intercepting-filter</module>
<module>solid</module>
<module>clean-architecture</module>