commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1164178 - in /commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain: Catalog.java CatalogFactory.java impl/CatalogBase.java
Date Thu, 01 Sep 2011 17:17:47 GMT
Author: simonetripodi
Date: Thu Sep  1 17:17:47 2011
New Revision: 1164178

URL: http://svn.apache.org/viewvc?rev=1164178&view=rev
Log:
added generics to Command<?> catalog

Modified:
    commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/Catalog.java
    commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/CatalogFactory.java
    commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/impl/CatalogBase.java

Modified: commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/Catalog.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/Catalog.java?rev=1164178&r1=1164177&r2=1164178&view=diff
==============================================================================
--- commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/Catalog.java
(original)
+++ commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/Catalog.java
Thu Sep  1 17:17:47 2011
@@ -50,7 +50,7 @@ public interface Catalog {
      * @param command {@link Command} or {@link Chain} to be returned
      *  for later lookups on this name
      */
-    void addCommand(String name, Command<? extends Context> command);
+    <C extends Context> void addCommand(String name, Command<C> command);
 
 
     /**
@@ -61,7 +61,7 @@ public interface Catalog {
      *  should be retrieved
      * @return The Command associated with the specified name.
      */
-    Command getCommand(String name);
+    <C extends Context> Command<C> getCommand(String name);
 
 
 

Modified: commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/CatalogFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/CatalogFactory.java?rev=1164178&r1=1164177&r2=1164178&view=diff
==============================================================================
--- commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/CatalogFactory.java
(original)
+++ commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/CatalogFactory.java
Thu Sep  1 17:17:47 2011
@@ -122,7 +122,7 @@ public abstract class CatalogFactory {
      *
      * @since Chain 1.1
      */
-    public Command getCommand(String commandID) {
+    public <C extends Context> Command<C> getCommand(String commandID) {
 
         String commandName = commandID;
         String catalogName = null;

Modified: commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/impl/CatalogBase.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/impl/CatalogBase.java?rev=1164178&r1=1164177&r2=1164178&view=diff
==============================================================================
--- commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/impl/CatalogBase.java
(original)
+++ commons/proper/chain/branches/version-2.0-work/src/main/java/org/apache/commons/chain/impl/CatalogBase.java
Thu Sep  1 17:17:47 2011
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.commons.chain.Catalog;
 import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
 
 
 /**
@@ -44,7 +45,7 @@ public class CatalogBase implements Cata
     /**
      * <p>The map of named {@link Command}s, keyed by name.
      */
-    protected Map<String, Command> commands = new ConcurrentHashMap<String, Command>();
+    protected Map<String, Command<? extends Context>> commands = new ConcurrentHashMap<String,
Command<? extends Context>>();
 
 
     // --------------------------------------------------------- Constructors
@@ -62,8 +63,8 @@ public class CatalogBase implements Cata
      *
      * @since Chain 1.1
      */
-    public CatalogBase( Map<String, Command> commands ) {
-        this.commands =  new ConcurrentHashMap<String, Command>(commands);
+    public CatalogBase( Map<String, Command<? extends Context>> commands ) {
+        this.commands.putAll( commands );
     }
 
     // --------------------------------------------------------- Public Methods
@@ -78,7 +79,7 @@ public class CatalogBase implements Cata
      * @param command {@link Command} to be returned
      *  for later lookups on this name
      */
-    public void addCommand(String name, Command command) {
+    public <C extends Context> void addCommand(String name, Command<C> command)
{
 
         commands.put(name, command);
 
@@ -92,9 +93,11 @@ public class CatalogBase implements Cata
      *  should be retrieved
      * @return The Command associated with the specified name.
      */
-    public Command getCommand(String name) {
+    public <C extends Context> Command<C> getCommand(String name) {
 
-        return commands.get(name);
+        @SuppressWarnings( "unchecked" ) // will throw a cast exception at runtime!
+        Command<C> command = (Command<C>) commands.get(name);
+        return command;
 
     }
 
@@ -117,7 +120,7 @@ public class CatalogBase implements Cata
      */
     public String toString() {
 
-        Iterator names = getNames();
+        Iterator<String> names = getNames();
         StringBuffer str =
             new StringBuffer("[" + this.getClass().getName() + ": ");
 



Mime
View raw message