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

com.emc.mongoose.base.item.io.NewDataItemInput 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.DataItem;
import com.emc.mongoose.base.item.ItemFactory;
import com.emc.mongoose.base.item.naming.ItemNameInput;
import com.github.akurilov.commons.io.Input;
import com.github.akurilov.commons.system.SizeInBytes;
import java.util.List;

public final class NewDataItemInput extends NewItemInput
				implements Input {

	private final SizeInBytes dataSize;

	public NewDataItemInput(
					final ItemFactory itemFactory, final ItemNameInput itemNameInput, final SizeInBytes dataSize) {
		super(itemFactory, itemNameInput);
		this.dataSize = dataSize;
	}

	@Override
	public final D get() {
		return itemFactory.getItem(itemNameInput.get(), itemNameInput.lastId(), dataSize.get());
	}

	@Override
	public final int get(final List buffer, final int maxCount) {
		for (var i = 0; i < maxCount; i++) {
			buffer.add(itemFactory.getItem(itemNameInput.get(), itemNameInput.lastId(), dataSize.get()));
		}
		return maxCount;
	}

	@Override
	public final String toString() {
		return super.toString() + "(" + dataSize.toString() + ")";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy