1 package fr.ifremer.quadrige3.synchro.vo;
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 import com.google.common.collect.Lists;
27
28 import java.io.Serializable;
29 import java.text.Collator;
30 import java.util.List;
31
32
33
34
35
36
37 public class SynchroTableMetaVO implements Serializable, Comparable<SynchroTableMetaVO> {
38
39 private final String name;
40
41 private final boolean root;
42
43 private final boolean updatable;
44
45 private final boolean data;
46
47 private boolean toUpdate;
48
49
50
51
52 private final transient List<SynchroTableMetaVO> children;
53
54 public SynchroTableMetaVO(String name, boolean root, boolean updatable, boolean data) {
55 this.name = name;
56 this.root = root;
57 this.updatable = updatable;
58 this.data = data;
59 this.children = Lists.newArrayList();
60 }
61
62 public SynchroTableMetaVO(SynchroTableMetaVO tableMeta) {
63 this(tableMeta.getName(), tableMeta.isRoot(), tableMeta.isUpdatable(), tableMeta.isData());
64 }
65
66 public String getName() {
67 return name;
68 }
69
70 public boolean isRoot() {
71 return root;
72 }
73
74 public boolean isUpdatable() {
75 return updatable;
76 }
77
78 public boolean isData() {
79 return data;
80 }
81
82 public List<SynchroTableMetaVO> getChildren() {
83 return children;
84 }
85
86 public void addChildren(SynchroTableMetaVO children) {
87 this.children.add(children);
88 }
89
90 @Override
91 public boolean equals(Object o) {
92 if (this == o)
93 return true;
94 if (o == null || getClass() != o.getClass())
95 return false;
96
97 SynchroTableMetaVO that = (SynchroTableMetaVO) o;
98
99 return name.equals(that.name);
100 }
101
102 @Override
103 public int hashCode() {
104 return name.hashCode();
105 }
106
107 @Override
108 public int compareTo(SynchroTableMetaVO that) {
109 if (this == that)
110 return 0;
111 if (that == null)
112 return -1;
113
114 return Collator.getInstance().compare(this.getName(), that.getName());
115 }
116
117 @Override
118 public String toString() {
119 return getName();
120 }
121
122 public String toExtendedString() {
123 return getName() + (isRoot() && isUpdatable() ? " (root & updatable)" : isRoot() ? " (root)" : isUpdatable() ? " (updatable)" : "")
124 + (isData() ? " (data)" : " (referential)");
125 }
126
127 public boolean isToUpdate() {
128 return toUpdate;
129 }
130
131 public SynchroTableMetaVO setToUpdate(boolean toUpdate) {
132 this.toUpdate = toUpdate;
133 return this;
134 }
135 }