commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1372429 - in /commons/proper/chain/trunk/core/src: main/java/org/apache/commons/chain2/Chains.java main/java/org/apache/commons/chain2/CommandSetter.java test/java/org/apache/commons/chain2/impl/FluentInterfacesTestCase.java
Date Mon, 13 Aug 2012 14:06:54 GMT
Author: simonetripodi
Date: Mon Aug 13 14:06:54 2012
New Revision: 1372429

URL: http://svn.apache.org/viewvc?rev=1372429&view=rev
Log:
Chains method to add commands made less verbose

Modified:
    commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/Chains.java
    commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/CommandSetter.java
    commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/FluentInterfacesTestCase.java

Modified: commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/Chains.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/Chains.java?rev=1372429&r1=1372428&r2=1372429&view=diff
==============================================================================
--- commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/Chains.java (original)
+++ commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/Chains.java Mon
Aug 13 14:06:54 2012
@@ -71,13 +71,13 @@ public final class Chains {
             this.chain = chain;
         }
 
-        public <CMD extends Command<K, V, C>> ChainExecutor<K, V, C> addCommand(CMD
command) {
+        public <CMD extends Command<K, V, C>> ChainExecutor<K, V, C> add(CMD
command) {
             chain.addCommand(checkNotNullArgument(command, "Chain does not accept null Command
instances"));
             return new DefaultChainExecutor<K, V, C>(chain);
         }
 
         @Override
-        public <F extends Filter<K, V, C>> ChainExecutor<K, V, C> addFilter(F
filter) {
+        public <F extends Filter<K, V, C>> ChainExecutor<K, V, C> add(F
filter) {
             chain.addCommand(checkNotNullArgument(filter, "Chain does not accept null Filter
instances"));
             return new DefaultChainExecutor<K, V, C>(chain);
         }
@@ -92,13 +92,13 @@ public final class Chains {
             this.chain = chain;
         }
 
-        public <CMD extends Command<K, V, C>> ChainExecutor<K, V, C> addCommand(CMD
command) {
+        public <CMD extends Command<K, V, C>> ChainExecutor<K, V, C> add(CMD
command) {
             chain.addCommand(checkNotNullArgument(command, "Chain does not accept null Command
instances"));
             return this;
         }
 
         @Override
-        public <F extends Filter<K, V, C>> ChainExecutor<K, V, C> addFilter(F
filter) {
+        public <F extends Filter<K, V, C>> ChainExecutor<K, V, C> add(F
filter) {
             chain.addCommand(checkNotNullArgument(filter, "Chain does not accept null Filter
instances"));
             return this;
         }
@@ -118,13 +118,13 @@ public final class Chains {
             this.catalog = catalog;
         }
 
-        public <CMD extends Command<K, V, C>> NameSetter<K, V, C> addCommand(CMD
command) {
+        public <CMD extends Command<K, V, C>> NameSetter<K, V, C> add(CMD
command) {
             CMD checkedCommand = checkNotNullArgument( command, "Catalog does not accept
null Command instances" );
             return new DefaultNameSetter<K, V, C>(catalog, checkedCommand);
         }
 
         @Override
-        public <F extends Filter<K, V, C>> NameSetter<K, V, C> addFilter(F
filter) {
+        public <F extends Filter<K, V, C>> NameSetter<K, V, C> add(F filter)
{
             F checkedFilter = checkNotNullArgument(filter, "Catalog does not accept null
Filter instances");
             return new DefaultNameSetter<K, V, C>(catalog, checkedFilter);
         }

Modified: commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/CommandSetter.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/CommandSetter.java?rev=1372429&r1=1372428&r2=1372429&view=diff
==============================================================================
--- commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/CommandSetter.java
(original)
+++ commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2/CommandSetter.java
Mon Aug 13 14:06:54 2012
@@ -38,7 +38,7 @@ public interface CommandSetter<K, V, C e
      * @return next chain builder
      * @see Chain#addCommand(Command)
      */
-    <CMD extends Command<K, V, C>> R addCommand(CMD command);
+    <CMD extends Command<K, V, C>> R add(CMD command);
 
     /**
      * Add the given filter to the target {@link Chain} has to be executed.
@@ -48,6 +48,6 @@ public interface CommandSetter<K, V, C e
      * @return next chain builder
      * @see Chain#addCommand(Command)
      */
-    <F extends Filter<K, V, C>> R addFilter(F filter);
+    <F extends Filter<K, V, C>> R add(F filter);
 
 }

Modified: commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/FluentInterfacesTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/FluentInterfacesTestCase.java?rev=1372429&r1=1372428&r2=1372429&view=diff
==============================================================================
--- commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/FluentInterfacesTestCase.java
(original)
+++ commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/FluentInterfacesTestCase.java
Mon Aug 13 14:06:54 2012
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTru
 
 import org.apache.commons.chain2.Catalog;
 import org.apache.commons.chain2.Chain;
+import org.apache.commons.chain2.Command;
 import org.apache.commons.chain2.Context;
 import org.junit.Test;
 
@@ -40,26 +41,26 @@ public final class FluentInterfacesTestC
     @Test(expected = IllegalArgumentException.class)
     public void doesNotAcceptNullCommand() {
         on(new ChainBase<String, Object, Context<String, Object>>())
-        .addCommand(null);
+        .add(null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void doesNotAcceptNullContext() {
         on(new ChainBase<String, Object, Context<String, Object>>())
-        .addCommand(new NonDelegatingFilter("3", "c"))
+        .add(new NonDelegatingFilter("3", "c"))
         .execute(null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void doesNotAcceptNullCommandInCatalog() {
         on(new CatalogBase<String, Object, Context<String, Object>>())
-        .addCommand(null);
+        .add((Command<String, Object, Context<String, Object>>) null);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void doesNotAcceptNullName() {
         on(new CatalogBase<String, Object, Context<String, Object>>())
-        .addCommand(new DelegatingFilter("1", "a")).identifiedBy(null);
+        .add(new DelegatingFilter("1", "a")).identifiedBy(null);
     }
 
     @Test
@@ -67,9 +68,9 @@ public final class FluentInterfacesTestC
         ContextBase context = new ContextBase();
 
         on(new ChainBase<String, Object, Context<String, Object>>())
-        .addCommand(new DelegatingFilter("1", "a"))
-        .addCommand(new ExceptionFilter("2", "b"))
-        .addCommand(new NonDelegatingFilter("3", "c"))
+        .add(new DelegatingFilter("1", "a"))
+        .add(new ExceptionFilter("2", "b"))
+        .add(new NonDelegatingFilter("3", "c"))
         .execute(context);
 
         assertTrue(context.containsKey("log"));
@@ -81,14 +82,14 @@ public final class FluentInterfacesTestC
             new CatalogBase<String, Object, Context<String, Object>>();
 
         on(catalog)
-        .addCommand(new AddingCommand("", null)).identifiedBy("AddingCommand")
-        .addCommand(new DelegatingCommand("")).identifiedBy("DelegatingCommand")
-        .addCommand(new DelegatingFilter("", "")).identifiedBy("DelegatingFilter")
-        .addCommand(new ExceptionCommand("")).identifiedBy("ExceptionCommand")
-        .addCommand(new ExceptionFilter("", "")).identifiedBy("ExceptionFilter")
-        .addCommand(new NonDelegatingCommand("")).identifiedBy("NonDelegatingCommand")
-        .addCommand(new NonDelegatingFilter("", "")).identifiedBy("NonDelegatingFilter")
-        .addCommand(new ChainBase<String, Object, Context<String, Object>>()).identifiedBy("ChainBase");
+        .add(new AddingCommand("", null)).identifiedBy("AddingCommand")
+        .add(new DelegatingCommand("")).identifiedBy("DelegatingCommand")
+        .add(new DelegatingFilter("", "")).identifiedBy("DelegatingFilter")
+        .add(new ExceptionCommand("")).identifiedBy("ExceptionCommand")
+        .add(new ExceptionFilter("", "")).identifiedBy("ExceptionFilter")
+        .add(new NonDelegatingCommand("")).identifiedBy("NonDelegatingCommand")
+        .add(new NonDelegatingFilter("", "")).identifiedBy("NonDelegatingFilter")
+        .add(new ChainBase<String, Object, Context<String, Object>>()).identifiedBy("ChainBase");
 
         assertNotNull(catalog.getCommand("AddingCommand"));
         assertNotNull(catalog.getCommand("DelegatingCommand"));



Mime
View raw message