public int compareTo(KeyCount other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; KeyCount typedOther = (KeyCount) other; lastComparison = Boolean.valueOf(isSetKey()).compareTo(typedOther.isSetKey()); if (lastComparison != 0) { return lastComparison; } if (isSetKey()) { lastComparison = TBaseHelper.compareTo(this.key, typedOther.key); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetCount()).compareTo(typedOther.isSetCount()); if (lastComparison != 0) { return lastComparison; } if (isSetCount()) { lastComparison = TBaseHelper.compareTo(this.count, typedOther.count); if (lastComparison != 0) { return lastComparison; } } return 0; }