Skip to content

Commit 6e49fc0

Browse files
committed
Improved comments on visitor pattern example.
1 parent b12243b commit 6e49fc0

File tree

7 files changed

+37
-2
lines changed

7 files changed

+37
-2
lines changed

visitor/src/main/java/com/iluwatar/App.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
/**
44
*
5-
* Visitor pattern defines mechanism to apply operations (UnitVisitor) on nodes
6-
* (Unit) in hierarchy. New operations can be added without altering the node
5+
* Visitor pattern defines mechanism to apply operations on nodes
6+
* in hierarchy. New operations can be added without altering the node
77
* interface.
88
*
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+
*
914
*/
1015
public class App {
1116

visitor/src/main/java/com/iluwatar/Commander.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Commander
6+
*
7+
*/
38
public class Commander extends Unit {
49

510
public Commander(Unit... children) {

visitor/src/main/java/com/iluwatar/CommanderVisitor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* CommanderVisitor
6+
*
7+
*/
38
public class CommanderVisitor implements UnitVisitor {
49

510
@Override

visitor/src/main/java/com/iluwatar/Sergeant.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Sergeant
6+
*
7+
*/
38
public class Sergeant extends Unit {
49

510
public Sergeant(Unit... children) {

visitor/src/main/java/com/iluwatar/SergeantVisitor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* SergeantVisitor
6+
*
7+
*/
38
public class SergeantVisitor implements UnitVisitor {
49

510
@Override

visitor/src/main/java/com/iluwatar/Soldier.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Soldier
6+
*
7+
*/
38
public class Soldier extends Unit {
49

510
public Soldier(Unit... children) {

visitor/src/main/java/com/iluwatar/SoldierVisitor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* SoldierVisitor
6+
*
7+
*/
38
public class SoldierVisitor implements UnitVisitor {
49

510
@Override

0 commit comments

Comments
 (0)