/** {@inheritDoc} */ @Override public int compareTo(ProtocolVersion other) { if (null == mProtocol && null != other.mProtocol) { // null protocol sorts ahead of any alphabetic protocol. return -1; } else if (mProtocol != null) { if (null == other.mProtocol) { return 1; // they sort as 'less than' us since their protocol name is null. } int protoCmp = mProtocol.compareTo(other.mProtocol); if (0 != protoCmp) { return protoCmp; } } int majCmp = Integer.valueOf(getMajorVersion()).compareTo(other.getMajorVersion()); if (0 != majCmp) { return majCmp; } int minCmp = Integer.valueOf(getMinorVersion()).compareTo(other.getMinorVersion()); if (0 != minCmp) { return minCmp; } int revCmp = Integer.valueOf(getRevision()).compareTo(other.getRevision()); return revCmp; }
/** {@inheritDoc} */ @Override public boolean equals(Object other) { if (null == other) { return false; } else if (this == other) { return true; } else if (!(other instanceof ProtocolVersion)) { return false; } ProtocolVersion otherVer = (ProtocolVersion) other; if (!checkEquality(mProtocol, otherVer.mProtocol)) { return false; } return getMajorVersion() == otherVer.getMajorVersion() && getMinorVersion() == otherVer.getMinorVersion() && getRevision() == otherVer.getRevision(); }