X Tutup
Skip to content

Commit d220a07

Browse files
committed
iluwatar#107 Improve JavaDoc for Visitor example
1 parent 35e1afd commit d220a07

File tree

2 files changed

+50
-41
lines changed

2 files changed

+50
-41
lines changed
Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
package com.iluwatar.visitor;
2-
3-
/**
4-
*
5-
* Visitor pattern defines mechanism to apply operations on nodes
6-
* in hierarchy. New operations can be added without altering the node
7-
* interface.
8-
*
9-
* In this example there is a unit hierarchy beginning from Commander.
10-
* This hierarchy is traversed by visitors. SoldierVisitor applies
11-
* its operation on Soldiers, SergeantVisitor on Sergeants and so
12-
* on.
13-
*
14-
*/
15-
public class App {
16-
17-
public static void main(String[] args) {
18-
19-
Commander commander = new Commander(new Sergeant(new Soldier(),
20-
new Soldier(), new Soldier()), new Sergeant(new Soldier(),
21-
new Soldier(), new Soldier()));
22-
commander.accept(new SoldierVisitor());
23-
commander.accept(new SergeantVisitor());
24-
commander.accept(new CommanderVisitor());
25-
26-
}
27-
}
1+
package com.iluwatar.visitor;
2+
3+
/**
4+
*
5+
* Visitor pattern defines mechanism to apply operations on nodes
6+
* in hierarchy. New operations can be added without altering the node
7+
* interface.
8+
* <p>
9+
* In this example there is a unit hierarchy beginning from {@link Commander}.
10+
* This hierarchy is traversed by visitors. {@link SoldierVisitor} applies
11+
* its operation on {@link Soldier}s, {@link SergeantVisitor} on {@link Sergeant}s and so
12+
* on.
13+
*
14+
*/
15+
public class App {
16+
17+
/**
18+
* Program entry point
19+
* @param args command line args
20+
*/
21+
public static void main(String[] args) {
22+
23+
Commander commander = new Commander(new Sergeant(new Soldier(),
24+
new Soldier(), new Soldier()), new Sergeant(new Soldier(),
25+
new Soldier(), new Soldier()));
26+
commander.accept(new SoldierVisitor());
27+
commander.accept(new SergeantVisitor());
28+
commander.accept(new CommanderVisitor());
29+
30+
}
31+
}
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
package com.iluwatar.visitor;
2-
3-
import org.junit.Test;
4-
5-
import com.iluwatar.visitor.App;
6-
7-
public class AppTest {
8-
9-
@Test
10-
public void test() {
11-
String[] args = {};
12-
App.main(args);
13-
}
14-
}
1+
package com.iluwatar.visitor;
2+
3+
import org.junit.Test;
4+
5+
import com.iluwatar.visitor.App;
6+
7+
/**
8+
*
9+
* Application test
10+
*
11+
*/
12+
public class AppTest {
13+
14+
@Test
15+
public void test() {
16+
String[] args = {};
17+
App.main(args);
18+
}
19+
}

0 commit comments

Comments
 (0)
X Tutup