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.
    • getLocalDate

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

      @Nullable public LocalDate getLocalDate(String key, @Nullable LocalDate defaultValue)
      Typesafe getter for the LocalDate 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.
    • getLocalTime

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

      @Nullable public LocalTime getLocalTime(String key, @Nullable LocalTime defaultValue)
      Typesafe getter for the LocalTime 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.
    • getLocalDateTime

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

      @Nullable public LocalDateTime getLocalDateTime(String key, @Nullable LocalDateTime defaultValue)
      Typesafe getter for the LocalDateTime 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.
    • getParameter

      @Nullable public JobParameter<?> getParameter(String key)
    • getParameters

      public Map<String,JobParameter<?>> getParameters()
      Get a map of all parameters.
      Returns:
      an unmodifiable map containing all parameters.
    • getIdentifyingParameters

      public Map<String,JobParameter<?>> getIdentifyingParameters()
      Get a map of identifying parameters.
      Returns:
      an unmodifiable map containing identifying parameters.
      Since:
      5.1
    • 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

      @Deprecated(since="5.0", forRemoval=true) public Properties toProperties()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 5.0, scheduled for removal in 5.2. Use JobParametersConverter.getProperties(JobParameters)
      Returns:
      The Properties that contain the key and values for the JobParameter objects.