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

net.sf.jabb.seqtx.SequentialTransaction Maven / Gradle / Ivy

/**
 * 
 */
package net.sf.jabb.seqtx;

import java.io.Serializable;
import java.time.Duration;
import java.time.Instant;

/**
 * Partially modifiable version of the progress transaction.
 * @author James Hu
 *
 */
public interface SequentialTransaction extends ReadOnlySequentialTransaction{
	/**
	 * Set the proposed ID of this transaction
	 * @param proposedTransactionId	proposed ID of the transaction
	 */
	void setTransactionId(String proposedTransactionId);
	
	/**
	 * Set the ID of the processor that owns the transaction
	 * @param processorId	ID of the owner processor
	 */
	void setProcessorId(String processorId);

	/**
	 * Set the start position of the transaction
	 * @param startPosition	the start position, for example the sequence number in input data stream
	 */
	void setStartPosition(String startPosition);
	
	/**
	 * Set the end position of the transaction
	 * @param endPosition	the end position, for example the sequence number in input data stream
	 */
	void setEndPosition(String endPosition);
	
	/**
	 * Set the time that the transaction will time out
	 * @param timeout	the time that the transaction will time out
	 */
	void setTimeout(Instant timeout);
	
	/**
	 * Set the time that the transaction will time out
	 * @param timeoutDuration	the duration after which the transaction will time out
	 */
	default void setTimeout(Duration timeoutDuration){
		setTimeout(Instant.now().plus(timeoutDuration));
	}
	
	/**
	 * Set the details of the transaction
	 * @param detail	the detail
	 */
	void setDetail(Serializable detail);
	
	
	default void setStartPosition(Number pos){
		setStartPosition(pos == null ? null : pos.toString());
	}

	default void setEndPosition(Number pos){
		setEndPosition(pos == null ? null : pos.toString());
	}

	default void setEndPositionNull(){
		setEndPosition((String)null);
	}

	default void setDetailNull(){
		setDetail((Serializable)null);
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy