001/* 002 * Copyright 2006-2018 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 at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * 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 and 014 * limitations under the License. 015 */ 016 017package org.springframework.batch.core.converter; 018 019import java.util.Properties; 020 021import org.springframework.batch.core.JobParameters; 022import org.springframework.batch.core.JobParametersBuilder; 023import org.springframework.lang.Nullable; 024 025/** 026 * A factory for {@link JobParameters} instances. A job can be executed with 027 * many possible runtime parameters, which identify the instance of the job. 028 * This converter allows job parameters to be converted to and from Properties. 029 * 030 * @author Dave Syer 031 * @author Mahmoud Ben Hassine 032 * 033 * @see JobParametersBuilder 034 * 035 */ 036public interface JobParametersConverter { 037 038 /** 039 * Get a new {@link JobParameters} instance. If given null, or an empty 040 * properties, an empty JobParameters will be returned. 041 * 042 * @param properties the runtime parameters in the form of String literals. 043 * @return a {@link JobParameters} properties converted to the correct 044 * types. 045 */ 046 JobParameters getJobParameters(@Nullable Properties properties); 047 048 /** 049 * The inverse operation: get a {@link Properties} instance. If given null 050 * or empty JobParameters, an empty Properties should be returned. 051 * 052 * @param params the {@link JobParameters} instance to be converted. 053 * @return a representation of the parameters as properties 054 */ 055 Properties getProperties(@Nullable JobParameters params); 056}