Resolves checkstyle errors for abstract-document abstract-factory acyclic-visitor adapter aggregator-microservices (#1080)
* Reduces checkstyle errors in abstract-document * Reduces checkstyle errors in abstract-factory * Reduces checkstyle errors in acyclic-visitor * Reduces checkstyle errors in adapter * Reduces checkstyle errors in aggregator-microservices
This commit is contained in:
committed by
Ilkka Seppälä
parent
390795154f
commit
1e76d91929
@ -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 {
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>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
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -24,7 +24,7 @@
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
* HayesVisitor interface
|
||||
* HayesVisitor interface.
|
||||
*/
|
||||
public interface HayesVisitor extends ModemVisitor {
|
||||
void visit(Hayes hayes);
|
||||
|
@ -24,7 +24,7 @@
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
* Modem abstract class
|
||||
* Modem abstract class.
|
||||
*/
|
||||
public abstract class Modem {
|
||||
public abstract void accept(ModemVisitor modemVisitor);
|
||||
|
@ -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.
|
||||
|
@ -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() {
|
||||
|
@ -24,7 +24,7 @@
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
* ZoomVisitor interface
|
||||
* ZoomVisitor interface.
|
||||
*/
|
||||
public interface ZoomVisitor extends ModemVisitor {
|
||||
void visit(Zoom zoom);
|
||||
|
Reference in New Issue
Block a user