classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] RFC: Genericize return type in PrinterStateReaso


From: Wolfgang Baer
Subject: [cp-patches] [generics] RFC: Genericize return type in PrinterStateReasons
Date: Sat, 14 Jan 2006 11:54:43 +0100
User-agent: Debian Thunderbird 1.0.7 (X11/20051017)

Hi,

as this is my first patch for the generics branch I would like a
comment if the patch is OK.

Also I would like to know if one should only genericize the API
or also (as I did in this patch) genericize the method body and
remove no longer needed stuff. I did this to get rid of a bunch
of eclipse warnings but maybe this is not wanted at this stage
as it might make merging harder.

Thanks,
Wolfgang

2006-01-14  Wolfgang Baer  <address@hidden>

        * javax/print/attribute/standard/PrinterStateReasons.java:
        Remove no longer needed import of Iterator.
        (printerStateReasonSet): Genericize return type and method body.
        (put): Remove no longer needed casts.

Index: PrinterStateReasons.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/print/attribute/standard/PrinterStateReasons.java,v
retrieving revision 1.2.2.5
diff -u -r1.2.2.5 PrinterStateReasons.java
--- PrinterStateReasons.java    10 Jan 2006 15:59:42 -0000      1.2.2.5
+++ PrinterStateReasons.java    14 Jan 2006 10:43:36 -0000
@@ -41,7 +41,6 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -139,16 +138,14 @@
    * @param severity the severity level for the constructed set.
    * @return The set of printer state reasons.
    */
-  public Set printerStateReasonSet(Severity severity)
+  public Set<PrinterStateReason> printerStateReasonSet(Severity severity)
   {
     if (severity == null)
       throw new NullPointerException("severity is null");
     
-    HashSet set = new HashSet();
-    Iterator it = entrySet().iterator();
-    while (it.hasNext())
+    HashSet<PrinterStateReason> set = new HashSet<PrinterStateReason>();
+    for (Map.Entry<PrinterStateReason,Severity> entry : entrySet())
       {
-        Map.Entry entry = (Map.Entry) it.next();
         if (entry.getValue().equals(severity))
           set.add(entry.getKey());
       }
@@ -178,7 +175,7 @@
     if (severity == null)
       throw new NullPointerException("severity is null");
     
-    return put((PrinterStateReason) reason, (Severity) severity);
+    return put(reason, severity);
   }   
   
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]