commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r829352 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/builder/ test/org/apache/commons/lang/builder/
Date Sat, 24 Oct 2009 12:08:55 GMT
Author: scolebourne
Date: Sat Oct 24 12:08:55 2009
New Revision: 829352

URL: http://svn.apache.org/viewvc?rev=829352&view=rev
Log:
Apply generics

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/ToStringStyle.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/CompareToBuilderTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java?rev=829352&r1=829351&r2=829352&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/CompareToBuilder.java
Sat Oct 24 12:08:55 2009
@@ -438,7 +438,8 @@
      *  with <code>lhs</code>
      * @since 2.0
      */
-    public CompareToBuilder append(Object lhs, Object rhs, Comparator comparator) {
+    @SuppressWarnings("unchecked")
+    public CompareToBuilder append(Object lhs, Object rhs, Comparator<?> comparator)
{
         if (comparison != 0) {
             return this;
         }
@@ -483,7 +484,7 @@
             if (comparator == null) {
                 comparison = ((Comparable) lhs).compareTo(rhs);
             } else {
-                comparison = comparator.compare(lhs, rhs);
+                comparison = ((Comparator) comparator).compare(lhs, rhs);
             }
         }
         return this;

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java?rev=829352&r1=829351&r2=829352&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
Sat Oct 24 12:08:55 2009
@@ -179,7 +179,7 @@
         try {
             register(object);
             Field[] fields = clazz.getDeclaredFields();
-            List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields)
: Collections.EMPTY_LIST;
+            List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields)
: Collections.<String>emptyList();
             AccessibleObject.setAccessible(fields, true);
             for (Field field : fields) {
                 if (!excludedFieldList.contains(field.getName())

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/ToStringStyle.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/ToStringStyle.java?rev=829352&r1=829351&r2=829352&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/ToStringStyle.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/ToStringStyle.java
Sat Oct 24 12:08:55 2009
@@ -461,18 +461,18 @@
         register(value);
 
         try {
-            if (value instanceof Collection) {
+            if (value instanceof Collection<?>) {
                 if (detail) {
-                    appendDetail(buffer, fieldName, (Collection) value);
+                    appendDetail(buffer, fieldName, (Collection<?>) value);
                 } else {
-                    appendSummarySize(buffer, fieldName, ((Collection) value).size());
+                    appendSummarySize(buffer, fieldName, ((Collection<?>) value).size());
                 }
     
-            } else if (value instanceof Map) {
+            } else if (value instanceof Map<?, ?>) {
                 if (detail) {
-                    appendDetail(buffer, fieldName, (Map) value);
+                    appendDetail(buffer, fieldName, (Map<?, ?>) value);
                 } else {
-                    appendSummarySize(buffer, fieldName, ((Map) value).size());
+                    appendSummarySize(buffer, fieldName, ((Map<?, ?>) value).size());
                 }
     
             } else if (value instanceof long[]) {
@@ -587,7 +587,7 @@
      * @param coll  the <code>Collection</code> to add to the
      *  <code>toString</code>, not <code>null</code>
      */
-    protected void appendDetail(StringBuffer buffer, String fieldName, Collection coll) {
+    protected void appendDetail(StringBuffer buffer, String fieldName, Collection<?>
coll) {
         buffer.append(coll);
     }
 
@@ -599,7 +599,7 @@
      * @param map  the <code>Map</code> to add to the <code>toString</code>,
      *  not <code>null</code>
      */
-    protected void appendDetail(StringBuffer buffer, String fieldName, Map map) {
+    protected void appendDetail(StringBuffer buffer, String fieldName, Map<?, ?> map)
{
         buffer.append(map);
     }
 
@@ -1570,7 +1570,7 @@
      * @param cls  the <code>Class</code> to get the short name of
      * @return the short name
      */
-    protected String getShortClassName(Class cls) {
+    protected String getShortClassName(Class<?> cls) {
         return ClassUtils.getShortClassName(cls);
     }
 

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/CompareToBuilderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/CompareToBuilderTest.java?rev=829352&r1=829351&r2=829352&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/CompareToBuilderTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/CompareToBuilderTest.java
Sat Oct 24 12:08:55 2009
@@ -57,7 +57,7 @@
 
     //-----------------------------------------------------------------------
 
-    static class TestObject implements Comparable {
+    static class TestObject implements Comparable<TestObject> {
         private int a;
         public TestObject(int a) {
             this.a = a;
@@ -81,8 +81,7 @@
         public int getA() {
             return a;
         }
-        public int compareTo(Object o) {
-            TestObject rhs = (TestObject) o;
+        public int compareTo(TestObject rhs) {
             return (a < rhs.a) ? -1 : (a > rhs.a) ? +1 : 0;
         }
     }



Mime
View raw message