Replace explicit type with diamond operator in samples module

This commit is contained in:
Drummond Dawson
2018-10-09 19:54:54 -04:00
committed by Mahmoud Ben Hassine
parent 3fe5fc3427
commit e4dd5d9c60
33 changed files with 49 additions and 49 deletions

View File

@@ -82,7 +82,7 @@ public class ColumnRangePartitioner implements Partitioner {
int max = jdbcTemplate.queryForObject("SELECT MAX(" + column + ") from " + table, Integer.class);
int targetSize = (max - min) / gridSize + 1;
Map<String, ExecutionContext> result = new HashMap<String, ExecutionContext>();
Map<String, ExecutionContext> result = new HashMap<>();
int number = 0;
int start = min;
int end = start + targetSize - 1;

View File

@@ -123,7 +123,7 @@ InitializingBean, DisposableBean {
}
}, id);
return new ProcessIndicatorItemWrapper<T>(id, result);
return new ProcessIndicatorItemWrapper<>(id, result);
}
@Override

View File

@@ -61,6 +61,6 @@ public class RetrySampleConfiguration {
@Bean
protected ItemWriter<Object> writer() {
return new RetrySampleItemWriter<Object>();
return new RetrySampleItemWriter<>();
}
}

View File

@@ -37,7 +37,7 @@ import org.springframework.mail.MailMessage;
public class TestMailErrorHandler implements MailErrorHandler {
private static final Log LOGGER = LogFactory.getLog(TestMailErrorHandler.class);
private List<MailMessage> failedMessages = new ArrayList<MailMessage>();
private List<MailMessage> failedMessages = new ArrayList<>();
@Override
public void handle(MailMessage failedMessage, Exception ex) {

View File

@@ -96,7 +96,7 @@ public class AggregateItemFieldSetMapper<T> implements FieldSetMapper<AggregateI
return AggregateItem.getFooter();
}
return new AggregateItem<T>(delegate.mapFieldSet(fieldSet));
return new AggregateItem<>(delegate.mapFieldSet(fieldSet));
}

View File

