![JAR search and dependency download from the Maven repository](/logo.png)
com.alexkasko.springjdbc.parallel.accessor.ImmutableAccessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of parallel-queries Show documentation
Show all versions of parallel-queries Show documentation
Processes given SQL query in parallel in multiple data sources (assuming that all data source
contain the same data). Combined results from multiple queries are exposed to application as
java.util.Iterator. Worker thread use spring's JdbcTemplate with named parameters support.
package com.alexkasko.springjdbc.parallel.accessor;
import com.google.common.collect.ForwardingCollection;
import com.google.common.collect.ImmutableList;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import java.util.Collection;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Abstract accessor implementation as a wrapper around provided collection.
* Copies provided collection into inner immutable one on creation. Thread-safe.
*
* @author alexkasko
* Date: 6/11/12
* @see DataSourceAccessor
*/
public abstract class ImmutableAccessor
extends ForwardingCollection implements DataSourceAccessor {
protected final ImmutableList delegate;
/**
* Protected constructor, copies provided collection into inner immutable one
*
* @param collection collection to wrap
*/
protected ImmutableAccessor(Collection collection) {
checkNotNull(collection, "Provided collection must be not null");
checkArgument(collection.size() > 0, "Provided collection must be not empty");
this.delegate = ImmutableList.copyOf(collection);
}
/**
* {@inheritDoc}
*/
@Override
protected Collection delegate() {
return delegate;
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("ImmutableAccessor");
sb.append("{delegate=").append(delegate);
sb.append('}');
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy