public Diff getDiff(ClusterState other) {
Diff diff = new Diff();
if (version != other.version) {
diff.add(new Diff.Entry("version", version, other.version));
}
if (!state.equals(other.state)) {
diff.add(new Diff.Entry("cluster", state, other.state));
}
if (distributionBits != other.distributionBits) {
diff.add(new Diff.Entry("bits", distributionBits, other.distributionBits));
}
if (official != other.official) {
diff.add(new Diff.Entry("official", official, other.official));
}
for (NodeType type : NodeType.getTypes()) {
Diff typeDiff = new Diff();
int maxCount = Math.max(getNodeCount(type), other.getNodeCount(type));
for (int i = 0; i < maxCount; i++) {
Node n = new Node(type, i);
Diff d = getNodeState(n).getDiff(other.getNodeState(n));
if (d.differs()) {
typeDiff.add(new Diff.Entry(i, d));
}
}
if (typeDiff.differs()) {
diff.add(new Diff.Entry(type, typeDiff).splitLine());
}
}
return diff;
}