Class JobParameters

java.lang.Object
org.springframework.batch.core.JobParameters
All Implemented Interfaces:
Serializable

public class JobParameters extends Object implements Serializable
Value object representing runtime parameters to a batch job. Because the parameters have no individual meaning outside of the JobParameters object 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 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, Mahmoud Ben Hassine, Taeik Lim
See Also:
  • Constructor Details

    • JobParameters

      public JobParameters()
      Default constructor.
    • JobParameters

      public JobParameters(Map<String,JobParameter> parameters)
      Constructor that is initialized with the content of a Map that contains a String key and a JobParameter value.
      Parameters:
      parameters - The Map that contains a String key and a JobParameter value.
  • Method Details

    • getLong

      @Nullable public Long getLong(String key)
      Typesafe getter for the Long represented by the provided key.
      Parameters:
      key - The key for which to get a value.
      Returns:
      The Long value or null if the key is absent.
    • getLong

      @Nullable public Long getLong(String key, @Nullable Long defaultValue)
      Typesafe getter for the Long represented by the provided key. If the key does not exist, the default value is returned.
      Parameters:
      key - The key for which to return the value.
      defaultValue - The default value to return if the value does not exist.
      Returns:
      the parameter represented by the provided key or, if that is missing, the default value.
    • getString

      @Nullable public String getString(String key)
      Typesafe getter for the String represented by the provided key.
      Parameters:
      key - The key for which to get a value.
      Returns:
      The String value or null if the key is absent.
    • getString

      @Nullable public String getString(String key, @Nullable String defaultValue)
      Typesafe getter for the String represented by the provided key. If the key does not exist, the default value is returned.
      Parameters:
      key - The key for which to return the value.
      defaultValue - The defult value to return if the value does not exist.
      Returns:
      the parameter represented by the provided key or, if that is missing, the default value.
    • getDouble

      @Nullable public Double getDouble(String key)
      Typesafe getter for the Long represented by the provided key.
      Parameters:
      key - The key for which to get a value.
      Returns:
      The Double value or null if the key is absent.
    • getDouble

      @Nullable public Double getDouble(String key, @Nullable Double defaultValue)
      Typesafe getter for the Double represented by the provided key. If the key does not exist, the default value is returned.
      Parameters:
      key - The key for which to return the value.
      defaultValue - The default value to return if the value does not exist.
      Returns:
      the parameter represented by the provided key or, if that is missing, the default value.
    • getDate

      @Nullable public Date getDate(String key)
      Typesafe getter for the Date represented by the provided key.
      Parameters:
      key - The key for which to get a value.
      Returns:
      the Date value or null if the key is absent.
    • getDate

      @Nullable public Date getDate(String key, @Nullable Date defaultValue)
      Typesafe getter for the Date represented by the provided key. If the key does not exist, the default value is returned.
      Parameters:
      key - The key for which to return the value.
      defaultValue - The default value to return if the value does not exist.
      Returns:
      the parameter represented by the provided key or, if that is missing, the default value.
    • getParameters

      public Map<String,JobParameter> getParameters()
      Get a map of all parameters, including String, Long, and Date types.
      Returns:
      an unmodifiable map containing all parameters.
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if the parameters object is empty or false otherwise.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toProperties

      public Properties toProperties()
      Returns:
      The Properties that contain the key and values for the JobParameter objects.