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

com.emc.mongoose.base.item.io.SingleItemOutput Maven / Gradle / Ivy

There is a newer version: 4.3.10
Show newest version
package com.emc.mongoose.base.item.io;

import com.emc.mongoose.base.item.Item;
import com.github.akurilov.commons.io.Input;
import com.github.akurilov.commons.io.Output;
import java.util.List;

/** Created by andrey on 28.04.16. */
public class SingleItemOutput implements Output {

	private volatile T item = null;

	@Override
	public boolean put(final T item) {
		this.item = item;
		return true;
	}

	@Override
	public final int put(final List buffer, final int from, final int to) {
		item = buffer.size() > 0 ? null : buffer.get(to - 1);
		return 1;
	}

	@Override
	public final int put(final List buffer) {
		item = buffer.size() > 0 ? buffer.get(buffer.size() - 1) : null;
		return 1;
	}

	@Override
	public final Input getInput() {
		return new SingleItemInput<>(item);
	}

	@Override
	public final void close() {
		item = null;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy