Hexagonal Architecture in Java - incorporated feedback

This commit is contained in:
DESKTOP-MG5QNKB\harsha 2019-06-12 00:54:16 -04:00
parent 84bcc8115c
commit a51abbab58
6 changed files with 27 additions and 34 deletions

View File

@ -1,7 +1,6 @@
package com.baeldung.hexagon; package com.baeldung.hexagon;
public class ConstantTaxRateRepository implements TaxRateRepository{ public class ConstantTaxRateRepository implements TaxRateRepository {
private static final double TAX_RATE = 0.13d; private static final double TAX_RATE = 0.13d;
@Override @Override

View File

@ -10,8 +10,7 @@ public class TaxCalculator implements TaxService {
} }
@Override @Override
public double calculateTax(Double amount) { public double calculateTax(double amount) {
return amount * taxRateRepository.getRate(); return amount * taxRateRepository.getRate();
} }
} }

View File

@ -1,7 +1,6 @@
package com.baeldung.hexagon; package com.baeldung.hexagon;
public class TaxFactory { public class TaxFactory {
public static TaxService getTaxService() { public static TaxService getTaxService() {
return new TaxCalculator(getTaxRepository()); return new TaxCalculator(getTaxRepository());
} }
@ -9,5 +8,4 @@ public class TaxFactory {
public static TaxRateRepository getTaxRepository() { public static TaxRateRepository getTaxRepository() {
return new ConstantTaxRateRepository(); return new ConstantTaxRateRepository();
} }
} }

View File

@ -1,6 +1,5 @@
package com.baeldung.hexagon; package com.baeldung.hexagon;
public interface TaxRateRepository { public interface TaxRateRepository {
public double getRate(); public double getRate();
} }

View File

@ -1,7 +1,5 @@
package com.baeldung.hexagon; package com.baeldung.hexagon;
public interface TaxService { public interface TaxService {
public double calculateTax(double amount);
public double calculateTax(Double amount);
} }

View File

@ -3,7 +3,7 @@ package com.baeldung.hexagon;
public class TestTaxUser { public class TestTaxUser {
public double calculateTax(Double amount) { public double calculateTax(Double amount) {
return TaxFactory.getTaxService().calculateTax(amount); return TaxFactory.getTaxService()
.calculateTax(amount);
} }
} }