commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1130657 - in /commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook: AddressBook.java Person.java
Date Thu, 02 Jun 2011 17:09:46 GMT
Author: simonetripodi
Date: Thu Jun  2 17:09:46 2011
New Revision: 1130657

URL: http://svn.apache.org/viewvc?rev=1130657&view=rev
Log:
added generic to collections

Modified:
    commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/AddressBook.java
    commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/Person.java

Modified: commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/AddressBook.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/AddressBook.java?rev=1130657&r1=1130656&r2=1130657&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/AddressBook.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/AddressBook.java
Thu Jun  2 17:09:46 2011
@@ -26,7 +26,7 @@ import java.util.Iterator;
 public class AddressBook
 {
 
-    LinkedList people = new LinkedList();
+    LinkedList<Person> people = new LinkedList<Person>();
 
     public void addPerson( Person p )
     {
@@ -37,9 +37,9 @@ public class AddressBook
     {
         System.out.println( "Address book has " + people.size() + " entries" );
 
-        for ( Iterator i = people.iterator(); i.hasNext(); )
+        for ( Iterator<Person> i = people.iterator(); i.hasNext(); )
         {
-            Person p = (Person) i.next();
+            Person p = i.next();
             p.print();
         }
     }

Modified: commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/Person.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/Person.java?rev=1130657&r1=1130656&r2=1130657&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/Person.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/api/addressbook/src/main/java/org/apache/commons/digester3/examples/api/addressbook/Person.java
Thu Jun  2 17:09:46 2011
@@ -34,9 +34,9 @@ public class Person
 
     private String name;
 
-    private HashMap emails = new HashMap();
+    private HashMap<String, String> emails = new HashMap<String, String>();
 
-    private List addresses = new ArrayList();
+    private List<Address> addresses = new ArrayList<Address>();
 
     /**
      * A unique id for this person. Note that the Digester automatically converts the id
to an integer.
@@ -73,17 +73,17 @@ public class Person
         System.out.println( "  category=" + category );
         System.out.println( "  name=" + name );
 
-        for ( Iterator i = emails.keySet().iterator(); i.hasNext(); )
+        for ( Iterator<String> i = emails.keySet().iterator(); i.hasNext(); )
         {
-            String type = (String) i.next();
-            String address = (String) emails.get( type );
+            String type = i.next();
+            String address = emails.get( type );
 
             System.out.println( "  email (type " + type + ") : " + address );
         }
 
-        for ( Iterator i = addresses.iterator(); i.hasNext(); )
+        for ( Iterator<Address> i = addresses.iterator(); i.hasNext(); )
         {
-            Address addr = (Address) i.next();
+            Address addr = i.next();
             addr.print( System.out, 2 );
         }
     }



Mime
View raw message