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

com.emc.mongoose.api.model.item.SingleItemOutput Maven / Gradle / Ivy

There is a newer version: 4.0.0-alpha5
Show newest version
package com.emc.mongoose.api.model.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 ? null : buffer.get(buffer.size() - 1);
		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