/** * Clones this object. * * @return clone of this object */ public PairOfStringLong clone() { return new PairOfStringLong(this.leftElement, this.rightElement); }
/** * Creates a pair. * * @param left the left element * @param right the right element */ public PairOfStringLong(String left, long right) { set(left, right); }
/** * Checks two pairs for equality. * * @param obj object for comparison * @return <code>true</code> if <code>obj</code> is equal to this object, <code>false</code> * otherwise */ public boolean equals(Object obj) { PairOfStringLong pair = (PairOfStringLong) obj; return leftElement.equals(pair.getLeftElement()) && rightElement == pair.getRightElement(); }
/** * Defines a natural sort order for pairs. Pairs are sorted first by the left element, and then by * the right element. * * @return a value less than zero, a value greater than zero, or zero if this pair should be * sorted before, sorted after, or is equal to <code>obj</code>. */ public int compareTo(PairOfStringLong pair) { String pl = pair.getLeftElement(); long pr = pair.getRightElement(); if (leftElement.equals(pl)) { if (rightElement == pr) return 0; return rightElement < pr ? -1 : 1; } return leftElement.compareTo(pl); }
public static PairOfStringLong of(String left, long right) { return new PairOfStringLong(left, right); }