@Override
    public int compareTo(DocumentState state) {
        int comp = gid.compareTo(state.gid);
        if (comp == 0) {
            if (docId != null) {
                if (state.docId != null) {
                    return docId.toString().compareTo(state.docId.toString());
                } else {
                    return 1;
                }
            } else if (state.docId != null){
                return -1;
            }
        }
        return comp;
    }
@author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentState.java