Enhancing code format
This commit is contained in:
@ -23,28 +23,17 @@
|
||||
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
|
||||
* 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 Hayes}
|
||||
* and {@link ZoomVisitor} respectively.
|
||||
* {@link ConfigureForUnixVisitor} and
|
||||
* {@link ConfigureForDosVisitor} implement
|
||||
* each derivative's visit method
|
||||
* only if it is required
|
||||
* 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 Hayes} and {@link ZoomVisitor}
|
||||
* respectively. {@link ConfigureForUnixVisitor} and {@link ConfigureForDosVisitor}
|
||||
* implement each derivative's visit method only if it is required
|
||||
*/
|
||||
|
||||
public class App {
|
||||
|
||||
/**
|
||||
|
@ -26,12 +26,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CongigureForDosVisitor class
|
||||
* implements both zoom's and
|
||||
* hayes' visit method for Dos
|
||||
* manufacturer
|
||||
* CongigureForDosVisitor class implements both zoom's and hayes' visit method
|
||||
* for Dos manufacturer
|
||||
*/
|
||||
|
||||
public class ConfigureForDosVisitor implements ModemVisitor, HayesVisitor, ZoomVisitor {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigureForDosVisitor.class);
|
||||
|
@ -26,9 +26,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CongigureForDosVisitor class
|
||||
* implements both zoom's visit
|
||||
* method for Unix manufacturer
|
||||
* CongigureForDosVisitor class implements both zoom's visit method for Unix
|
||||
* manufacturer
|
||||
*/
|
||||
public class ConfigureForUnixVisitor implements ModemVisitor, ZoomVisitor {
|
||||
|
||||
|
@ -26,10 +26,8 @@ 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);
|
||||
|
@ -25,7 +25,6 @@ package com.iluwatar.acyclicvisitor;
|
||||
/**
|
||||
* Modem abstract class
|
||||
*/
|
||||
|
||||
public abstract class Modem {
|
||||
public abstract void accept(ModemVisitor modemVisitor);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ package com.iluwatar.acyclicvisitor;
|
||||
/**
|
||||
* ZoomVisitor interface
|
||||
*/
|
||||
|
||||
public interface ModemVisitor {
|
||||
// Visitor is a degenerate base class for all visitors.
|
||||
}
|
||||
|
@ -26,10 +26,8 @@ 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);
|
||||
|
@ -25,7 +25,6 @@ package com.iluwatar.acyclicvisitor;
|
||||
/**
|
||||
* ZoomVisitor interface
|
||||
*/
|
||||
|
||||
public interface ZoomVisitor {
|
||||
void visit(Zoom zoom);
|
||||
}
|
||||
|
Reference in New Issue
Block a user