commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1371240 - in /commons/proper/chain/trunk/core/src/main/java/org/apache/commons/chain2: Chains.java CommandSetter.java
Date Thu, 09 Aug 2012 14:54:16 GMT
Author: simonetripodi
Date: Thu Aug  9 14:54:16 2012
New Revision: 1371240

URL: http://svn.apache.org/viewvc?rev=1371240&view=rev
Log:
added fluent methods to setup Filter instances as well in both Chain/Catalog

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

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=1371240&r1=1371239&r2=1371240&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 Thu
Aug  9 14:54:16 2012
@@ -76,6 +76,12 @@ public final class Chains {
             return new DefaultChainExecutor<K, V, C>(chain);
         }
 
+        @Override
+        public <F extends Filter<K, V, C>> ChainExecutor<K, V, C> addFilter(F
filter) {
+            chain.addCommand(checkNotNullArgument(filter, "Chain does not accept null Filter
instances"));
+            return new DefaultChainExecutor<K, V, C>(chain);
+        }
+
     }
 
     private static final class DefaultChainExecutor<K, V, C extends Map<K, V>>
implements ChainExecutor<K, V, C> {
@@ -91,6 +97,12 @@ public final class Chains {
             return this;
         }
 
+        @Override
+        public <F extends Filter<K, V, C>> ChainExecutor<K, V, C> addFilter(F
filter) {
+            chain.addCommand(checkNotNullArgument(filter, "Chain does not accept null Filter
instances"));
+            return this;
+        }
+
         public boolean execute(C context) {
             return chain.execute(checkNotNullArgument(context, "Chain cannot be applied to
a null context."));
         }
@@ -111,6 +123,12 @@ public final class Chains {
             return new DefaultNameSetter<K, V, C>(catalog, checkedCommand);
         }
 
+        @Override
+        public <F extends Filter<K, V, C>> NameSetter<K, V, C> addFilter(F
filter) {
+            F checkedFilter = checkNotNullArgument(filter, "Catalog does not accept null
Filter instances");
+            return new DefaultNameSetter<K, V, C>(catalog, checkedFilter);
+        }
+
     }
 
     private static final class DefaultNameSetter<K, V, C extends Map<K, V>> implements
NameSetter<K, V, C> {

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=1371240&r1=1371239&r2=1371240&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
Thu Aug  9 14:54:16 2012
@@ -40,4 +40,14 @@ public interface CommandSetter<K, V, C e
      */
     <CMD extends Command<K, V, C>> R addCommand(CMD command);
 
+    /**
+     * Add the given filter to the target {@link Chain} has to be executed.
+     *
+     * @param <F> Type of the filter has to be added
+     * @param command the command has to be added in the target chain
+     * @return next chain builder
+     * @see Chain#addCommand(Command)
+     */
+    <F extends Filter<K, V, C>> R addFilter(F filter);
+
 }



Mime
View raw message