commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r892136 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang3/builder/CompareToBuilder.java
Date Fri, 18 Dec 2009 05:04:11 GMT
Author: sebb
Date: Fri Dec 18 05:04:11 2009
New Revision: 892136

URL: http://svn.apache.org/viewvc?rev=892136&view=rev
Log:
LANG-568 - @SuppressWarnings("unchecked") is used too generally
Partial fix - some warnings remain to be addressed

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang3/builder/CompareToBuilder.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang3/builder/CompareToBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang3/builder/CompareToBuilder.java?rev=892136&r1=892135&r2=892136&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang3/builder/CompareToBuilder.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang3/builder/CompareToBuilder.java
Fri Dec 18 05:04:11 2009
@@ -438,7 +438,6 @@
      *  with <code>lhs</code>
      * @since 2.0
      */
-    @SuppressWarnings("unchecked")
     public CompareToBuilder append(Object lhs, Object rhs, Comparator<?> comparator)
{
         if (comparison != 0) {
             return this;
@@ -482,9 +481,13 @@
         } else {
             // the simple case, not an array, just test the element
             if (comparator == null) {
-                comparison = ((Comparable) lhs).compareTo(rhs);
+                @SuppressWarnings("unchecked") // assume this can be done; if not throw CCE
as per Javadoc
+                final Comparable<Object> comparable = (Comparable<Object>) lhs;
+                comparison = comparable.compareTo(rhs);
             } else {
-                comparison = ((Comparator) comparator).compare(lhs, rhs);
+                @SuppressWarnings("unchecked") // assume this can be done; if not throw CCE
as per Javadoc
+                final Comparator<Object> comparator2 = (Comparator<Object>) comparator;
+                comparison = comparator2.compare(lhs, rhs);
             }
         }
         return this;



Mime
View raw message