From d8f2ccb354a157c7a0fa1c3353b5a121a983ab15 Mon Sep 17 00:00:00 2001 From: lucasward Date: Thu, 24 Jan 2008 16:19:02 +0000 Subject: [PATCH] BATCH-304: Modified the CommandLineJobRunner to accept a job name as an argument. Also modified the contract of JobParamterFactory to return an empty JobParameters or Properties if null is passed in, rather than throwing an IllegalArgumentException. --- .../springframework/batch/core/domain/JobParameters.java | 7 +++++++ .../batch/core/runtime/JobParametersFactory.java | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java index 24667fec1..914ab4dbc 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java @@ -133,6 +133,13 @@ public class JobParameters { return Collections.unmodifiableMap(dateMap); } + /** + * @return true if the prameters is empty, false otherwise. + */ + public boolean isEmpty(){ + return (dateMap.isEmpty() && longMap.isEmpty() && stringMap.isEmpty()); + } + /* * Convenience method for validating that a the provided map only contains a particular * type as a value, with only a String as a key. diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobParametersFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobParametersFactory.java index be83e8d26..25a728423 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobParametersFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobParametersFactory.java @@ -38,7 +38,8 @@ import org.springframework.batch.core.domain.JobParametersBuilder; public interface JobParametersFactory { /** - * Get a new {@link JobParameters} instance. + * Get a new {@link JobParameters} instance. If given null, or an empty + * properties, an empty JobParameters will be returned. * * @param properties * the runtime parameters in the form of String literals. @@ -47,7 +48,8 @@ public interface JobParametersFactory { public JobParameters getJobParameters(Properties properties); /** - * The inverse operation: get a {@link Properties} instance. + * The inverse operation: get a {@link Properties} instance. If given + * null or empty JobParameters, an empty Properties should be returned. * * @param params * @return a representation of the parameters as properties