@@ -105,7 +105,7 @@ public class AggregateItemReader<T> implements ItemReader<List<T>> {
*
*/
private class ResultHolder {
private List<T> records = new ArrayList<T>();
private List<T> records = new ArrayList<>();
private boolean exhausted = false;
public List<T> getRecords() {

View File

@@ -137,7 +137,7 @@ public class OrderItemReader implements ItemReader<Order> {
else if (LineItem.LINE_ID_ITEM.equals(lineId)) {
log.debug("MAPPING LINE ITEM");
if (order.getLineItems() == null) {
order.setLineItems(new ArrayList<LineItem>());
order.setLineItems(new ArrayList<>());
}
order.getLineItems().add(itemMapper.mapFieldSet(fieldSet));
}

View File

@@ -32,9 +32,9 @@ import org.springframework.validation.Validator;
public class OrderValidator implements Validator {
private static final List<String> CARD_TYPES = new ArrayList<String>();
private static final List<String> SHIPPER_IDS = new ArrayList<String>();
private static final List<String> SHIPPER_TYPES = new ArrayList<String>();
private static final List<String> CARD_TYPES = new ArrayList<>();
private static final List<String> SHIPPER_IDS = new ArrayList<>();
private static final List<String> SHIPPER_TYPES = new ArrayList<>();
private static final long MAX_ID = 9999999999L;
private static final BigDecimal BD_MIN = new BigDecimal("0.0");
private static final BigDecimal BD_MAX = new BigDecimal("99999999.99");

View File

@@ -27,7 +27,7 @@ public class Person {
private String last_name = "";
private int age = 0;
private Address address = new Address();
private List<Child> children = new ArrayList<Child>();
private List<Child> children = new ArrayList<>();
public Person() {
children.add(new Child());

View File

@@ -43,7 +43,7 @@ public class PersonService {
Person person = new Person();
Address address = new Address();
Child child = new Child();
List<Child> children = new ArrayList<Child>(1);
List<Child> children = new ArrayList<>(1);
children.add(child);

View File

@@ -37,7 +37,7 @@ public enum CustomerOperation {
}
static{
CODE_MAP = new HashMap<Character,CustomerOperation>();
CODE_MAP = new HashMap<>();
for(CustomerOperation operation:values()){
CODE_MAP.put(operation.getCode(), operation);
}

View File

@@ -34,7 +34,7 @@ public class HibernateCreditDao implements
CustomerCreditDao, RepeatListener {
private int failOnFlush = -1;
private List<Throwable> errors = new ArrayList<Throwable>();
private List<Throwable> errors = new ArrayList<>();
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {

View File

@@ -43,7 +43,7 @@ public class TradeWriter extends ItemStreamSupport implements ItemWriter<Trade>
private TradeDao dao;
private List<String> failingCustomers = new ArrayList<String>();
private List<String> failingCustomers = new ArrayList<>();
private BigDecimal totalPrice = BigDecimal.ZERO;

View File

@@ -36,7 +36,7 @@ public class DefaultJobLoader implements JobLoader, ApplicationContextAware {
private ApplicationContext applicationContext;
private Map<String, String> configurations = new HashMap<String, String>();
private Map<String, String> configurations = new HashMap<>();
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
@@ -49,7 +49,7 @@ public class DefaultJobLoader implements JobLoader, ApplicationContextAware {
@Override
public Map<String, String> getConfigurations() {
Map<String, String> result = new HashMap<String, String>(configurations);
Map<String, String> result = new HashMap<>(configurations);
for (String jobName : registry.getJobNames()) {
try {
Job configuration = registry.getJob(jobName);

View File

@@ -47,7 +47,7 @@ public class CustomerFilterJobFunctionalTests {
private List<Customer> customers;
private int activeRow = 0;
private JdbcOperations jdbcTemplate;
private Map<String, Double> credits = new HashMap<String, Double>();
private Map<String, Double> credits = new HashMap<>();
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;

View File

@@ -154,7 +154,7 @@ public class HibernateFailureJobFunctionalTests {
* Credit was increased by CREDIT_INCREASE
*/
protected void validatePostConditions() throws Exception {
final List<BigDecimal> matches = new ArrayList<BigDecimal>();
final List<BigDecimal> matches = new ArrayList<>();
new TransactionTemplate(transactionManager).execute(new TransactionCallback<Void>() {
@Override

View File

@@ -69,7 +69,7 @@ public class PartitionFileJobFunctionalTests implements ApplicationContextAware
.containsBeanDefinition("outputTestReader"));
open(inputReader);
List<CustomerCredit> inputs = new ArrayList<CustomerCredit>(getCredits(inputReader));
List<CustomerCredit> inputs = new ArrayList<>(getCredits(inputReader));
close(inputReader);
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
@@ -79,7 +79,7 @@ public class PartitionFileJobFunctionalTests implements ApplicationContextAware
ItemReader<CustomerCredit> outputReader = (ItemReader<CustomerCredit>) applicationContext
.getBean("outputTestReader");
open(outputReader);
List<CustomerCredit> outputs = new ArrayList<CustomerCredit>(getCredits(outputReader));
List<CustomerCredit> outputs = new ArrayList<>(getCredits(outputReader));
close(outputReader);
assertEquals(inputs.size(), outputs.size());
@@ -98,7 +98,7 @@ public class PartitionFileJobFunctionalTests implements ApplicationContextAware
*/
private Set<CustomerCredit> getCredits(ItemReader<CustomerCredit> reader) throws Exception {
CustomerCredit credit;
Set<CustomerCredit> result = new LinkedHashSet<CustomerCredit>();
Set<CustomerCredit> result = new LinkedHashSet<>();
while ((credit = reader.read()) != null) {
result.add(credit);

View File

@@ -69,7 +69,7 @@ public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware
.containsBeanDefinition("outputTestReader"));
open(inputReader);
List<CustomerCredit> inputs = new ArrayList<CustomerCredit>(getCredits(inputReader));
List<CustomerCredit> inputs = new ArrayList<>(getCredits(inputReader));
close(inputReader);
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
@@ -79,7 +79,7 @@ public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware
ItemReader<CustomerCredit> outputReader = (ItemReader<CustomerCredit>) applicationContext
.getBean("outputTestReader");
open(outputReader);
List<CustomerCredit> outputs = new ArrayList<CustomerCredit>(getCredits(outputReader));
List<CustomerCredit> outputs = new ArrayList<>(getCredits(outputReader));
close(outputReader);
assertEquals(inputs.size(), outputs.size());
@@ -98,7 +98,7 @@ public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware
*/
private Set<CustomerCredit> getCredits(ItemReader<CustomerCredit> reader) throws Exception {
CustomerCredit credit;
Set<CustomerCredit> result = new LinkedHashSet<CustomerCredit>();
Set<CustomerCredit> result = new LinkedHashSet<>();
while ((credit = reader.read()) != null) {
result.add(credit);
}

View File

@@ -53,7 +53,7 @@ public class TradeJobFunctionalTests {
private List<Trade> trades;
private int activeRow = 0;
private JdbcOperations jdbcTemplate;
private Map<String, Double> credits = new HashMap<String, Double>();
private Map<String, Double> credits = new HashMap<>();
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;

View File

@@ -43,12 +43,12 @@ public class CustomItemReaderTests {
*/
@Before
public void setUp() throws Exception {
List<String> items = new ArrayList<String>();
List<String> items = new ArrayList<>();
items.add("1");
items.add("2");
items.add("3");
itemReader = new CustomItemReader<String>(items);
itemReader = new CustomItemReader<>(items);
}
@Test
@@ -65,11 +65,11 @@ public class CustomItemReaderTests {
((ItemStream)itemReader).open(executionContext);
assertEquals("1", itemReader.read());
((ItemStream)itemReader).update(executionContext);
List<String> items = new ArrayList<String>();
List<String> items = new ArrayList<>();
items.add("1");
items.add("2");
items.add("3");
itemReader = new CustomItemReader<String>(items);
itemReader = new CustomItemReader<>(items);
((ItemStream)itemReader).open(executionContext);
assertEquals("2", itemReader.read());

View File

@@ -36,7 +36,7 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor
public class CustomItemWriterTests {
@Test
public void testFlush() throws Exception {
CustomItemWriter<String> itemWriter = new CustomItemWriter<String>();
CustomItemWriter<String> itemWriter = new CustomItemWriter<>();
itemWriter.write(Collections.singletonList("1"));
assertEquals(1, itemWriter.getOutput().size());
itemWriter.write(Arrays.asList("2","3"));

View File

@@ -43,8 +43,8 @@ public class ExceptionThrowingItemReaderProxyTests {
public void testProcess() throws Exception {
//create module and set item processor and iteration count
ExceptionThrowingItemReaderProxy<String> itemReader = new ExceptionThrowingItemReaderProxy<String>();
itemReader.setDelegate(new ListItemReader<String>(new ArrayList<String>() {{
ExceptionThrowingItemReaderProxy<String> itemReader = new ExceptionThrowingItemReaderProxy<>();
itemReader.setDelegate(new ListItemReader<>(new ArrayList<String>() {{
add("a");
add("b");
add("c");

View File

@@ -90,7 +90,7 @@ public class StagingItemReaderTests {
String item = wrapper.getItem();
assertEquals("FOO", item);
StagingItemProcessor<String> updater = new StagingItemProcessor<String>();
StagingItemProcessor<String> updater = new StagingItemProcessor<>();
updater.setJdbcTemplate(jdbcTemplate);
updater.process(wrapper);

View File

@@ -26,7 +26,7 @@ import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
public class AggregateItemFieldSetMapperTests {
private AggregateItemFieldSetMapper<String> mapper = new AggregateItemFieldSetMapper<String>();
private AggregateItemFieldSetMapper<String> mapper = new AggregateItemFieldSetMapper<>();
@Test
public void testDefaultBeginRecord() throws Exception {

View File

@@ -39,7 +39,7 @@ public class AggregateItemReaderTests {
case 1:
case 2:
case 3:
return new AggregateItem<String>("line");
return new AggregateItem<>("line");
case 4:
return AggregateItem.getFooter();
default:
@@ -49,7 +49,7 @@ public class AggregateItemReaderTests {
};
provider = new AggregateItemReader<String>();
provider = new AggregateItemReader<>();
provider.setItemReader(input);
}

View File

@@ -70,7 +70,7 @@ public class OrderValidatorTests {
order.setOrderId(-5);
order.setOrderDate(new Date(new Date().getTime() + 1000000000L));
order.setTotalLines(10);
order.setLineItems(new ArrayList<LineItem>());
order.setLineItems(new ArrayList<>());
Errors errors = new BeanPropertyBindingResult(order, "validOrder");
@@ -85,7 +85,7 @@ public class OrderValidatorTests {
order.setOrderId(Long.MAX_VALUE);
order.setOrderDate(new Date(new Date().getTime() - 1000));
order.setTotalLines(0);
List<LineItem> items = new ArrayList<LineItem>();
List<LineItem> items = new ArrayList<>();
items.add(new LineItem());
order.setLineItems(items);
@@ -101,7 +101,7 @@ public class OrderValidatorTests {
order.setOrderId(5L);
order.setOrderDate(new Date(new Date().getTime() - 1000));
order.setTotalLines(1);
items = new ArrayList<LineItem>();
items = new ArrayList<>();
items.add(new LineItem());
order.setLineItems(items);
@@ -307,7 +307,7 @@ public class OrderValidatorTests {
@Test
public void testValidLineItems() {
Order order = new Order();
List<LineItem> lineItems = new ArrayList<LineItem>();
List<LineItem> lineItems = new ArrayList<>();
lineItems.add(buildLineItem(-5, 5.00, 0, 0, 2, 3, 3, 30));
lineItems.add(buildLineItem(Long.MAX_VALUE, 5.00, 0, 0, 2, 3, 3, 30));
lineItems.add(buildLineItem(6, -5.00, 0, 0, 2, 3, 3, 0));

View File

@@ -27,7 +27,7 @@ import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
public class ItemTrackingTradeItemWriter implements ItemWriter<Trade> {
private List<Trade> items = new ArrayList<Trade>();
private List<Trade> items = new ArrayList<>();
private String writeFailureISIN;
private JdbcOperations jdbcTemplate;
@@ -45,7 +45,7 @@ public class ItemTrackingTradeItemWriter implements ItemWriter<Trade> {
@Override
public void write(List<? extends Trade> items) throws Exception {
List<Trade> newItems = new ArrayList<Trade>();
List<Trade> newItems = new ArrayList<>();
for (Trade t : items) {
if (t.getIsin().equals(this.writeFailureISIN)) {

View File

@@ -103,7 +103,7 @@ public abstract class AbstractIoSampleTests {
*/
private List<CustomerCredit> getCredits(ItemReader<CustomerCredit> reader) throws Exception {
CustomerCredit credit;
List<CustomerCredit> result = new ArrayList<CustomerCredit>();
List<CustomerCredit> result = new ArrayList<>();
while ((credit = reader.read()) != null) {
result.add(credit);
}

View File

@@ -35,7 +35,7 @@ public class MultiLineTradeItemWriter implements ItemWriter<Trade>, ItemStream {
@Override
public void write(List<? extends Trade> items) throws Exception {
List<String> lines = new ArrayList<String>();
List<String> lines = new ArrayList<>();
for (Trade t : items) {
lines.add("BEGIN");

View File

@@ -37,7 +37,7 @@ public class JobExecutionNotificationPublisherTests {
@Test
public void testRepeatOperationsOpenUsed() throws Exception {
final List<Notification> list = new ArrayList<Notification>();
final List<Notification> list = new ArrayList<>();
publisher.setNotificationPublisher(new NotificationPublisher() {
@Override

View File

@@ -44,7 +44,7 @@ import org.springframework.jmx.support.MBeanServerConnectionFactoryBean;
*/
public class RemoteLauncherTests {
private static Log logger = LogFactory.getLog(RemoteLauncherTests.class);
private static List<Exception> errors = new ArrayList<Exception>();
private static List<Exception> errors = new ArrayList<>();
private static JobOperator launcher;
private static JobLoader loader;
static private Thread thread;

View File

@@ -50,7 +50,7 @@ import org.springframework.batch.core.repository.JobRestartException;
public class JobLauncherDetailsTests {
private JobLauncherDetails details = new JobLauncherDetails();
private TriggerFiredBundle firedBundle;
private List<Serializable> list = new ArrayList<Serializable>();
private List<Serializable> list = new ArrayList<>();
@Before
public void setUp() throws Exception {

View File

@@ -30,7 +30,7 @@ import org.junit.Test;
*/
public class RetrySampleItemWriterTests {
private RetrySampleItemWriter<Object> processor = new RetrySampleItemWriter<Object>();
private RetrySampleItemWriter<Object> processor = new RetrySampleItemWriter<>();
/*
* Processing throws exception on 2nd and 3rd call.