Created
February 11, 2016 07:09
-
-
Save theflofly/aa6b88fab72ad7a53f50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tcb.issue1.job; | |
import com.tcb.issue1.model.Car; | |
import com.tcb.issue1.model.Offer; | |
import org.slf4j.Logger; | |
import org.springframework.batch.item.ItemProcessor; | |
import static org.slf4j.LoggerFactory.getLogger; | |
/** | |
* This class is a processor, it takes a Car as parameter then returns an Offer. | |
* | |
* Created by Florian.Courtial on 27/01/16. | |
*/ | |
public class CarProcessor implements ItemProcessor<Car, Offer> { | |
private Logger logger = getLogger(getClass()); | |
@Override | |
public Offer process(Car car) throws Exception { | |
Offer offer = new Offer(); | |
offer.setId(car.getId()); | |
offer.setAge(car.getAge()); | |
offer.setMilesNumber(car.getMilesNumber()); | |
offer.setModel(car.getModel()); | |
offer.setPrice(car.getAge() * 100000 - car.getMilesNumber()); | |
logger.info("Converting : " + car.toString() + " to " + offer.toString()); | |
return offer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment