IN PROGRESS - BATCH-711: Upgrade ItemWriter and implementations to use parameterized types
This commit is contained in:
@@ -26,7 +26,7 @@ import org.springframework.batch.item.transform.ItemTransformer;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class LineAggregatorItemTransformer implements ItemTransformer {
|
||||
public class LineAggregatorItemTransformer<T> implements ItemTransformer<T, String> {
|
||||
|
||||
private LineAggregator aggregator = new DelimitedLineAggregator();
|
||||
|
||||
@@ -44,7 +44,7 @@ public class LineAggregatorItemTransformer implements ItemTransformer {
|
||||
*
|
||||
* @see org.springframework.batch.item.transform.ItemTransformer#transform(java.lang.Object)
|
||||
*/
|
||||
public Object transform(Object item) throws Exception {
|
||||
public String transform(T item) throws Exception {
|
||||
return aggregator.aggregate(createFieldSet(item));
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class LineAggregatorItemTransformer implements ItemTransformer {
|
||||
*
|
||||
* @throws ConversionException if the field set cannot be created
|
||||
*/
|
||||
protected FieldSet createFieldSet(Object item) throws ConversionException {
|
||||
protected FieldSet createFieldSet(T item) throws ConversionException {
|
||||
try {
|
||||
return new DefaultFieldSet((String[]) item);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.batch.item.transform.ItemTransformer;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class RecursiveCollectionItemTransformer implements ItemTransformer {
|
||||
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
@@ -11,18 +11,22 @@ import org.springframework.util.Assert;
|
||||
* injected <code>ItemTransformer</code>s (return value of previous
|
||||
* transformation is the entry value of the next).
|
||||
*
|
||||
* Note the user is responsible for injecting a chain of {@link ItemTransformer}
|
||||
* s that conforms to declared input and output types.
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class CompositeItemTransformer implements ItemTransformer, InitializingBean {
|
||||
@SuppressWarnings("unchecked")
|
||||
public class CompositeItemTransformer<I, O> implements ItemTransformer<I, O>, InitializingBean {
|
||||
|
||||
private List<ItemTransformer> itemTransformers;
|
||||
|
||||
public Object transform(Object item) throws Exception {
|
||||
public O transform(I item) throws Exception {
|
||||
Object result = item;
|
||||
for (Iterator<ItemTransformer> iterator = itemTransformers.listIterator(); iterator.hasNext();) {
|
||||
result = iterator.next().transform(result);
|
||||
}
|
||||
return result;
|
||||
return (O) result;
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user