Record Class JobParameters
java.lang.Object
java.lang.Record
org.springframework.batch.core.job.parameters.JobParameters
- All Implemented Interfaces:
Serializable, Iterable<JobParameter<?>>
public record JobParameters(Set<JobParameter<?>> parameters)
extends Record
implements Serializable, Iterable<JobParameter<?>>
Value object representing runtime parameters of a batch job. Because the parameters
have no individual meaning outside 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. This class is a namespace
of job parameters and all parameters should have a unique name within that namespace.
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 Summary
ConstructorsConstructorDescriptionCreate a new emptyJobParametersinstance.JobParameters(Set<JobParameter<?>> parameters) Create a newJobParametersinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.voidforEach(Consumer<? super JobParameter<?>> action) @Nullable DateTypesafe getter for theDaterepresented by the provided key.@Nullable DateTypesafe getter for theDaterepresented by the provided key.@Nullable DoubleTypesafe getter for theDoublerepresented by the provided key.@Nullable DoubleTypesafe getter for theDoublerepresented by the provided key.Set<JobParameter<?>> Get a set of identifying parameters.@Nullable LocalDategetLocalDate(String key) Typesafe getter for theLocalDaterepresented by the provided key.@Nullable LocalDategetLocalDate(String key, LocalDate defaultValue) Typesafe getter for theLocalDaterepresented by the provided key.@Nullable LocalDateTimegetLocalDateTime(String key) Typesafe getter for theLocalDateTimerepresented by the provided key.@Nullable LocalDateTimegetLocalDateTime(String key, LocalDateTime defaultValue) Typesafe getter for theLocalDateTimerepresented by the provided key.@Nullable LocalTimegetLocalTime(String key) Typesafe getter for theLocalTimerepresented by the provided key.@Nullable LocalTimegetLocalTime(String key, LocalTime defaultValue) Typesafe getter for theLocalTimerepresented by the provided key.@Nullable LongTypesafe getter for theLongrepresented by the provided key.@Nullable LongTypesafe getter for theLongrepresented by the provided key.@Nullable JobParameter<?> getParameter(String key) @Nullable StringTypesafe getter for theStringrepresented by the provided key.@Nullable StringTypesafe getter for theStringrepresented by the provided key.final inthashCode()Returns a hash code value for this object.booleanisEmpty()Iterator<JobParameter<?>> iterator()Set<JobParameter<?>> Get a set of all parameters.toString()Returns a string representation of this record class.Methods inherited from interface Iterable
spliterator
-
Constructor Details
-
JobParameters
-
JobParameters
Create a newJobParametersinstance.- Parameters:
parameters- the set of job parameters, must not benullor empty- Since:
- 6.0
-
-
Method Details
-
getLong
-
getLong
Typesafe getter for theLongrepresented 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
-
getString
Typesafe getter for theStringrepresented 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
-
getDouble
Typesafe getter for theDoublerepresented 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
-
getDate
Typesafe getter for theDaterepresented 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
-
getLocalDate
Typesafe getter for theLocalDaterepresented 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
-
getLocalTime
Typesafe getter for theLocalTimerepresented 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
Typesafe getter for theLocalDateTimerepresented by the provided key.- Parameters:
key- The key for which to get a value.- Returns:
- the
LocalDateTimevalue ornullif the key is absent.
-
getLocalDateTime
Typesafe getter for theLocalDateTimerepresented 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
-
parameters
Get a set of all parameters.- Returns:
- an unmodifiable set containing all parameters.
-
getIdentifyingParameters
Get a set of identifying parameters.- Returns:
- an unmodifiable set containing identifying parameters.
- Since:
- 5.1
-
isEmpty
public boolean isEmpty()- Returns:
trueif the parameters object is empty orfalseotherwise.
-
iterator
- Specified by:
iteratorin interfaceIterable<JobParameter<?>>
-
forEach
- Specified by:
forEachin interfaceIterable<JobParameter<?>>
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
toString
-
hashCode
-