#107 Improve JavaDoc for Visitor example
This commit is contained in:
@ -1,27 +1,31 @@
|
|||||||
package com.iluwatar.visitor;
|
package com.iluwatar.visitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Visitor pattern defines mechanism to apply operations on nodes
|
* Visitor pattern defines mechanism to apply operations on nodes
|
||||||
* in hierarchy. New operations can be added without altering the node
|
* in hierarchy. New operations can be added without altering the node
|
||||||
* interface.
|
* interface.
|
||||||
*
|
* <p>
|
||||||
* In this example there is a unit hierarchy beginning from Commander.
|
* In this example there is a unit hierarchy beginning from {@link Commander}.
|
||||||
* This hierarchy is traversed by visitors. SoldierVisitor applies
|
* This hierarchy is traversed by visitors. {@link SoldierVisitor} applies
|
||||||
* its operation on Soldiers, SergeantVisitor on Sergeants and so
|
* its operation on {@link Soldier}s, {@link SergeantVisitor} on {@link Sergeant}s and so
|
||||||
* on.
|
* on.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
/**
|
||||||
|
* Program entry point
|
||||||
Commander commander = new Commander(new Sergeant(new Soldier(),
|
* @param args command line args
|
||||||
new Soldier(), new Soldier()), new Sergeant(new Soldier(),
|
*/
|
||||||
new Soldier(), new Soldier()));
|
public static void main(String[] args) {
|
||||||
commander.accept(new SoldierVisitor());
|
|
||||||
commander.accept(new SergeantVisitor());
|
Commander commander = new Commander(new Sergeant(new Soldier(),
|
||||||
commander.accept(new CommanderVisitor());
|
new Soldier(), new Soldier()), new Sergeant(new Soldier(),
|
||||||
|
new Soldier(), new Soldier()));
|
||||||
}
|
commander.accept(new SoldierVisitor());
|
||||||
}
|
commander.accept(new SergeantVisitor());
|
||||||
|
commander.accept(new CommanderVisitor());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
package com.iluwatar.visitor;
|
package com.iluwatar.visitor;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.iluwatar.visitor.App;
|
import com.iluwatar.visitor.App;
|
||||||
|
|
||||||
public class AppTest {
|
/**
|
||||||
|
*
|
||||||
@Test
|
* Application test
|
||||||
public void test() {
|
*
|
||||||
String[] args = {};
|
*/
|
||||||
App.main(args);
|
public class AppTest {
|
||||||
}
|
|
||||||
}
|
@Test
|
||||||
|
public void test() {
|
||||||
|
String[] args = {};
|
||||||
|
App.main(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user