Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructors with var args/Lists #686

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 the original author or authors.
* Copyright 2006-2019 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.
Expand All @@ -15,6 +15,7 @@
*/
package org.springframework.batch.core.listener;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

Expand All @@ -30,6 +31,28 @@ public class CompositeChunkListener implements ChunkListener {

private OrderedComposite<ChunkListener> listeners = new OrderedComposite<>();

public CompositeChunkListener() {

}

/**
* Convenience constructor for setting the {@link ChunkListener}s.
*
* @param listeners list of {@link ChunkListener}.
*/
public CompositeChunkListener(List<? extends ChunkListener> listeners) {
setListeners(listeners);
}

/**
* Convenience constructor for setting the {@link ChunkListener}s.
*
* @param listeners array of {@link ChunkListener}.
*/
public CompositeChunkListener(ChunkListener... listeners) {
this(Arrays.asList(listeners));
}

/**
* Public setter for the listeners.
*
Expand Down
Expand Up @@ -21,6 +21,7 @@
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

import java.util.Arrays;
import java.util.List;

/**
Expand All @@ -38,6 +39,30 @@ public class CompositeItemProcessor<I, O> implements ItemProcessor<I, O>, Initia

private List<? extends ItemProcessor<?, ?>> delegates;

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")
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2019 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.
Expand Down Expand Up @@ -33,6 +33,15 @@ public class CompositeItemStream implements ItemStream {

private 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 = streams;
}

/**
* Public setter for the {@link ItemStream}s.
*
Expand Down Expand Up @@ -63,6 +72,24 @@ 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.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2019 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.
Expand All @@ -24,6 +24,7 @@
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;

import java.util.Arrays;
import java.util.List;

/**
Expand All @@ -41,6 +42,28 @@ public class CompositeItemWriter<T> implements ItemStreamWriter<T>, Initializing

private boolean ignoreItemStream = false;

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.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2019 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.
Expand Down Expand Up @@ -33,6 +33,37 @@ public class CompositeRepeatListener implements RepeatListener {

private List<RepeatListener> listeners = new ArrayList<>();

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.
*
Expand Down