@Override public int compareTo(FieldValue fieldValue) { int comp = super.compareTo(fieldValue); if (comp != 0) { return comp; } //types are equal, this must be of this type Document otherValue = (Document) fieldValue; comp = getId().compareTo(otherValue.getId()); if (comp != 0) { return comp; } comp = header.compareTo(otherValue.header); if (comp != 0) { return comp; } comp = body.compareTo(otherValue.body); return comp; }
@Override public int compareTo(FieldValue obj) { int cmp = super.compareTo(obj); if (cmp != 0) { return cmp; } Struct rhs = (Struct)obj; cmp = values.size() - rhs.values.size(); if (cmp != 0) { return cmp; } StructDataType type = getDataType(); for (Field field : type.getFields()) { FieldValue lhsField = getFieldValue(field); FieldValue rhsField = rhs.getFieldValue(field); if (lhsField != null && rhsField != null) { cmp = lhsField.compareTo(rhsField); if (cmp != 0) { return cmp; } } else if (lhsField != null || rhsField != null) { return (lhsField != null ? -1 : 1); } } return 0; }