The final version for now is:
interface IByteStateConverter
{
IIdentifiable ConvertFromByteArray(byte[] array);
byte[] ConvertToByteArray(IIdentifiable stateId);
}
public interface IManageState
{
/// <summary>
/// Store the linkable component's current State
/// </summary>
/// <returns>Object that identifies the stored state.</returns>
IIdentifiable KeepCurrentState();
/// <summary>
/// Restores the state identified by the parameter stateID. If the state identifier identified by
/// stateID is not known by the linkable component an InvalidOperationException should be trown.
/// </summary>
/// <param name="stateID">Object that identifies the state to be restored.</param>
void RestoreState(IIdentifiable stateId);
/// <summary>
/// Clears a state from the linkable component's memory. If the state identifier identified by
/// stateID is not known by the linkable component an exception should be trown.
/// </summary>
/// <param name="stateID">Object that identifies the state to be cleared.</param>
void ClearState(IIdentifiable stateId);
}
Suggestion for IState and IManageState refactoring in Java version:
public interface IByteStateConverter {
IIdentifiable convertFromByteArray(byte[] array);
byte[] convertToByteArray(IIdentifiable stateId);
}
public interface IManageState {
public IIdentifiable keepCurrentState();
public void restoreState(IState state);
public void clearState(IState state);
}
Previous version:
public interface IManageState
{
/// <summary>
/// Store the linkable component's current State
/// </summary>
/// <returns>Object that identifies the stored state.</returns>
Object KeepCurrentState();
/// <summary>
/// Restores the state identified by the parameter stateID. If the state identifier identified by
/// stateID is not known by the linkable component an exception should be trown.
/// </summary>
/// <param name="stateID">Object that identifies the state to be restored.</param>
void RestoreState(Object stateID);
/// <summary>
/// Clears a state from the linkable component's memory. If the state identifier identified by
/// stateID is not known by the linkable component an exception should be trown.
/// </summary>
/// <param name="stateID">Object that identifies the state to be cleared.</param>
void ClearState(Object stateID);
}
interface IPersistentState
{
/// <summary>
/// Transform the state of a component instance into an array of bytes
/// </summary>
/// <param name="state">The state to be turned into a byte array</param>
/// <returns></returns>
byte[] makePersistent(object state);
/// <summary>
/// Read the state of a component instance from an array of bytes
/// </summary>
/// <param name="persistentState">Byte array containing the state</param>
/// <returns></returns>
object readPersistentState(byte[] persistentState);
}