package com.springapp.batch.config;

import com.springapp.batch.mapper.BasicPersonFieldSetMapper;
import com.springapp.batch.mapper.PersonFieldSetMapper;
import org.springframework.batch.item.file.LineMapper;
import org.springframework.batch.item.file.mapping.DefaultLineMapper;
import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
import org.springframework.batch.item.file.transform.LineTokenizer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MapperConfiguration {

    @Autowired
    private PersonFieldSetMapper personFieldSetMapper;

    @Autowired
    private BasicPersonFieldSetMapper basicPersonFieldSetMapper;

    @Bean
    public LineTokenizer tokenizer() {
        return new DelimitedLineTokenizer();
    }

    @Bean
    public LineMapper personLineMapper() {
        DefaultLineMapper mapper = new DefaultLineMapper();
        mapper.setFieldSetMapper(personFieldSetMapper);
        mapper.setLineTokenizer(tokenizer());
        return mapper;
    }

    @Bean
    public LineMapper basicPersonLineMapper() {
        DefaultLineMapper mapper = new DefaultLineMapper();
        mapper.setFieldSetMapper(basicPersonFieldSetMapper);
        mapper.setLineTokenizer(tokenizer());
        return mapper;
    }
}

@@ -264,32 +264,99 @@
 aultLineMapper;%0A
+import org.springframework.batch.item.file.mapping.FieldSetMapper;%0A
 import org.sprin
@@ -1030,115 +1030,122 @@
     
-DefaultLineMapper mapper = new DefaultLine
+return bootstrapLineMapper(personFieldSet
 Mapper
-(
 );%0A    
+%7D%0A%0A
     
-mapper.setFieldSetMapper(personFieldSet
+@Bean%0A    public LineMapper basicPersonLine
 Mapper
-);
+() %7B
 %0A   
@@ -1153,67 +1153,61 @@
     
-mapper.setLineTokenizer(tokenizer());%0A        return m
+return bootstrapLineMapper(basicPersonFieldSetM
 apper
+)
 ;%0A  
@@ -1215,32 +1215,23 @@
  %7D%0A%0A    
-@Bean%0A    public
+private
  LineMap
@@ -1231,34 +1231,32 @@
 LineMapper b
-asicPerson
+ootstrap
 LineMapper()
@@ -1246,32 +1246,61 @@
 strapLineMapper(
+FieldSetMapper fieldSetMapper
 ) %7B%0A        Defa
@@ -1376,36 +1376,25 @@
 ldSetMapper(
-basicPersonF
+f
 ieldSetMappe
@@ -1472,10 +1472,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Remove duplicate code