View Javadoc

1   package org.springframework.batch.sample.domain.order.internal.extractor;
2   
3   import org.springframework.batch.item.file.transform.FieldExtractor;
4   import org.springframework.batch.sample.domain.order.Customer;
5   import org.springframework.batch.sample.domain.order.Order;
6   
7   /**
8    * @author Dan Garrette
9    * @since 2.0.1
10   */
11  public class CustomerFieldExtractor implements FieldExtractor<Order> {
12  
13  	public Object[] extract(Order order) {
14  		Customer customer = order.getCustomer();
15  		return new Object[] { "CUSTOMER:", customer.getRegistrationId(), emptyIfNull(customer.getFirstName()),
16  				emptyIfNull(customer.getMiddleName()), emptyIfNull(customer.getLastName()) };
17  	}
18  
19  	private String emptyIfNull(String s) {
20  		return s != null ? s : "";
21  	}
22  
23  }