-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathNode.java
More file actions
66 lines (54 loc) · 1.01 KB
/
Copy pathNode.java
File metadata and controls
66 lines (54 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package chapter8;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public interface Node
{
String name();
}
abstract class AbstractNode implements Node
{
private String aName;
protected AbstractNode(String pName)
{
aName = pName;
}
public String name()
{
return aName;
}
}
class File extends AbstractNode
{
public File(String pName)
{
super(pName);
}
}
class Directory extends AbstractNode implements Iterable<Node>
{
private final List<Node> aNodes;
public Directory(String pName, Node... pNodes)
{
super(pName);
aNodes = Arrays.asList(pNodes);
}
public Iterator<Node> iterator()
{
return Collections.unmodifiableList(aNodes).iterator();
}
}
class SymbolicLink extends AbstractNode
{
private final Node aNode;
public SymbolicLink(String pName, Node pNode)
{
super(pName);
aNode = pNode;
}
public String name()
{
return "Link to " + aNode.name();
}
}