Add constructors with var args/Lists
For classes that have a setter for a List<T> field, create Constructors that take List<T> and var args of T. Issue #686
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
968a5b5b2e
commit
15e18e5fcd
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,33 @@ public class CompositeItemProcessor<I, O> implements ItemProcessor<I, O>, Initia
|
||||
|
||||
private List<? extends ItemProcessor<?, ?>> delegates;
|
||||
|
||||
/**
|
||||
* Default constrcutor
|
||||
*/
|
||||
public CompositeItemProcessor() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor for setting the delegates.
|
||||
*
|
||||
* @param delegates array of {@link ItemProcessor} delegates that will work on the
|
||||
* item.
|
||||
*/
|
||||
public CompositeItemProcessor(ItemProcessor<?, ?>... delegates) {
|
||||
this(Arrays.asList(delegates));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor for setting the delegates.
|
||||
*
|
||||
* @param delegates list of {@link ItemProcessor} delegates that will work on the
|
||||
* item.
|
||||
*/
|
||||
public CompositeItemProcessor(List<? extends ItemProcessor<?, ?>> delegates) {
|
||||
setDelegates(delegates);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,6 +34,15 @@ public class CompositeItemStream implements ItemStream {
|
||||
|
||||
private final List<ItemStream> streams = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Public setter for the {@link ItemStream}s.
|
||||
*
|
||||
* @param streams {@link List} of {@link ItemStream}.
|
||||
*/
|
||||
public void setStreams(List<ItemStream> streams) {
|
||||
this.streams.addAll(streams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the {@link ItemStream}s.
|
||||
*
|
||||
@@ -58,12 +67,30 @@ public class CompositeItemStream implements ItemStream {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Default constrcutor
|
||||
*/
|
||||
public CompositeItemStream() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor for setting the {@link ItemStream}s.
|
||||
*
|
||||
* @param streams {@link List} of {@link ItemStream}.
|
||||
*/
|
||||
public CompositeItemStream(List<ItemStream> streams) {
|
||||
setStreams(streams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor for setting the {@link ItemStream}s.
|
||||
*
|
||||
* @param streams array of {@link ItemStream}.
|
||||
*/
|
||||
public CompositeItemStream(ItemStream... streams) {
|
||||
setStreams(streams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple aggregate {@link ExecutionContext} provider for the contributions
|
||||
* registered under the given key.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,31 @@ public class CompositeItemWriter<T> implements ItemStreamWriter<T>, Initializing
|
||||
|
||||
private boolean ignoreItemStream = false;
|
||||
|
||||
/**
|
||||
* Default constrcutor
|
||||
*/
|
||||
public CompositeItemWriter() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor for setting the delegates.
|
||||
*
|
||||
* @param delegates the list of delegates to use.
|
||||
*/
|
||||
public CompositeItemWriter(List<ItemWriter<? super T>> delegates) {
|
||||
setDelegates(delegates);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor for setting the delegates.
|
||||
*
|
||||
* @param delegates the array of delegates to use.
|
||||
*/
|
||||
public CompositeItemWriter(ItemWriter<? super T>... delegates) {
|
||||
this(Arrays.asList(delegates));
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes the policy whether to call the open, close, or update methods for the
|
||||
* item writer delegates associated with the CompositeItemWriter.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,6 +33,40 @@ public class CompositeRepeatListener implements RepeatListener {
|
||||
|
||||
private List<RepeatListener> listeners = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Default constrcutor
|
||||
*/
|
||||
public CompositeRepeatListener() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor for setting the {@link RepeatListener}s.
|
||||
*
|
||||
* @param listeners {@link List} of RepeatListeners to be used by the CompositeRepeatListener.
|
||||
*/
|
||||
public CompositeRepeatListener(List<RepeatListener> listeners) {
|
||||
setListeners(listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor for setting the {@link RepeatListener}s.
|
||||
*
|
||||
* @param listeners array of RepeatListeners to be used by the CompositeRepeatListener.
|
||||
*/
|
||||
public CompositeRepeatListener(RepeatListener... listeners) {
|
||||
setListeners(listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the listeners.
|
||||
*
|
||||
* @param listeners {@link List} of RepeatListeners to be used by the CompositeRepeatListener.
|
||||
*/
|
||||
public void setListeners(List<RepeatListener> listeners) {
|
||||
this.listeners = listeners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the listeners.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user