Package org.springframework.batch.core
Class JobParameters
- java.lang.Object
- org.springframework.batch.core.JobParameters
- All Implemented Interfaces:
java.io.Serializable
public class JobParameters extends java.lang.Object implements java.io.Serializable
Value object representing runtime parameters to a batch job. Because the parameters have no individual meaning outside of the JobParameters they are contained within, it is a value object rather than an entity. It is also extremely important that a parameters object can be reliably compared to another for equality, in order to determine if one JobParameters object equals another. Furthermore, because these parameters will need to be persisted, it is vital that the types added are restricted. This class is immutable and therefore thread-safe.- Since:
- 1.0
- Author:
- Lucas Ward, Michael Minella
- See Also:
- Serialized Form
Constructor Summary
Constructors Constructor Description JobParameters()
JobParameters(java.util.Map<java.lang.String,JobParameter> parameters)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.util.Date
getDate(java.lang.String key)
Typesafe Getter for the Date represented by the provided key.java.util.Date
getDate(java.lang.String key, java.util.Date defaultValue)
Typesafe Getter for the Date represented by the provided key.java.lang.Double
getDouble(java.lang.String key)
Typesafe Getter for the Long represented by the provided key.java.lang.Double
getDouble(java.lang.String key, double defaultValue)
Typesafe Getter for the Double represented by the provided key.java.lang.Long
getLong(java.lang.String key)
Typesafe Getter for the Long represented by the provided key.java.lang.Long
getLong(java.lang.String key, long defaultValue)
Typesafe Getter for the Long represented by the provided key.java.util.Map<java.lang.String,JobParameter>
getParameters()
Get a map of all parameters, including string, long, and date.java.lang.String
getString(java.lang.String key)
Typesafe Getter for the String represented by the provided key.java.lang.String
getString(java.lang.String key, java.lang.String defaultValue)
Typesafe Getter for the String represented by the provided key.int
hashCode()
boolean
isEmpty()
java.util.Properties
toProperties()
java.lang.String
toString()
Constructor Detail
JobParameters
public JobParameters()
JobParameters
public JobParameters(java.util.Map<java.lang.String,JobParameter> parameters)
Method Detail
getLong
public java.lang.Long getLong(java.lang.String key)
Typesafe Getter for the Long represented by the provided key.- Parameters:
key
- The key to get a value for- Returns:
- The
Long
value
getLong
public java.lang.Long getLong(java.lang.String key, long defaultValue)
Typesafe Getter for the Long represented by the provided key. If the key does not exist, the default value will be returned.- Parameters:
key
- to return the value fordefaultValue
- to return if the value doesn't exist- Returns:
- the parameter represented by the provided key, defaultValue otherwise.
getString
public java.lang.String getString(java.lang.String key)
Typesafe Getter for the String represented by the provided key.- Parameters:
key
- The key to get a value for- Returns:
- The
String
value
getString
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
Typesafe Getter for the String represented by the provided key. If the key does not exist, the default value will be returned.- Parameters:
key
- to return the value fordefaultValue
- to return if the value doesn't exist- Returns:
- the parameter represented by the provided key, defaultValue otherwise.
getDouble
public java.lang.Double getDouble(java.lang.String key)
Typesafe Getter for the Long represented by the provided key.- Parameters:
key
- The key to get a value for- Returns:
- The
Double
value
getDouble
public java.lang.Double getDouble(java.lang.String key, double defaultValue)
Typesafe Getter for the Double represented by the provided key. If the key does not exist, the default value will be returned.- Parameters:
key
- to return the value fordefaultValue
- to return if the value doesn't exist- Returns:
- the parameter represented by the provided key, defaultValue otherwise.
getDate
public java.util.Date getDate(java.lang.String key)
Typesafe Getter for the Date represented by the provided key.- Parameters:
key
- The key to get a value for- Returns:
- The
java.util.Date
value
getDate
public java.util.Date getDate(java.lang.String key, java.util.Date defaultValue)
Typesafe Getter for the Date represented by the provided key. If the key does not exist, the default value will be returned.- Parameters:
key
- to return the value fordefaultValue
- to return if the value doesn't exist- Returns:
- the parameter represented by the provided key, defaultValue otherwise.
getParameters
public java.util.Map<java.lang.String,JobParameter> getParameters()
Get a map of all parameters, including string, long, and date.- Returns:
- an unmodifiable map containing all parameters.
isEmpty
public boolean isEmpty()
- Returns:
- true if the parameters is empty, false otherwise.
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
toProperties
public java.util.Properties toProperties()