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

com.emc.mongoose.api.model.item.NewDataItemInput 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.system.SizeInBytes;

import java.io.IOException;
import java.util.List;

public final class NewDataItemInput
extends NewItemInput
implements Input {
	
	private final SizeInBytes dataSize;
	
	public NewDataItemInput(
		final ItemFactory itemFactory, final IdStringInput idInput,
		final SizeInBytes dataSize
	) {
		super(itemFactory, idInput);
		this.dataSize = dataSize;
	}
	
	public SizeInBytes getDataSizeInfo() {
		return dataSize;
	}
	
	@Override
	public final D get()
	throws IOException {
		return itemFactory.getItem(idInput.get(), idInput.getAsLong(), dataSize.get());
	}
	
	@Override
	public final int get(final List buffer, final int maxCount)
	throws IOException {
		for(int i = 0; i < maxCount; i ++) {
			buffer.add(itemFactory.getItem(idInput.get(), idInput.getAsLong(), dataSize.get()));
		}
		return maxCount;
	}
	
	@Override
	public final String toString() {
		return super.toString() + "(" + dataSize.toString() + ")";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy