• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision270 (tree)
Time2016-05-03 20:58:20
Authort_nakayama1971

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/NameSetter.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/NameSetter.java (revision 270)
@@ -14,6 +14,7 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
@@ -21,11 +22,11 @@
2122 /**
2223 * Allows specifying a name for a {@link Command} in a {@link Catalog} instance.
2324 *
25+ * @version $Id$
2426 * @param <K> Context key type
2527 * @param <V> Context value type
2628 * @param <C> Type of the context associated with this name setter
2729 * @since 2.0
28- * @version $Id$
2930 */
3031 public interface NameSetter<K, V, C extends Map<K, V>> {
3132
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Catalog.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Catalog.java (revision 270)
@@ -27,11 +27,11 @@
2727 * is optional, but convenient when there are multiple possible chains
2828 * that can be selected and executed based on environmental conditions.</p>
2929 *
30+ * @version $Id$
31+ *
3032 * @param <K> the type of keys maintained by the context associated with this command
3133 * @param <V> the type of mapped values
3234 * @param <C> Type of the context associated with this command
33- *
34- * @version $Id$
3535 */
3636 public interface Catalog<K, V, C extends Map<K, V>> {
3737
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/NamedCommandSetter.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/NamedCommandSetter.java (revision 270)
@@ -14,6 +14,7 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
@@ -21,11 +22,11 @@
2122 /**
2223 * Allows adding a command in a {@link Catalog} identified by a name.
2324 *
25+ * @version $Id$
2426 * @param <K> Context key type
2527 * @param <V> Context value type
2628 * @param <C> Type of the context associated with this command setter
2729 * @since 2.0
28- * @version $Id$
2930 */
3031 public interface NamedCommandSetter<K, V, C extends Map<K, V>>
3132 extends CommandSetter<K, V, C, NameSetter<K, V, C>> {
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Processing.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Processing.java (revision 270)
@@ -14,11 +14,12 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 /**
2021 * A <code>Processing</code> encapsulates states that can be returned by
21- * commands.
22+ * commands.
2223 * <p>
2324 * {@link Command}s should either return <code>FINISHED</code> if the
2425 * processing of the given context has been completed, or return
@@ -30,7 +31,7 @@
3031 public enum Processing {
3132
3233 /**
33- * Commands should return continue if the processing of the given
34+ * Commands should return continue if the processing of the given
3435 * context should be delegated to a subsequent command in an enclosing chain.
3536 *
3637 * @since Chain 2.0
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Command.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Command.java (revision 270)
@@ -14,12 +14,11 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
2021
21-import org.apache.commons.chain2.Processing;
22-
2322 /**
2423 * <p>A {@link Command} encapsulates a unit of processing work to be
2524 * performed, whose purpose is to examine and/or modify the state of a
@@ -76,33 +75,33 @@
7675 * being used in this fashion, as opposed to JavaBeans properties that simply
7776 * configure the internal operation of this {@link Command}.</p>
7877 *
78+ * @version $Id$
79+ *
7980 * @param <K> the type of keys maintained by the context associated with this command
8081 * @param <V> the type of mapped values
8182 * @param <C> Type of the context associated with this command
82- *
83- * @version $Id$
8483 */
8584 public interface Command<K, V, C extends Map<K, V>> {
8685
8786 /**
88- * Execute a unit of processing work to be performed.
87+ * Execute a unit of processing work to be performed.
8988 * <p>
90- * A command may either complete the required processing and return
91- * finished, or delegate remaining processing to the subsequent command
89+ * A command may either complete the required processing and return
90+ * finished, or delegate remaining processing to the subsequent command
9291 * in the enclosing {@link Chain} by returning continue.
9392 *
9493 * @param context The {@link Context} to be processed by this
9594 * {@link Command}
9695 *
96+ * @return {@link Processing#FINISHED} if the processing of this contex
97+ * has been completed. Returns {@link Processing#CONTINUE} if the processing
98+ * of this context should be delegated to a subsequent command in an
99+ * enclosing chain.
100+ *
97101 * @exception ChainException general purpose exception return
98102 * to indicate abnormal termination
99103 * @exception IllegalArgumentException if <code>context</code>
100104 * is <code>null</code>
101- *
102- * @return {@link Processing#FINISHED} if the processing of this contex
103- * has been completed. Returns {@link Processing#CONTINUE} if the processing
104- * of this context should be delegated to a subsequent command in an
105- * enclosing chain.
106105 */
107106 Processing execute(C context);
108107
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Chain.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Chain.java (revision 270)
@@ -14,6 +14,7 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
@@ -48,11 +49,11 @@
4849 * the <code>execute()</code> method of the {@link Chain} is first called.
4950 * After that, the configuration of the {@link Chain} is frozen.</p>
5051 *
52+ * @version $Id$
53+ *
5154 * @param <K> Context key type
5255 * @param <V> Context value type
5356 * @param <C> Type of the context associated with this chain
54- *
55- * @version $Id$
5657 */
5758 public interface Chain<K, V, C extends Map<K, V>> extends Command<K, V, C> {
5859
@@ -63,7 +64,7 @@
6364 * at least once, it is no longer possible to add additional
6465 * {@link Command}s; instead, an exception will be thrown.</p>
6566 *
66- * @param <CMD> the {@link Command} type to be added in the {@link Chain}
67+ * @param <T> the {@link Command} type to be added in the {@link Chain}
6768 * @param command The {@link Command} to be added
6869 *
6970 * @exception IllegalArgumentException if <code>command</code>
@@ -71,7 +72,7 @@
7172 * @exception IllegalStateException if this {@link Chain} has already
7273 * been executed at least once, so no further configuration is allowed
7374 */
74- <CMD extends Command<K, V, C>> void addCommand(CMD command);
75+ <T extends Command<K, V, C>> void addCommand(T command);
7576
7677 /**
7778 * <p>Execute the processing represented by this {@link Chain} according
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Context.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Context.java (revision 270)
@@ -14,6 +14,7 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
@@ -54,9 +55,9 @@
5455 * simultaneously unless this is explicitly documented for a particular
5556 * implementation.</p>
5657 *
58+ * @version $Id$
5759 * @param <K> the type of keys maintained by the context associated with this catalog
5860 * @param <V> the type of mapped values
59- * @version $Id$
6061 */
6162 public interface Context<K, V> extends Map<K, V> {
6263
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Filter.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Filter.java (revision 270)
@@ -39,11 +39,11 @@
3939 * can reliably release such resources in the <code>postprocess()</code>
4040 * method, which is guaranteed to be called by the owning {@link Chain}.</p>
4141 *
42+ * @version $Id$
43+ *
4244 * @param <K> the type of keys maintained by the context associated with this command
4345 * @param <V> the type of mapped values
4446 * @param <C> Type of the context associated with this command
45- *
46- * @version $Id$
4747 */
4848 public interface Filter<K, V, C extends Map<K, V>> extends Command<K, V, C> {
4949
@@ -58,12 +58,12 @@
5858 * by the last {@link Command} that was executed; otherwise
5959 * <code>null</code>
6060 *
61- * @exception IllegalArgumentException if <code>context</code>
62- * is <code>null</code>
63- *
6461 * @return If a non-null <code>exception</code> was "handled" by this
6562 * method (and therefore need not be rethrown), return <code>FINISHED</code>;
6663 * otherwise return <code>CONTINUE</code>
64+ *
65+ * @exception IllegalArgumentException if <code>context</code>
66+ * is <code>null</code>
6767 */
6868 boolean postprocess(C context, Exception exception);
6969
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/ToExecutorCommandSetter.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/ToExecutorCommandSetter.java (revision 270)
@@ -14,6 +14,7 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
@@ -21,11 +22,11 @@
2122 /**
2223 * First builder that allows adding a command in the target chain.
2324 *
25+ * @version $Id$
2426 * @param <K> Context key type
2527 * @param <V> Context value type
2628 * @param <C> Type of the context associated with this chain executor
2729 * @since 2.0
28- * @version $Id$
2930 */
3031 public interface ToExecutorCommandSetter<K, V, C extends Map<K, V>>
3132 extends CommandSetter<K, V, C, ChainExecutor<K, V, C>> {
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/ChainException.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/ChainException.java (revision 270)
@@ -14,6 +14,7 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
@@ -27,19 +28,13 @@
2728 */
2829 public class ChainException extends RuntimeException {
2930
30- /**
31- *
32- */
31+ /** serialVersionUID */
3332 private static final long serialVersionUID = 20120724L;
3433
35- /**
36- * Context used when exception occurred.
37- */
34+ /** Context used when exception occurred. */
3835 private final Map<?, ?> context;
3936
40- /**
41- * Command that failed when exception occurred.
42- */
37+ /** Command that failed when exception occurred. */
4338 private final transient Command<?, ?, ?> failedCommand;
4439
4540 /**
@@ -46,7 +41,7 @@
4641 * Create an exception object with a message.
4742 * @param message Message to associate with exception
4843 */
49- public ChainException(String message) {
44+ public ChainException(final String message) {
5045 super(message);
5146 this.context = null;
5247 this.failedCommand = null;
@@ -57,7 +52,7 @@
5752 * @param message Message to associate with exception
5853 * @param cause Exception to chain to this exception
5954 */
60- public ChainException(String message, Throwable cause) {
55+ public ChainException(final String message, final Throwable cause) {
6156 super(message, cause);
6257 this.context = null;
6358 this.failedCommand = null;
@@ -75,16 +70,16 @@
7570 * {@link #getCause()} method). (A <tt>null</tt> value is
7671 * permitted, and indicates that the cause is nonexistent or
7772 * unknown.)
78- * @param context The Context object passed to the {@link Command} in
73+ * @param ctx The Context object passed to the {@link Command} in
7974 * which the exception occurred.
80- * @param failedCommand The Command object in which the exception was
75+ * @param failed The Command object in which the exception was
8176 * thrown.
8277 */
83- public <K, V, C extends Map<K, V>> ChainException(String message, Throwable cause,
84- C context, Command<K, V, C> failedCommand) {
78+ public <K, V, C extends Map<K, V>> ChainException(final String message,
79+ final Throwable cause, final C ctx, final Command<K, V, C> failed) {
8580 super(message, cause);
86- this.context = context;
87- this.failedCommand = failedCommand;
81+ this.context = ctx;
82+ this.failedCommand = failed;
8883 }
8984
9085 /**
@@ -91,8 +86,8 @@
9186 * @return The context object passed when the {@link Command}
9287 * threw an exception.
9388 */
94- public Map<?, ?> getContext() {
95- return context;
89+ public final Map<?, ?> getContext() {
90+ return this.context;
9691 }
9792
9893 /**
@@ -99,8 +94,8 @@
9994 * @return The {@link Command} object in which the original exception was
10095 * thrown.
10196 */
102- public Command<?, ?, ?> getFailedCommand() {
103- return failedCommand;
97+ public final Command<?, ?, ?> getFailedCommand() {
98+ return this.failedCommand;
10499 }
105100
106101 }
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/ChainExecutor.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/ChainExecutor.java (revision 270)
@@ -14,22 +14,22 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
2021
21-import org.apache.commons.chain2.Processing;
22-
2322 /**
2423 * Builder that allows continue adding a command in the target chain and execute it.
2524 *
25+ * @version $Id$
2626 * @param <K> Context key type
2727 * @param <V> Context value type
2828 * @param <C> Type of the context associated with this chain executor
29- * @version $Id$
3029 * @since 2.0
3130 */
32-public interface ChainExecutor<K, V, C extends Map<K, V>> extends CommandSetter<K, V, C, ChainExecutor<K, V, C>> {
31+public interface ChainExecutor<K, V, C extends Map<K, V>>
32+ extends CommandSetter<K, V, C, ChainExecutor<K, V, C>> {
3333
3434 /**
3535 * Execute the processing represented by the target chain.
@@ -39,7 +39,7 @@
3939 * has been completed. Returns {@link Processing#CONTINUE} if the processing
4040 * of this context should be delegated to a subsequent command in an
4141 * enclosing chain.
42- *
42+ *
4343 * @see Chain#execute(Map)
4444 */
4545 Processing execute(C context);
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/CatalogFactory.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/CatalogFactory.java (revision 270)
@@ -29,11 +29,11 @@
2929 * The base implementation provides command lookup based on a single
3030 * String. This String encodes both the catalog and command names.
3131 *
32+ * @version $Id: CatalogFactory.java 1486528 2013-05-27 07:38:38Z simonetripodi $
33+ *
3234 * @param <K> the type of keys maintained by the context associated with this {@link Command}
3335 * @param <V> the type of mapped values
3436 * @param <C> Type of the context associated with this command
35- *
36- * @version $Id: CatalogFactory.java 1486528 2013-05-27 07:38:38Z simonetripodi $
3737 */
3838 public interface CatalogFactory<K, V, C extends Map<K, V>> {
3939
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Chains.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/Chains.java (revision 270)
@@ -14,32 +14,42 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
19-import static java.lang.String.format;
20-
2120 import java.util.Map;
2221
2322 /**
2423 * Simple fluent chain EDSL to simplify {@link Chain} instances invocation.
2524 *
25+ * @version $Id$
2626 * @since 2.0
27- * @version $Id$
2827 */
2928 public final class Chains {
3029
3130 /**
31+ * Private constructor, this class cannot be instantiated directly.
32+ */
33+ private Chains() {
34+ throw new AssertionError();
35+ }
36+
37+ /**
3238 * Defines the target chain has to be invoked.
3339 *
3440 * @param <K> Context key type
3541 * @param <V> Context value type
3642 * @param <C> Type of the context associated with this command
37- * @param <CH> Type of the {@link Chain} to execute
43+ * @param <U> Type of the {@link Chain} to execute
3844 * @param chain the chain instance reference to execute
3945 * @return next chain builder
4046 */
41- public static <K, V, C extends Map<K, V>, CH extends Chain<K, V, C>> ToExecutorCommandSetter<K, V, C> on(CH chain) {
42- return new DefaultCommandSetter<>(checkNotNullArgument(chain, "Null Chain can not be executed"));
47+ public static <K, V, C extends Map<K, V>, U extends Chain<K, V, C>>
48+ ToExecutorCommandSetter<K, V, C> on(final U chain) {
49+ if (chain == null) {
50+ throw new IllegalArgumentException(String.format("Null Chain can not be executed"));
51+ }
52+ return new DefaultCommandSetter<>(chain);
4353 }
4454
4555 /**
@@ -48,53 +58,79 @@
4858 * @param <K> Context key type
4959 * @param <V> Context value type
5060 * @param <C> Type of the context associated with this command
51- * @param <CA> Type of the {@link Catalog} to execute
61+ * @param <S> Type of the {@link Catalog} to execute
5262 * @param catalog the catalog instance reference to be setup
5363 * @return next chain builder
5464 */
55- public static <K, V, C extends Map<K, V>, CA extends Catalog<K, V, C>> NamedCommandSetter<K, V, C> on(CA catalog) {
56- return new DefaultNamedCommandSetter<>(checkNotNullArgument(catalog, "Null Catalog can not be setup"));
65+ public static <K, V, C extends Map<K, V>, S extends Catalog<K, V, C>>
66+ NamedCommandSetter<K, V, C> on(final S catalog) {
67+ if (catalog == null) {
68+ throw new IllegalArgumentException(String.format("Null Catalog can not be setup"));
69+ }
70+ return new DefaultNamedCommandSetter<>(catalog);
5771 }
5872
59- /**
60- * Private constructor, this class cannot be instantiated directly.
61- */
62- private Chains() {
63- // do nothing
64- }
73+ private static class DefaultCommandSetter<K, V, C extends Map<K, V>>
74+ implements ToExecutorCommandSetter<K, V, C> {
6575
66- private static class DefaultCommandSetter<K, V, C extends Map<K, V>> implements ToExecutorCommandSetter<K, V, C> {
76+ private final Chain<K, V, C> chain;
6777
68- private final Chain<K, V, C> chain;
69- /** @param chain Chain */
70- public DefaultCommandSetter(Chain<K, V, C> chain) {
71- this.chain = chain;
78+ /**
79+ * @param chn Chain
80+ */
81+ DefaultCommandSetter(final Chain<K, V, C> chn) {
82+ this.chain = chn;
7283 }
73- /** @see org.apache.commons.chain2.CommandSetter#add(org.apache.commons.chain2.Command) */
74- @Override public <CMD extends Command<K, V, C>> ChainExecutor<K, V, C> add(CMD command) {
75- chain.addCommand(checkNotNullArgument(command, "Chain does not accept null Command instances"));
76- return new DefaultChainExecutor<>(chain);
84+
85+ /**
86+ * @see org.apache.commons.chain2.CommandSetter#add(org.apache.commons.chain2.Command)
87+ */
88+ @Override
89+ public <T extends Command<K, V, C>> ChainExecutor<K, V, C> add(final T command) {
90+ if (command == null) {
91+ throw new IllegalArgumentException(
92+ String.format("Chain does not accept null Command instances"));
93+ }
94+ this.chain.addCommand(command);
95+ return new DefaultChainExecutor<>(this.chain);
7796 }
78-
7997 }
8098
81- private static final class DefaultChainExecutor<K, V, C extends Map<K, V>> implements ChainExecutor<K, V, C> {
99+ private static final class DefaultChainExecutor<K, V, C extends Map<K, V>>
100+ implements ChainExecutor<K, V, C> {
82101
83102 private final Chain<K, V, C> chain;
84- /** @param chain Chain */
85- public DefaultChainExecutor(Chain<K, V, C> chain) {
86- this.chain = chain;
103+
104+ /**
105+ * @param chn Chain
106+ */
107+ DefaultChainExecutor(final Chain<K, V, C> chn) {
108+ this.chain = chn;
87109 }
88- /** @see org.apache.commons.chain2.CommandSetter#add(org.apache.commons.chain2.Command) */
89- @Override public <CMD extends Command<K, V, C>> ChainExecutor<K, V, C> add(CMD command) {
90- chain.addCommand(checkNotNullArgument(command, "Chain does not accept null Command instances"));
110+
111+ /**
112+ * @see org.apache.commons.chain2.CommandSetter#add(org.apache.commons.chain2.Command)
113+ */
114+ @Override
115+ public <T extends Command<K, V, C>> ChainExecutor<K, V, C> add(final T command) {
116+ if (command == null) {
117+ throw new IllegalArgumentException(
118+ String.format("Chain does not accept null Command instances"));
119+ }
120+ this.chain.addCommand(command);
91121 return this;
92122 }
93- /** @see org.apache.commons.chain2.ChainExecutor#execute(java.util.Map) */
94- @Override public Processing execute(C context) {
95- return chain.execute(checkNotNullArgument(context, "Chain cannot be applied to a null context."));
123+
124+ /**
125+ * @see org.apache.commons.chain2.ChainExecutor#execute(java.util.Map)
126+ */
127+ @Override public Processing execute(final C context) {
128+ if (context == null) {
129+ throw new IllegalArgumentException(
130+ String.format("Chain cannot be applied to a null context."));
131+ }
132+ return this.chain.execute(context);
96133 }
97-
98134 }
99135
100136 private static final class DefaultNamedCommandSetter<K, V, C extends Map<K, V>>
@@ -101,42 +137,52 @@
101137 implements NamedCommandSetter<K, V, C> {
102138
103139 private final Catalog<K, V, C> catalog;
104- /** @param catalog Catalog */
105- public DefaultNamedCommandSetter(Catalog<K, V, C> catalog) {
106- this.catalog = catalog;
140+
141+ /**
142+ * @param ctlg Catalog
143+ */
144+ DefaultNamedCommandSetter(final Catalog<K, V, C> ctlg) {
145+ this.catalog = ctlg;
107146 }
108- /** @see org.apache.commons.chain2.CommandSetter#add(org.apache.commons.chain2.Command) */
109- @Override public <CMD extends Command<K, V, C>> NameSetter<K, V, C> add(CMD command) {
110- CMD checkedCommand = checkNotNullArgument( command, "Catalog does not accept null Command instances" );
111- return new DefaultNameSetter<>(catalog, checkedCommand);
147+
148+ /**
149+ * @see org.apache.commons.chain2.CommandSetter#add(org.apache.commons.chain2.Command)
150+ */
151+ @Override
152+ public <T extends Command<K, V, C>> NameSetter<K, V, C> add(final T command) {
153+ if (command == null) {
154+ throw new IllegalArgumentException(
155+ String.format("Catalog does not accept null Command instances"));
156+ }
157+ return new DefaultNameSetter<>(this.catalog, command);
112158 }
113-
114159 }
115160
116- private static final class DefaultNameSetter<K, V, C extends Map<K, V>> implements NameSetter<K, V, C> {
161+ private static final class DefaultNameSetter<K, V, C extends Map<K, V>>
162+ implements NameSetter<K, V, C> {
117163 private final Catalog<K, V, C> catalog;
118164 private final Command<K, V, C> command;
165+
119166 /**
120- * @param catalog Catalog
121- * @param command Command */
122- public DefaultNameSetter(Catalog<K, V, C> catalog, Command<K, V, C> command) {
123- this.catalog = catalog;
124- this.command = command;
167+ * @param ctlg Catalog
168+ * @param cmd Command */
169+ DefaultNameSetter(final Catalog<K, V, C> ctlg, final Command<K, V, C> cmd) {
170+ this.catalog = ctlg;
171+ this.command = cmd;
125172 }
126- /** @see org.apache.commons.chain2.NameSetter#identifiedBy(java.lang.String) */
127- @Override public NamedCommandSetter<K, V, C> identifiedBy(String name) {
128- catalog.addCommand(checkNotNullArgument(name, "Command <%s> cannot be identified by a null name", command),
129- command);
130- return new DefaultNamedCommandSetter<>(catalog);
131- }
132173
133- }
134-
135- protected static <T> T checkNotNullArgument(T reference, String message, Object...args) {
136- if (reference == null) {
137- throw new IllegalArgumentException(format(message, args));
174+ /**
175+ * @see org.apache.commons.chain2.NameSetter#identifiedBy(java.lang.String)
176+ */
177+ @Override
178+ public NamedCommandSetter<K, V, C> identifiedBy(final String name) {
179+ if (name == null) {
180+ throw new IllegalArgumentException(
181+ String.format("Command <%s> cannot be identified by a null name", this.command));
182+ }
183+ this.catalog.addCommand(name, this.command);
184+ return new DefaultNamedCommandSetter<>(this.catalog);
138185 }
139- return reference;
140186 }
141187
142188 }
--- trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/CommandSetter.java (revision 269)
+++ trunk/apache/commons-chain2/src/main/java/org/apache/commons/chain2/CommandSetter.java (revision 270)
@@ -14,6 +14,7 @@
1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718 package org.apache.commons.chain2;
1819
1920 import java.util.Map;
@@ -21,12 +22,12 @@
2122 /**
2223 * Generic builder that allows adding commands to the target {@link Chain} has to be executed.
2324 *
25+ * @version $Id$
2426 * @param <K> Context key type
2527 * @param <V> Context value type
2628 * @param <C> Type of the context associated with this command setter
2729 * @param <R> Type of the next chain builder
2830 * @since 2.0
29- * @version $Id$
3031 */
3132 public interface CommandSetter<K, V, C extends Map<K, V>, R> {
3233
@@ -33,11 +34,11 @@
3334 /**
3435 * Add the given command to the target {@link Chain} has to be executed.
3536 *
36- * @param <CMD> Type of the command has to be added
37+ * @param <T> Type of the command has to be added
3738 * @param command the command has to be added in the target chain
3839 * @return next chain builder
3940 * @see Chain#addCommand(Command)
4041 */
41- <CMD extends Command<K, V, C>> R add(CMD command);
42+ <T extends Command<K, V, C>> R add(T command);
4243
4344 }