/** * Clones this object. * * @return clone of this object */ @Override public PairOfFloatString clone() { return new PairOfFloatString(this.leftElement, this.rightElement); }
/** * Creates a pair. * * @param left the left element * @param right the right element */ public PairOfFloatString(float left, String 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 */ @Override public boolean equals(Object obj) { PairOfFloatString pair = (PairOfFloatString) obj; return rightElement.equals(pair.getRightElement()) && leftElement == pair.getLeftElement(); }
/** * 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(PairOfFloatString pair) { String pr = pair.getRightElement(); float pl = pair.getLeftElement(); if (leftElement == pl) { if (rightElement.equals(pr)) return 0; return rightElement.compareTo(pr); } return leftElement < pl ? -1 : 1; }