001/*002 * Copyright 2006-2013 the original author or authors.003 *004 * Licensed under the Apache License, Version 2.0 (the "License");005 * you may not use this file except in compliance with the License.006 * You may obtain a copy of the License at007 *008 * https://www.apache.org/licenses/LICENSE-2.0009 *010 * Unless required by applicable law or agreed to in writing, software011 * distributed under the License is distributed on an "AS IS" BASIS,012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.013 * See the License for the specific language governing permissions and014 * limitations under the License.015 */016017package org.springframework.batch.core;018019import java.io.Serializable;020import java.util.Date;021import java.util.LinkedHashMap;022import java.util.Map;023import java.util.Properties;024025/**026 * Value object representing runtime parameters to a batch job. Because the027 * parameters have no individual meaning outside of the JobParameters they are028 * contained within, it is a value object rather than an entity. It is also029 * extremely important that a parameters object can be reliably compared to030 * another for equality, in order to determine if one JobParameters object031 * equals another. Furthermore, because these parameters will need to be032 * persisted, it is vital that the types added are restricted.033 * 034 * This class is immutable and therefore thread-safe.035 * 036 * @author Lucas Ward037 * @author Michael Minella038 * @since 1.0039 */040@SuppressWarnings("serial")041public class JobParameters implements Serializable {042043 private final Map<String,JobParameter> parameters;044045 public JobParameters() {046 this.parameters = new LinkedHashMap<String, JobParameter>();047 }048049 public JobParameters(Map<String,JobParameter> parameters) {050 this.parameters = new LinkedHashMap<String,JobParameter>(parameters);051 }052053 /**054 * Typesafe Getter for the Long represented by the provided key.055 * 056 * @param key The key to get a value for057 * @return The <code>Long</code> value058 */059 public Long getLong(String key){060 if (!parameters.containsKey(key)) {061 return 0L;062 }063 Object value = parameters.get(key).getValue();064 return value==null ? 0L : ((Long)value).longValue();065 }066067 /**068 * Typesafe Getter for the Long represented by the provided key. If the069 * key does not exist, the default value will be returned.070 * 071 * @param key to return the value for072 * @param defaultValue to return if the value doesn't exist073 * @return the parameter represented by the provided key, defaultValue074 * otherwise.075 */076 public Long getLong(String key, long defaultValu