All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.topicus.jdbc.statement.Mutations Maven / Gradle / Ivy

There is a newer version: 1.1.6
Show newest version
package nl.topicus.jdbc.statement;

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

import nl.topicus.jdbc.shaded.com.google.cloud.spanner.Mutation;

class Mutations
{
	private final List buffer;

	private final AbstractTablePartWorker worker;

	/**
	 * Single mutation
	 * 
	 * @param mutation
	 */
	Mutations(Mutation mutation)
	{
		this.buffer = Arrays.asList(mutation);
		this.worker = null;
	}

	Mutations(List mutations)
	{
		this.buffer = mutations;
		this.worker = null;
	}

	Mutations(AbstractTablePartWorker worker)
	{
		this.buffer = null;
		this.worker = worker;
	}

	List getMutations()
	{
		if (isWorker())
			throw new IllegalStateException(
					"Cannot call getMutations() on a Mutations-object that returns its results as a worker");
		return buffer;
	}

	AbstractTablePartWorker getWorker()
	{
		return worker;
	}

	boolean isWorker()
	{
		return worker != null;
	}

	long getNumberOfResults()
	{
		if (isWorker())
			return worker.getRecordCount();
		return buffer.size();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy