Replace explicit type with diamond operator in samples module
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
3fe5fc3427
commit
e4dd5d9c60
@@ -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;
|
||||
|
||||
@@ -123,7 +123,7 @@ InitializingBean, DisposableBean {
|
||||
}
|
||||
}, id);
|
||||
|
||||
return new ProcessIndicatorItemWrapper<T>(id, result);
|
||||
return new ProcessIndicatorItemWrapper<>(id, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,6 +61,6 @@ public class RetrySampleConfiguration {
|
||||
|
||||
@Bean
|
||||
protected ItemWriter<Object> writer() {
|
||||
return new RetrySampleItemWriter<Object>();
|
||||
return new RetrySampleItemWriter<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user