IN PROGRESS - BATCH-709: Change all collections to use generics

This commit is contained in:
robokaso
2008-07-15 11:52:51 +00:00
parent 81ccf42b61
commit e19dab884b
5 changed files with 29 additions and 42 deletions

View File

@@ -54,7 +54,7 @@ final class PropertyMatches {
* @param propertyName the name of the property to find possible matches for
* @param beanClass the bean class to search for matches
*/
public static PropertyMatches forProperty(String propertyName, Class beanClass) {
public static PropertyMatches forProperty(String propertyName, Class<?> beanClass) {
return forProperty(propertyName, beanClass, DEFAULT_MAX_DISTANCE);
}
@@ -64,7 +64,7 @@ final class PropertyMatches {
* @param beanClass the bean class to search for matches
* @param maxDistance the maximum property distance allowed for matches
*/
public static PropertyMatches forProperty(String propertyName, Class beanClass, int maxDistance) {
public static PropertyMatches forProperty(String propertyName, Class<?> beanClass, int maxDistance) {
return new PropertyMatches(propertyName, beanClass, maxDistance);
}
@@ -81,7 +81,7 @@ final class PropertyMatches {
/**
* Create a new PropertyMatches instance for the given property.
*/
private PropertyMatches(String propertyName, Class beanClass, int maxDistance) {
private PropertyMatches(String propertyName, Class<?> beanClass, int maxDistance) {
this.propertyName = propertyName;
this.possibleMatches = calculateMatches(BeanUtils.getPropertyDescriptors(beanClass), maxDistance);
}

View File

@@ -7,35 +7,33 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
/**
* Composite {@link ItemTransformer} that passes the item through a sequence
* of injected <code>ItemTransformer</code>s (return value of previous transformation
* is the entry value of the next).
* Composite {@link ItemTransformer} that passes the item through a sequence of
* injected <code>ItemTransformer</code>s (return value of previous
* transformation is the entry value of the next).
*
* @author Robert Kasanicky
*/
public class CompositeItemTransformer implements ItemTransformer, InitializingBean {
private List itemTransformers;
private List<ItemTransformer> itemTransformers;
public Object transform(Object item) throws Exception {
Object result = item;
for (Iterator iterator = itemTransformers.listIterator(); iterator.hasNext();) {
result = ((ItemTransformer)iterator.next()).transform(result);
for (Iterator<ItemTransformer> iterator = itemTransformers.listIterator(); iterator.hasNext();) {
result = iterator.next().transform(result);
}
return result;
}
public void afterPropertiesSet() throws Exception {
Assert.notEmpty(itemTransformers);
for (Iterator iterator = itemTransformers.iterator(); iterator.hasNext();) {
Assert.isInstanceOf(ItemTransformer.class, iterator.next());
}
}
/**
* @param itemTransformers will be chained to produce a composite transformation.
* @param itemTransformers will be chained to produce a composite
* transformation.
*/
public void setItemTransformers(List itemTransformers) {
public void setItemTransformers(List<ItemTransformer> itemTransformers) {
this.itemTransformers = itemTransformers;
}

View File

@@ -17,7 +17,6 @@
package org.springframework.batch.item.validator;
import java.util.Collection;
import java.util.Iterator;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
@@ -70,10 +69,10 @@ public class SpringValidator implements Validator, InitializingBean {
* Append the string representation of elements of the collection (separated
* by new lines) to the given StringBuilder.
*/
private void appendCollection(Collection collection, StringBuffer builder) {
for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
private void appendCollection(Collection<?> collection, StringBuffer builder) {
for (Object value : collection) {
builder.append("\n");
builder.append(iterator.next().toString());
builder.append(value.toString());
}
}

View File

@@ -81,7 +81,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
private String rootTagName = DEFAULT_ROOT_TAG_NAME;
// root element attributes
private Map rootElementAttributes = null;
private Map<String, String> rootElementAttributes = null;
// signalizes that marshalling was restarted
private boolean restarted = false;
@@ -113,9 +113,9 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
// holds the list of items for writing before they are actually written on
// #flush()
private List buffer = new ArrayList();
private List<Object> buffer = new ArrayList<Object>();
private List headers = new ArrayList();
private List<Object> headers = new ArrayList<Object>();
public StaxEventItemWriter() {
setName(ClassUtils.getShortName(StaxEventItemWriter.class));
@@ -199,7 +199,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
*
* @return attributes of the root element
*/
public Map getRootElementAttributes() {
public Map<String, String> getRootElementAttributes() {
return rootElementAttributes;
}
@@ -208,7 +208,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
*
* @param rootElementAttributes attributes of the root element
*/
public void setRootElementAttributes(Map rootElementAttributes) {
public void setRootElementAttributes(Map<String, String> rootElementAttributes) {
this.rootElementAttributes = rootElementAttributes;
}
@@ -260,11 +260,11 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
}
open(startAtPosition);
if (startAtPosition==0) {
for (Iterator iterator = headers.iterator(); iterator.hasNext();) {
Object header = (Object) iterator.next();
write(header);
if (startAtPosition == 0) {
for (Iterator<Object> iterator = headers.listIterator(); iterator.hasNext();) {
Object header = iterator.next();
write(header);
}
}
}
@@ -328,9 +328,8 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
// write root tag attributes
if (!CollectionUtils.isEmpty(getRootElementAttributes())) {
for (Iterator i = getRootElementAttributes().entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
writer.add(factory.createAttribute((String) entry.getKey(), (String) entry.getValue()));
for (Map.Entry<String, String> entry : getRootElementAttributes().entrySet()) {
writer.add(factory.createAttribute(entry.getKey(), entry.getValue()));
}
}
@@ -455,7 +454,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
*/
public void flush() throws FlushFailedException {
for (Iterator iterator = buffer.listIterator(); iterator.hasNext();) {
for (Iterator<Object> iterator = buffer.listIterator(); iterator.hasNext();) {
Object item = iterator.next();
serializer.serializeObject(eventWriter, item);
}