1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.tree;
17
18 import static org.kuali.common.util.base.Precondition.checkNotNull;
19
20 import java.util.List;
21
22 public final class ImmutableNode<T> extends MutableNode<T> {
23
24 private static final String UOE_MSG = "not supported for immutable node's";
25
26 public static <T> ImmutableNode<T> copyOf(Node<T> node) {
27 return new ImmutableNode<T>(node);
28 }
29
30 public ImmutableNode(Node<T> node) {
31 checkNotNull(node, "node");
32 super.setElement(node.getElement());
33 List<Node<T>> children = node.getChildren();
34 for (Node<T> child : children) {
35 super.add(children.size(), copyOf(child));
36 }
37 }
38
39 @Override
40 public void setElement(T element) {
41 throw new UnsupportedOperationException(UOE_MSG);
42 }
43
44 @Override
45 public void add(List<MutableNode<T>> children) {
46 throw new UnsupportedOperationException(UOE_MSG);
47 }
48
49 @Override
50 public void add(MutableNode<T> child1, MutableNode<T> child2) {
51 throw new UnsupportedOperationException(UOE_MSG);
52 }
53
54 @Override
55 public void add(MutableNode<T> child1, MutableNode<T> child2, MutableNode<T> child3) {
56 throw new UnsupportedOperationException(UOE_MSG);
57 }
58
59 @Override
60 public void add(MutableNode<T> child1, MutableNode<T> child2, MutableNode<T> child3, MutableNode<T> child4) {
61 throw new UnsupportedOperationException(UOE_MSG);
62 }
63
64 @Override
65 public void add(MutableNode<T> child1, MutableNode<T> child2, MutableNode<T> child3, MutableNode<T> child4, MutableNode<T> child5) {
66 throw new UnsupportedOperationException(UOE_MSG);
67 }
68
69 @Override
70 public void add(MutableNode<T> child) {
71 throw new UnsupportedOperationException(UOE_MSG);
72 }
73
74 @Override
75 public void add(int index, MutableNode<T> child) {
76 throw new UnsupportedOperationException(UOE_MSG);
77 }
78
79 @Override
80 public void remove(MutableNode<T> child) {
81 throw new UnsupportedOperationException(UOE_MSG);
82 }
83
84 @Override
85 public void remove(int index) {
86 throw new UnsupportedOperationException(UOE_MSG);
87 }
88
89 @Override
90 public void removeAllChildren() {
91 throw new UnsupportedOperationException(UOE_MSG);
92 }
93
94 @Override
95 public void removeFromParent() {
96 throw new UnsupportedOperationException(UOE_MSG);
97 }
98
99 }