You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2015/10/15 05:07:31 UTC
incubator-groovy git commit: Groovy-7574: Ranges: Make Range members
final (formatting only, closes #141)
Repository: incubator-groovy
Updated Branches:
refs/heads/master 74c422e41 -> 0be52a9fa
Groovy-7574: Ranges: Make Range members final (formatting only, closes #141)
Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/0be52a9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/0be52a9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/0be52a9f
Branch: refs/heads/master
Commit: 0be52a9fa6064d2c49586ea7b5d47386229b002f
Parents: 74c422e
Author: paulk <pa...@asert.com.au>
Authored: Thu Oct 15 13:07:14 2015 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Thu Oct 15 13:07:14 2015 +1000
----------------------------------------------------------------------
src/main/groovy/lang/EmptyRange.java | 26 +++++++++++++-------------
src/main/groovy/lang/IntRange.java | 30 +++++++++++++++---------------
src/main/groovy/lang/ObjectRange.java | 8 ++++----
3 files changed, 32 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/0be52a9f/src/main/groovy/lang/EmptyRange.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/EmptyRange.java b/src/main/groovy/lang/EmptyRange.java
index 56ec153..6af75d1 100644
--- a/src/main/groovy/lang/EmptyRange.java
+++ b/src/main/groovy/lang/EmptyRange.java
@@ -26,7 +26,7 @@ import java.util.*;
* Constructing Ranges like 0..<0
*/
public class EmptyRange extends AbstractList implements Range {
-
+
/**
* The value at which the range originates (may be <code>null</code>).
*/
@@ -34,11 +34,11 @@ public class EmptyRange extends AbstractList implements Range {
/**
* Creates a new {@link EmptyRange}.
- *
+ *
* @param at the value at which the range starts (may be <code>null</code>).
*/
public EmptyRange(Comparable at) {
- this.at = at;
+ this.at = at;
}
/**
@@ -57,7 +57,7 @@ public class EmptyRange extends AbstractList implements Range {
/**
* Never true for an empty range.
- *
+ *
* @return <code>false</code>
*/
public boolean isReverse() {
@@ -84,14 +84,14 @@ public class EmptyRange extends AbstractList implements Range {
* {@inheritDoc}
*/
public String toString() {
- return (null == at)
- ? "null..<null"
- : at.toString() + "..<" + at.toString();
+ return (null == at)
+ ? "null..<null"
+ : at.toString() + "..<" + at.toString();
}
/**
* Always 0 for an empty range.
- *
+ *
* @return 0
*/
public int size() {
@@ -100,7 +100,7 @@ public class EmptyRange extends AbstractList implements Range {
/**
* Always throws <code>IndexOutOfBoundsException</code> for an empty range.
- *
+ *
* @throws IndexOutOfBoundsException always
*/
public Object get(int index) {
@@ -133,7 +133,7 @@ public class EmptyRange extends AbstractList implements Range {
public boolean addAll(Collection c) {
throw new UnsupportedOperationException("cannot add to Empty Ranges");
}
-
+
/**
* Always throws <code>UnsupportedOperationException</code> for an empty range.
*
@@ -170,9 +170,9 @@ public class EmptyRange extends AbstractList implements Range {
throw new UnsupportedOperationException("cannot retainAll in Empty Ranges");
}
- /**
- * Always throws <code>UnsupportedOperationException</code> for an empty range.
- *
+ /**
+ * Always throws <code>UnsupportedOperationException</code> for an empty range.
+ *
* @throws UnsupportedOperationException
*/
public Object set(int index, Object element) {
http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/0be52a9f/src/main/groovy/lang/IntRange.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/IntRange.java b/src/main/groovy/lang/IntRange.java
index 7077ddd..1995244 100644
--- a/src/main/groovy/lang/IntRange.java
+++ b/src/main/groovy/lang/IntRange.java
@@ -30,13 +30,13 @@ import java.util.List;
/**
* Represents a list of Integer objects starting at a specified {@code from} value up (or down)
* to and potentially including a given {@code to} value.
- * <p>
+ * <p/>
* Instances of this class may be either inclusive aware or non-inclusive aware. See the
* relevant constructors for creating each type. Inclusive aware IntRange instances are
* suitable for use with Groovy's range indexing - in particular if the from or to values
* might be negative. This normally happens underneath the covers but is worth keeping
* in mind if creating these ranges yourself explicitly.
- * <p>
+ * <p/>
* Note: the design of this class might seem a little strange at first. It contains a Boolean
* field, {@code inclusive}, which can be {@code true}, {@code false} or {@code null}. This
* design is for backwards compatibility reasons. Groovy uses this class under the covers
@@ -45,7 +45,7 @@ import java.util.List;
* covers by the {@code new IntRange(x, y)} and {@code new IntRange(x, y-1)}. This turns
* out to be a lossy abstraction when x and/or y are negative values. Now the latter case
* is represented by {@code new IntRange(false, x, y)}.
- * <p>
+ * <p/>
* Note: This class is a copy of {@link ObjectRange} optimized for <code>int</code>. If you make any
* changes to this class, you might consider making parallel changes to {@link ObjectRange}.
*/
@@ -98,8 +98,7 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer> {
/**
* Not supported.
*
- * @throws java.lang.UnsupportedOperationException
- * always
+ * @throws java.lang.UnsupportedOperationException always
*/
public void remove() {
IntRange.this.remove(index);
@@ -127,9 +126,9 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer> {
/**
* If <code>true</code> or null, <code>to</code> is included in the range.
* If <code>false</code>, the range stops before the <code>to</code> value.
- *
+ * <p/>
* Null for non-inclusive-aware ranges (which are inclusive).
- *
+ * <p/>
* If true or false, the reverse flag is discarded.
*/
private final Boolean inclusive;
@@ -190,8 +189,8 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer> {
/**
* Creates a new inclusive aware <code>IntRange</code>.
*
- * @param from the first value in the range.
- * @param to the last value in the range.
+ * @param from the first value in the range.
+ * @param to the last value in the range.
* @param inclusive <code>true</code> if the to value is included in the range.
*/
public IntRange(boolean inclusive, int from, int to) {
@@ -209,7 +208,8 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer> {
* @return the calculated range information (with 1 added to the to value, ready for providing to subList
*/
public RangeInfo subListBorders(int size) {
- if (inclusive == null) throw new IllegalStateException("Should not call subListBorders on a non-inclusive aware IntRange");
+ if (inclusive == null)
+ throw new IllegalStateException("Should not call subListBorders on a non-inclusive aware IntRange");
int tempFrom = from;
if (tempFrom < 0) {
tempFrom += size;
@@ -228,11 +228,11 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer> {
* Determines if this object is equal to another object. Delegates to
* {@link AbstractList#equals(Object)} if <code>that</code> is anything
* other than an {@link IntRange}.
- * <p>
+ * <p/>
* It is not necessary to override <code>hashCode</code>, as
* {@link AbstractList#hashCode()} provides a suitable hash code.<p>
- * <p>
- * Note that equals is generally handled by {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#equals(List,List)}
+ * <p/>
+ * Note that equals is generally handled by {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#equals(List, List)}
* instead of this method.
*
* @param that the object to compare
@@ -414,7 +414,7 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer> {
int value = getFrom();
while (value <= getTo()) {
closure.call(Integer.valueOf(value));
- if((0L + value + step) >= Integer.MAX_VALUE) {
+ if ((0L + value + step) >= Integer.MAX_VALUE) {
break;
}
value = value + step;
@@ -423,7 +423,7 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer> {
int value = getTo();
while (value >= getFrom()) {
closure.call(Integer.valueOf(value));
- if((0L + value + step) <= Integer.MIN_VALUE) {
+ if ((0L + value + step) <= Integer.MIN_VALUE) {
break;
}
value = value + step;
http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/0be52a9f/src/main/groovy/lang/ObjectRange.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/ObjectRange.java b/src/main/groovy/lang/ObjectRange.java
index d2e3427..a1c0eba 100644
--- a/src/main/groovy/lang/ObjectRange.java
+++ b/src/main/groovy/lang/ObjectRange.java
@@ -33,7 +33,7 @@ import java.util.List;
/**
* Represents an inclusive list of objects from a value to a value using
* comparators.
- * <p>
+ *
* Note: This class is similar to {@link IntRange}. If you make any changes to this
* class, you might consider making parallel changes to {@link IntRange}.
*/
@@ -85,7 +85,7 @@ public class ObjectRange extends AbstractList implements Range {
* 'smaller' must not be larger than 'larger'.
*
* @param smaller start of the range, must no be larger than to when reverse != null
- * @param larger end of the range, must be larger than from when reverse != null
+ * @param larger end of the range, must be larger than from when reverse != null
* @param reverse direction of the range. If null, causes direction to be computed (can be expensive).
*/
private ObjectRange(Comparable smaller, Comparable larger, Boolean reverse) {
@@ -311,14 +311,14 @@ public class ObjectRange extends AbstractList implements Range {
char toNum = (Character) to;
size = toNum - fromNum + 1;
} else if (from instanceof BigDecimal || to instanceof BigDecimal ||
- from instanceof BigInteger || to instanceof BigInteger) {
+ from instanceof BigInteger || to instanceof BigInteger) {
// let's fast calculate the size
BigDecimal fromNum = new BigDecimal(from.toString());
BigDecimal toNum = new BigDecimal(to.toString());
BigInteger sizeNum = toNum.subtract(fromNum).add(new BigDecimal(1.0)).toBigInteger();
size = sizeNum.intValue();
} else {
- // let's lazily calculate the size
+ // let's brute-force calculate the size
size = 0;
Comparable first = from;
Comparable value = from;