diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/AbstractDocument.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/AbstractDocument.java index 649bdbcc9..421d6890a 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/AbstractDocument.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/AbstractDocument.java @@ -31,7 +31,7 @@ import java.util.function.Function; import java.util.stream.Stream; /** - * Abstract implementation of Document interface + * Abstract implementation of Document interface. */ public abstract class AbstractDocument implements Document { @@ -64,7 +64,8 @@ public abstract class AbstractDocument implements Document { public String toString() { var builder = new StringBuilder(); builder.append(getClass().getName()).append("["); - properties.forEach((key, value) -> builder.append("[").append(key).append(" : ").append(value).append("]")); + properties.forEach((key, value) -> builder.append("[").append(key).append(" : ").append(value) + .append("]")); builder.append("]"); return builder.toString(); } diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/App.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/App.java index 99be4ee12..4f4dddafa 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/App.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/App.java @@ -25,46 +25,43 @@ package com.iluwatar.abstractdocument; import com.iluwatar.abstractdocument.domain.Car; import com.iluwatar.abstractdocument.domain.enums.Property; +import java.util.List; +import java.util.Map; 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 - * properties. This pattern uses concept of traits to enable type safety and - * separate properties of different classes into set of interfaces. - *
- *
- * In Abstract Document pattern,({@link AbstractDocument}) fully implements - * {@link Document}) interface. Traits are then defined to enable access to - * properties in usual, static way. + * The Abstract Document pattern enables handling additional, non-static properties. This pattern + * uses concept of traits to enable type safety and separate properties of different classes into + * set of interfaces. + * + *
In Abstract Document pattern,({@link AbstractDocument}) fully implements {@link Document}) + * interface. Traits are then defined to enable access to properties in usual, static way. */ public class App { private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** - * Executes the App + * Executes the App. */ public App() { LOGGER.info("Constructing parts and car"); var wheelProperties = Map.of( - Property.TYPE.toString(), "wheel", - Property.MODEL.toString(), "15C", - Property.PRICE.toString(), 100L); + Property.TYPE.toString(), "wheel", + Property.MODEL.toString(), "15C", + Property.PRICE.toString(), 100L); var doorProperties = Map.of( - Property.TYPE.toString(), "door", - Property.MODEL.toString(), "Lambo", - Property.PRICE.toString(), 300L); + Property.TYPE.toString(), "door", + Property.MODEL.toString(), "Lambo", + Property.PRICE.toString(), 300L); var carProperties = Map.of( - Property.MODEL.toString(), "300SL", - Property.PRICE.toString(), 10000L, - Property.PARTS.toString(), List.of(wheelProperties, doorProperties)); + Property.MODEL.toString(), "300SL", + Property.PRICE.toString(), 10000L, + Property.PARTS.toString(), List.of(wheelProperties, doorProperties)); var car = new Car(carProperties); @@ -72,11 +69,12 @@ public class App { LOGGER.info("-> model: {}", car.getModel().get()); LOGGER.info("-> price: {}", car.getPrice().get()); LOGGER.info("-> parts: "); - car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get())); + car.getParts().forEach(p -> LOGGER + .info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get())); } /** - * Program entry point + * Program entry point. * * @param args command line args */ diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/Document.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/Document.java index e1254c1f9..d0eb85f34 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/Document.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/Document.java @@ -28,12 +28,12 @@ import java.util.function.Function; import java.util.stream.Stream; /** - * Document interface + * Document interface. */ public interface Document { /** - * Puts the value related to the key + * Puts the value related to the key. * * @param key element key * @param value element value @@ -42,7 +42,7 @@ public interface Document { Void put(String key, Object value); /** - * Gets the value for the key + * Gets the value for the key. * * @param key element key * @return value or null @@ -50,7 +50,7 @@ public interface Document { Object get(String key); /** - * Gets the stream of child documents + * Gets the stream of child documents. * * @param key element key * @param constructor constructor of child class diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Car.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Car.java index 738aaab26..bf68d40e5 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Car.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Car.java @@ -23,12 +23,11 @@ package com.iluwatar.abstractdocument.domain; +import com.iluwatar.abstractdocument.AbstractDocument; import java.util.Map; -import com.iluwatar.abstractdocument.AbstractDocument; - /** - * Car entity + * Car entity. */ public class Car extends AbstractDocument implements HasModel, HasPrice, HasParts { diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasModel.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasModel.java index d5178ecad..76d7d7431 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasModel.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasModel.java @@ -23,13 +23,12 @@ package com.iluwatar.abstractdocument.domain; -import java.util.Optional; - import com.iluwatar.abstractdocument.Document; import com.iluwatar.abstractdocument.domain.enums.Property; +import java.util.Optional; /** - * HasModel trait for static access to 'model' property + * HasModel trait for static access to 'model' property. */ public interface HasModel extends Document { diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasParts.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasParts.java index ff021a2ea..8ecfa85fb 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasParts.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasParts.java @@ -23,13 +23,12 @@ package com.iluwatar.abstractdocument.domain; -import java.util.stream.Stream; - import com.iluwatar.abstractdocument.Document; import com.iluwatar.abstractdocument.domain.enums.Property; +import java.util.stream.Stream; /** - * HasParts trait for static access to 'parts' property + * HasParts trait for static access to 'parts' property. */ public interface HasParts extends Document { diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasPrice.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasPrice.java index 97683c344..9a95f2a51 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasPrice.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasPrice.java @@ -23,13 +23,12 @@ package com.iluwatar.abstractdocument.domain; -import java.util.Optional; - import com.iluwatar.abstractdocument.Document; import com.iluwatar.abstractdocument.domain.enums.Property; +import java.util.Optional; /** - * HasPrice trait for static access to 'price' property + * HasPrice trait for static access to 'price' property. */ public interface HasPrice extends Document { diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasType.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasType.java index 8ec1a9fe4..b1d5bd6b5 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasType.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/HasType.java @@ -23,13 +23,12 @@ package com.iluwatar.abstractdocument.domain; -import java.util.Optional; - import com.iluwatar.abstractdocument.Document; import com.iluwatar.abstractdocument.domain.enums.Property; +import java.util.Optional; /** - * HasType trait for static access to 'type' property + * HasType trait for static access to 'type' property. */ public interface HasType extends Document { diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Part.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Part.java index 21e0c7070..996598a92 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Part.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/Part.java @@ -23,12 +23,11 @@ package com.iluwatar.abstractdocument.domain; +import com.iluwatar.abstractdocument.AbstractDocument; import java.util.Map; -import com.iluwatar.abstractdocument.AbstractDocument; - /** - * Part entity + * Part entity. */ public class Part extends AbstractDocument implements HasType, HasModel, HasPrice { diff --git a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/enums/Property.java b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/enums/Property.java index b9957dd0c..640f0ed83 100644 --- a/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/enums/Property.java +++ b/abstract-document/src/main/java/com/iluwatar/abstractdocument/domain/enums/Property.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractdocument.domain.enums; /** - * - * Enum To Describe Property type - * + * Enum To Describe Property type. */ public enum Property { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java index a2b4867b0..2694dd708 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java @@ -23,25 +23,23 @@ package com.iluwatar.abstractfactory; +import com.iluwatar.abstractfactory.App.FactoryMaker.KingdomType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.iluwatar.abstractfactory.App.FactoryMaker.KingdomType; - /** - * - * The Abstract Factory pattern provides a way to encapsulate a group of individual factories that have a common theme - * without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of - * the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part - * of the theme. The client does not know (or care) which concrete objects it gets from each of these internal - * factories, since it uses only the generic interfaces of their products. This pattern separates the details of - * implementation of a set of objects from their general usage and relies on object composition, as object creation is - * implemented in methods exposed in the factory interface. - *
- * The essence of the Abstract Factory pattern is a factory interface ({@link KingdomFactory}) and its implementations ( - * {@link ElfKingdomFactory}, {@link OrcKingdomFactory}). The example uses both concrete implementations to create a - * king, a castle and an army. - * + * The Abstract Factory pattern provides a way to encapsulate a group of individual factories that + * have a common theme without specifying their concrete classes. In normal usage, the client + * software creates a concrete implementation of the abstract factory and then uses the generic + * interface of the factory to create the concrete objects that are part of the theme. The client + * does not know (or care) which concrete objects it gets from each of these internal factories, + * since it uses only the generic interfaces of their products. This pattern separates the details + * of implementation of a set of objects from their general usage and relies on object composition, + * as object creation is implemented in methods exposed in the factory interface. + * + *
The essence of the Abstract Factory pattern is a factory interface ({@link KingdomFactory}) + * and its implementations ( {@link ElfKingdomFactory}, {@link OrcKingdomFactory}). The example uses + * both concrete implementations to create a king, a castle and an army. */ public class App { @@ -52,14 +50,14 @@ public class App { private Army army; /** - * Creates kingdom + * Creates kingdom. */ public void createKingdom(final KingdomFactory factory) { setKing(factory.createKing()); setCastle(factory.createCastle()); setArmy(factory.createArmy()); } - + King getKing(final KingdomFactory factory) { return factory.createKing(); } @@ -71,7 +69,7 @@ public class App { private void setKing(final King king) { this.king = king; } - + Castle getCastle(final KingdomFactory factory) { return factory.createCastle(); } @@ -83,7 +81,7 @@ public class App { private void setCastle(final Castle castle) { this.castle = castle; } - + Army getArmy(final KingdomFactory factory) { return factory.createArmy(); } @@ -125,9 +123,8 @@ public class App { /** * Program entry point. - * - * @param args - * command line args + * + * @param args command line args */ public static void main(String[] args) { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java index 158ad9fa8..51f69a822 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Army.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * Army interface - * + * Army interface. */ public interface Army { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java index faf2cb4cc..c75eb32ef 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/Castle.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * Castle interface - * + * Castle interface. */ public interface Castle { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java index f4196072c..6d2da97cc 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * ElfArmy - * + * ElfArmy. */ public class ElfArmy implements Army { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java index 29f16907e..5f2b6ed2a 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * ElfCastle - * + * ElfCastle. */ public class ElfCastle implements Castle { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java index 8d4c6d7f0..f7c4c6146 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * ElfKing - * + * ElfKing. */ public class ElfKing implements King { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java index 61d744cfc..4493d2d08 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKingdomFactory.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * * ElfKingdomFactory concrete factory. - * */ public class ElfKingdomFactory implements KingdomFactory { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java index cbb27cec2..97e5f676f 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/King.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * King interface - * + * King interface. */ public interface King { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java index c3e3d0f25..a72dbf78c 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/KingdomFactory.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * * KingdomFactory factory interface. - * */ public interface KingdomFactory { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java index 55842f2a9..ae0bd5c3e 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * OrcArmy - * + * OrcArmy. */ public class OrcArmy implements Army { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java index 1316cf6d4..458a61bf9 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * OrcCastle - * + * OrcCastle. */ public class OrcCastle implements Castle { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java index a4ffc1d28..f73ada9b0 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * - * OrcKing - * + * OrcKing. */ public class OrcKing implements King { diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java index 6792174f2..ae7c744be 100644 --- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java +++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKingdomFactory.java @@ -24,9 +24,7 @@ package com.iluwatar.abstractfactory; /** - * * OrcKingdomFactory concrete factory. - * */ public class OrcKingdomFactory implements KingdomFactory { diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/AllModemVisitor.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/AllModemVisitor.java index b5842cdf5..354c4db74 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/AllModemVisitor.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/AllModemVisitor.java @@ -24,9 +24,9 @@ package com.iluwatar.acyclicvisitor; /** - * All ModemVisitor interface extends all visitor interfaces. This interface - * provides ease of use when a visitor needs to visit all modem types. + * All ModemVisitor interface extends all visitor interfaces. This interface provides ease of use + * when a visitor needs to visit all modem types. */ -public interface AllModemVisitor extends ZoomVisitor, HayesVisitor{ +public interface AllModemVisitor extends ZoomVisitor, HayesVisitor { } diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/App.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/App.java index 3875d7a2a..866abc3b7 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/App.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/App.java @@ -24,30 +24,28 @@ package com.iluwatar.acyclicvisitor; /** - * The Acyclic Visitor pattern allows new functions to be added to existing class - * hierarchies without affecting those hierarchies, and without creating the dependency - * cycles that are inherent to the GoF Visitor pattern, by making the Visitor base class - * degenerate - *
- * In this example the visitor base class is {@link ModemVisitor}. The base class of the - * visited hierarchy is {@link Modem} and has two children {@link Hayes} and {@link Zoom} - * each one having its own visitor interface {@link HayesVisitor} and {@link ZoomVisitor} - * respectively. {@link ConfigureForUnixVisitor} and {@link ConfigureForDosVisitor} - * implement each derivative's visit method only if it is required + * The Acyclic Visitor pattern allows new functions to be added to existing class hierarchies + * without affecting those hierarchies, and without creating the dependency cycles that are inherent + * to the GoF Visitor pattern, by making the Visitor base class degenerate + * + *
In this example the visitor base class is {@link ModemVisitor}. The base class of the visited + * hierarchy is {@link Modem} and has two children {@link Hayes} and {@link Zoom} each one having + * its own visitor interface {@link HayesVisitor} and {@link ZoomVisitor} respectively. {@link + * ConfigureForUnixVisitor} and {@link ConfigureForDosVisitor} implement each derivative's visit + * method only if it is required */ public class App { - + /** - * Program's entry point + * Program's entry point. */ - - public static void main(String[] args) { + public static void main(String[] args) { var conUnix = new ConfigureForUnixVisitor(); var conDos = new ConfigureForDosVisitor(); - + var zoom = new Zoom(); var hayes = new Hayes(); - + hayes.accept(conDos); // Hayes modem with Dos configurator zoom.accept(conDos); // Zoom modem with Dos configurator hayes.accept(conUnix); // Hayes modem with Unix configurator diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForDosVisitor.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForDosVisitor.java index 8b64db8a7..f9df38529 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForDosVisitor.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForDosVisitor.java @@ -27,8 +27,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * ConfigureForDosVisitor class implements both zoom's and hayes' visit method - * for Dos manufacturer + * ConfigureForDosVisitor class implements both zoom's and hayes' visit method for Dos + * manufacturer. */ public class ConfigureForDosVisitor implements AllModemVisitor { diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForUnixVisitor.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForUnixVisitor.java index fb5a657d7..3d14eff8f 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForUnixVisitor.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ConfigureForUnixVisitor.java @@ -27,9 +27,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * ConfigureForUnixVisitor class implements zoom's visit method for Unix - * manufacturer, unlike traditional visitor pattern, this class may selectively implement - * visit for other modems. + * ConfigureForUnixVisitor class implements zoom's visit method for Unix manufacturer, unlike + * traditional visitor pattern, this class may selectively implement visit for other modems. */ public class ConfigureForUnixVisitor implements ZoomVisitor { diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Hayes.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Hayes.java index 586d72876..b49a6234c 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Hayes.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Hayes.java @@ -27,14 +27,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Hayes class implements its accept method + * Hayes class implements its accept method. */ public class Hayes extends Modem { - + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class); /** - * Accepts all visitors but honors only HayesVisitor + * Accepts all visitors but honors only HayesVisitor. */ @Override public void accept(ModemVisitor modemVisitor) { @@ -45,10 +45,9 @@ public class Hayes extends Modem { } } - + /** - * Hayes' modem's toString - * method + * Hayes' modem's toString method. */ @Override public String toString() { diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/HayesVisitor.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/HayesVisitor.java index 80dfc2320..59527d57b 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/HayesVisitor.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/HayesVisitor.java @@ -24,7 +24,7 @@ package com.iluwatar.acyclicvisitor; /** - * HayesVisitor interface + * HayesVisitor interface. */ public interface HayesVisitor extends ModemVisitor { void visit(Hayes hayes); diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Modem.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Modem.java index 9c1eb117e..201712dd1 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Modem.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Modem.java @@ -24,7 +24,7 @@ package com.iluwatar.acyclicvisitor; /** - * Modem abstract class + * Modem abstract class. */ public abstract class Modem { public abstract void accept(ModemVisitor modemVisitor); diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ModemVisitor.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ModemVisitor.java index a5baa7169..b4058f237 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ModemVisitor.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ModemVisitor.java @@ -24,9 +24,8 @@ package com.iluwatar.acyclicvisitor; /** - * ModemVisitor interface does not contain any visit methods so that it does not - * depend on the visited hierarchy. Each derivative's visit method is declared in - * its own visitor interface + * ModemVisitor interface does not contain any visit methods so that it does not depend on the + * visited hierarchy. Each derivative's visit method is declared in its own visitor interface */ public interface ModemVisitor { // Visitor is a degenerate base class for all visitors. diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Zoom.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Zoom.java index c624f9f5f..3fbaa38df 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Zoom.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/Zoom.java @@ -27,27 +27,26 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Zoom class implements its accept method + * Zoom class implements its accept method. */ public class Zoom extends Modem { - + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class); /** - * Accepts all visitors but honors only ZoomVisitor + * Accepts all visitors but honors only ZoomVisitor. */ @Override public void accept(ModemVisitor modemVisitor) { - if (modemVisitor instanceof ZoomVisitor) { + if (modemVisitor instanceof ZoomVisitor) { ((ZoomVisitor) modemVisitor).visit(this); } else { LOGGER.info("Only ZoomVisitor is allowed to visit Zoom modem"); } } - + /** - * Zoom modem's toString - * method + * Zoom modem's toString method. */ @Override public String toString() { diff --git a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ZoomVisitor.java b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ZoomVisitor.java index 707943884..fd54d8b21 100644 --- a/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ZoomVisitor.java +++ b/acyclic-visitor/src/main/java/com/iluwatar/acyclicvisitor/ZoomVisitor.java @@ -24,7 +24,7 @@ package com.iluwatar.acyclicvisitor; /** - * ZoomVisitor interface + * ZoomVisitor interface. */ public interface ZoomVisitor extends ModemVisitor { void visit(Zoom zoom); diff --git a/adapter/src/main/java/com/iluwatar/adapter/App.java b/adapter/src/main/java/com/iluwatar/adapter/App.java index 570cc8272..4e3755fb2 100644 --- a/adapter/src/main/java/com/iluwatar/adapter/App.java +++ b/adapter/src/main/java/com/iluwatar/adapter/App.java @@ -24,35 +24,28 @@ 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. * - *
- * 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. * - *
- * The Adapter ({@link FishingBoatAdapter}) converts the interface of the - * adaptee class ({@link FishingBoat}) into a suitable one expected by the - * client ({@link RowingBoat}). - * - *
- * The story of this implementation is this.
- * 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}.
+ *
The Adapter ({@link FishingBoatAdapter}) converts the interface of the adaptee class ({@link + * FishingBoat}) into a suitable one expected by the client ({@link RowingBoat}). * + *
The story of this implementation is this.
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 final class App {
- private App() { }
+ private App() {
+ }
/**
* Program entry point.
diff --git a/adapter/src/main/java/com/iluwatar/adapter/Captain.java b/adapter/src/main/java/com/iluwatar/adapter/Captain.java
index 1eb3aaa1a..b83b13429 100644
--- a/adapter/src/main/java/com/iluwatar/adapter/Captain.java
+++ b/adapter/src/main/java/com/iluwatar/adapter/Captain.java
@@ -24,14 +24,14 @@
package com.iluwatar.adapter;
/**
- * The Captain uses {@link RowingBoat} to sail.
- * This is the client in the pattern.
+ * The Captain uses {@link RowingBoat} to sail.
This is the client in the pattern.
*/
public final class Captain {
private RowingBoat rowingBoat;
- public Captain() { }
+ public Captain() {
+ }
public Captain(final RowingBoat boat) {
this.rowingBoat = boat;
diff --git a/adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java b/adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java
index 1dbf5eed3..123006c46 100644
--- a/adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java
+++ b/adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java
@@ -23,15 +23,13 @@
package com.iluwatar.adapter;
-import org.slf4j.Logger;
-
import static org.slf4j.LoggerFactory.getLogger;
+import org.slf4j.Logger;
+
/**
- *
- * Device class (adaptee in the pattern). We want to reuse this class.
- * Fishing boat moves by sailing.
- *
+ * Device class (adaptee in the pattern). We want to reuse this class. Fishing boat moves by
+ * sailing.
*/
final class FishingBoat {
diff --git a/adapter/src/main/java/com/iluwatar/adapter/FishingBoatAdapter.java b/adapter/src/main/java/com/iluwatar/adapter/FishingBoatAdapter.java
index 7aaacd3e5..5ccde5c53 100644
--- a/adapter/src/main/java/com/iluwatar/adapter/FishingBoatAdapter.java
+++ b/adapter/src/main/java/com/iluwatar/adapter/FishingBoatAdapter.java
@@ -24,10 +24,8 @@
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 {
diff --git a/adapter/src/main/java/com/iluwatar/adapter/RowingBoat.java b/adapter/src/main/java/com/iluwatar/adapter/RowingBoat.java
index 3b43da732..908036a3f 100644
--- a/adapter/src/main/java/com/iluwatar/adapter/RowingBoat.java
+++ b/adapter/src/main/java/com/iluwatar/adapter/RowingBoat.java
@@ -24,9 +24,7 @@
package com.iluwatar.adapter;
/**
- * The interface expected by the client.
- * A rowing boat is rowed to move.
- *
+ * The interface expected by the client.
A rowing boat is rowed to move.
*/
public interface RowingBoat {
diff --git a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/Aggregator.java b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/Aggregator.java
index dbed50fc6..25369f0e0 100644
--- a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/Aggregator.java
+++ b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/Aggregator.java
@@ -24,14 +24,13 @@
package com.iluwatar.aggregator.microservices;
import javax.annotation.Resource;
-
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
- * The aggregator aggregates calls on various micro-services, collects
- * data and further publishes them under a REST endpoint.
+ * The aggregator aggregates calls on various micro-services, collects data and further publishes
+ * them under a REST endpoint.
*/
@RestController
public class Aggregator {
diff --git a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/App.java b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/App.java
index ab4b11dcf..3c09c54be 100644
--- a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/App.java
+++ b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/App.java
@@ -27,13 +27,13 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
- * Spring Boot EntryPoint Class
+ * Spring Boot EntryPoint Class.
*/
@SpringBootApplication
public class App {
/**
- * Program entry point
+ * Program entry point.
*
* @param args command line args
*/
diff --git a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java
index 0fe68da17..93fbb2ee6 100644
--- a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java
+++ b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java
@@ -28,7 +28,6 @@ import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -44,7 +43,9 @@ public class ProductInformationClientImpl implements ProductInformationClient {
@Override
public String getProductTitle() {
String response = null;
- var request = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51515/information")).build();
+ var request =
+ HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51515/information"))
+ .build();
var client = HttpClient.newHttpClient();
try {
var httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
diff --git a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java
index fcd824de7..f64208539 100644
--- a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java
+++ b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java
@@ -28,7 +28,6 @@ import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -45,7 +44,9 @@ public class ProductInventoryClientImpl implements ProductInventoryClient {
public Integer getProductInventories() {
var response = "";
- var request = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51516/inventories")).build();
+ var request =
+ HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51516/inventories"))
+ .build();
var client = HttpClient.newHttpClient();
try {
var httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
@@ -55,10 +56,10 @@ public class ProductInventoryClientImpl implements ProductInventoryClient {
} catch (InterruptedException ie) {
LOGGER.error("InterruptedException Occurred", ie);
}
- if("".equalsIgnoreCase(response)) {
- return null;
+ if ("".equalsIgnoreCase(response)) {
+ return null;
} else {
- return Integer.parseInt(response);
+ return Integer.parseInt(response);
}
}
}
diff --git a/aggregator-microservices/aggregator-service/src/main/resources/application.properties b/aggregator-microservices/aggregator-service/src/main/resources/application.properties
index 35bbf3471..f9e29f5a7 100644
--- a/aggregator-microservices/aggregator-service/src/main/resources/application.properties
+++ b/aggregator-microservices/aggregator-service/src/main/resources/application.properties
@@ -20,5 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
-
server.port=50004
\ No newline at end of file
diff --git a/aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java b/aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java
index 59d790de2..28e8b8397 100644
--- a/aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java
+++ b/aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java
@@ -23,15 +23,15 @@
package com.iluwatar.aggregator.microservices;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.when;
+
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.Mockito.when;
-
/**
* Test Aggregation of domain objects
*/
diff --git a/aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java b/aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java
index 8306fd785..2accc013d 100644
--- a/aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java
+++ b/aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java
@@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
- * Controller providing endpoints to retrieve information about products
+ * Controller providing endpoints to retrieve information about products.
*/
@RestController
public class InformationController {
diff --git a/aggregator-microservices/information-microservice/src/main/resources/application.properties b/aggregator-microservices/information-microservice/src/main/resources/application.properties
index 6d8b8e84f..b953a61da 100644
--- a/aggregator-microservices/information-microservice/src/main/resources/application.properties
+++ b/aggregator-microservices/information-microservice/src/main/resources/application.properties
@@ -20,5 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
-
server.port=51515
\ No newline at end of file
diff --git a/aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java b/aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java
index 3f3f1b511..a7130957b 100644
--- a/aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java
+++ b/aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java
@@ -23,10 +23,10 @@
package com.iluwatar.information.microservice;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Test;
+
/**
* Test for Information Rest Controller
*/
diff --git a/aggregator-microservices/inventory-microservice/src/main/java/com/iluwatar/inventory/microservice/InventoryController.java b/aggregator-microservices/inventory-microservice/src/main/java/com/iluwatar/inventory/microservice/InventoryController.java
index 85eea4e9c..e3c3838f8 100644
--- a/aggregator-microservices/inventory-microservice/src/main/java/com/iluwatar/inventory/microservice/InventoryController.java
+++ b/aggregator-microservices/inventory-microservice/src/main/java/com/iluwatar/inventory/microservice/InventoryController.java
@@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
- * Controller providing endpoints to retrieve product inventories
+ * Controller providing endpoints to retrieve product inventories.
*/
@RestController
public class InventoryController {
diff --git a/aggregator-microservices/inventory-microservice/src/main/resources/application.properties b/aggregator-microservices/inventory-microservice/src/main/resources/application.properties
index cc863fd4f..9d2021f44 100644
--- a/aggregator-microservices/inventory-microservice/src/main/resources/application.properties
+++ b/aggregator-microservices/inventory-microservice/src/main/resources/application.properties
@@ -20,5 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
-
server.port=51516
\ No newline at end of file
diff --git a/aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java b/aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java
index 8933053d4..abf3fa6a4 100644
--- a/aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java
+++ b/aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java
@@ -23,10 +23,10 @@
package com.iluwatar.inventory.microservice;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Test;
+
/**
* Test Inventory Rest Controller
*/