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

com.emc.mongoose.api.model.io.task.token.BasicTokenIoTaskBuilder Maven / Gradle / Ivy

There is a newer version: 4.0.0-alpha5
Show newest version
package com.emc.mongoose.api.model.io.task.token;

import com.emc.mongoose.api.model.io.task.BasicIoTaskBuilder;
import com.emc.mongoose.api.model.item.TokenItem;
import com.emc.mongoose.api.model.storage.Credential;

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

/**
 Created by kurila on 14.07.16.
 */
public class BasicTokenIoTaskBuilder>
extends BasicIoTaskBuilder
implements TokenIoTaskBuilder {

	@Override @SuppressWarnings("unchecked")
	public O getInstance(final I item)
	throws IOException {
		final String uid;
		return (O) new BasicTokenIoTask<>(
			originCode, ioType, item, Credential.getInstance(uid = getNextUid(), getNextSecret(uid))
		);
	}

	@Override @SuppressWarnings("unchecked")
	public void getInstances(final List items, final List buff)
	throws IOException {
		String uid;
		for(final I item : items) {
			buff.add(
				(O) new BasicTokenIoTask<>(
					originCode, ioType, item,
					Credential.getInstance(uid = getNextUid(), getNextSecret(uid))
				)
			);
		}
	}
}