Don't assign parameter

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1565243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2014-02-06 13:37:12 +00:00
parent f27c439c8d
commit 32a260ff46
1 changed files with 7 additions and 6 deletions

View File

@ -140,25 +140,26 @@ public final class Range<T> implements Serializable {
* *
* @param element1 the first element, not null * @param element1 the first element, not null
* @param element2 the second element, not null * @param element2 the second element, not null
* @param comparator the comparator to be used, null for natural ordering * @param comp the comparator to be used, null for natural ordering
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Range(final T element1, final T element2, Comparator<T> comparator) { private Range(final T element1, final T element2, final Comparator<T> comp) {
if (element1 == null || element2 == null) { if (element1 == null || element2 == null) {
throw new IllegalArgumentException("Elements in a range must not be null: element1=" + throw new IllegalArgumentException("Elements in a range must not be null: element1=" +
element1 + ", element2=" + element2); element1 + ", element2=" + element2);
} }
if (comparator == null) { if (comp == null) {
comparator = ComparableComparator.INSTANCE; this.comparator = ComparableComparator.INSTANCE;
} else {
this.comparator = comp;
} }
if (comparator.compare(element1, element2) < 1) { if (this.comparator.compare(element1, element2) < 1) {
this.minimum = element1; this.minimum = element1;
this.maximum = element2; this.maximum = element2;
} else { } else {
this.minimum = element2; this.minimum = element2;
this.maximum = element1; this.maximum = element1;
} }
this.comparator = comparator;
} }
// Accessors // Accessors