commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r770105 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/math/ java/org/apache/commons/lang/text/ test/org/apache/commons/lang/math/
Date Thu, 30 Apr 2009 08:08:49 GMT
Author: bayard
Date: Thu Apr 30 08:08:48 2009
New Revision: 770105

URL: http://svn.apache.org/viewvc?rev=770105&view=rev
Log:
Applying a set of updates for new Java features from Hendrik Maryns in LANG-336

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java?rev=770105&r1=770104&r2=770105&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java Thu Apr
30 08:08:48 2009
@@ -33,7 +33,7 @@
  * @since 2.0
  * @version $Id$
  */
-public final class Fraction extends Number implements Comparable {
+public final class Fraction extends Number implements Comparable<Fraction> {
 
     /**
      * Required for serialization support. Lang version 2.0.
@@ -867,13 +867,12 @@
      * with equals, because, for example, equals treats 1/2 and 2/4 as
      * different, whereas compareTo treats them as equal.
      *
-     * @param object  the object to compare to
+     * @param other  the object to compare to
      * @return -1 if this is less, 0 if equal, +1 if greater
      * @throws ClassCastException if the object is not a <code>Fraction</code>
      * @throws NullPointerException if the object is <code>null</code>
      */
-    public int compareTo(Object object) {
-        Fraction other = (Fraction) object;
+    public int compareTo(Fraction other) {
         if (this==other) {
             return 0;
         }

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java?rev=770105&r1=770104&r2=770105&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java Thu Apr
30 08:08:48 2009
@@ -119,7 +119,7 @@
             }
         }
         
-        int compare = ((Comparable) num1).compareTo(num2);
+        int compare = ((Comparable<Number>) num1).compareTo(num2);
         if (compare == 0) {
             this.min = num1;
             this.max = num1;
@@ -176,8 +176,8 @@
         if (number.getClass() != min.getClass()) {
             throw new IllegalArgumentException("The number must be of the same type as the
range numbers");
         }
-        int compareMin = ((Comparable) min).compareTo(number);
-        int compareMax = ((Comparable) max).compareTo(number);
+        int compareMin = ((Comparable<Number>) min).compareTo(number);
+        int compareMax = ((Comparable<Number>) max).compareTo(number);
         return compareMin <= 0 && compareMax >= 0;
     }
 

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java?rev=770105&r1=770104&r2=770105&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java Thu
Apr 30 08:08:48 2009
@@ -458,8 +458,8 @@
     public List<String> getTokenList() {
         checkTokenized();
         List<String> list = new ArrayList<String>(tokens.length);
-        for (int i = 0; i < tokens.length; i++) {
-            list.add(tokens[i]);
+        for (String element : tokens) {
+            list.add(element);
         }
         return list;
     }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java?rev=770105&r1=770104&r2=770105&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java (original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java Thu
Apr 30 08:08:48 2009
@@ -1264,11 +1264,6 @@
             fail("expecting NullPointerException");
         } catch (NullPointerException ex) {}
         
-        try {
-            f1.compareTo(new Object());
-            fail("expecting ClassCastException");
-        } catch (ClassCastException ex) {}
-        
         f2 = Fraction.getFraction(2, 5);
         assertTrue(f1.compareTo(f2) > 0);
         assertTrue(f2.compareTo(f2) == 0);



Mime
View raw message