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

com.emc.mongoose.base.item.op.partial.data.PartialDataOperationImpl Maven / Gradle / Ivy

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

import com.emc.mongoose.base.item.op.composite.data.CompositeDataOperation;
import com.emc.mongoose.base.item.op.data.DataOperationImpl;
import com.emc.mongoose.base.item.DataItem;
import com.emc.mongoose.base.item.op.OpType;
import com.emc.mongoose.base.storage.Credential;

/** Created by andrey on 23.11.16. */
public class PartialDataOperationImpl extends DataOperationImpl
				implements PartialDataOperation {

	private int partNumber;
	private CompositeDataOperation parent;

	public PartialDataOperationImpl() {
		super();
	}

	public PartialDataOperationImpl(
					final int originIndex,
					final OpType opType,
					final I part,
					final String srcPath,
					final String dstPath,
					final Credential credential,
					final int partNumber,
					final CompositeDataOperation parent) {
		super(originIndex, opType, part, srcPath, dstPath, credential, null, 0);
		this.partNumber = partNumber;
		this.parent = parent;
	}

	protected PartialDataOperationImpl(final PartialDataOperationImpl other) {
		super(other);
		this.partNumber = other.partNumber;
		this.parent = other.parent;
	}

	@Override
	public PartialDataOperationImpl result() {
		buildItemPath(item, dstPath == null ? srcPath : dstPath);
		return new PartialDataOperationImpl<>(this);
	}

	@Override
	public final int partNumber() {
		return partNumber;
	}

	@Override
	public final CompositeDataOperation parent() {
		return parent;
	}

	@Override
	public final void finishResponse() {
		super.finishResponse();
		parent.markSubTaskCompleted();
	}
}