Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
	interface IState
	{
		/// <summary>
		/// Transform the state instance into an array of bytes
		/// </summary>
		/// <param name="state">The state to be turned into a byte array</param>
		/// <returns></returns>
		byte[] ToByteArray();
	}

	public interface IManageState
	{
		/// <summary>
		/// Store the linkable component's current State
		/// </summary>
		/// <returns>Object that identifies the stored state.</returns>
		IState KeepCurrentState();

		/// <summary>
		/// Creates an instance of the state using array of bytes
		/// </summary>
		/// <param name="stateID">Object that identifies the state to be restored.</param>
		IState CreateStateFromByteArray(byte[] state);

		/// <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(IState state);

		/// <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(IState state);
		
		/// <summary>
		/// All available states created using KeepCurrentState()
		/// </summary>
		IEnumerable<IState> AvailableStates { get; }
	}
Code Block
java Suggestion for IState and IManageState refactoring
java Suggestion for IState and IManageState refactoring

public interface IIdentifiable {
    public long getId();
}

public interface IState {
    public IIdentifiable getIdentifier();
    public byte[] toByteArray();
    public void assignFromByteArray(byte[] bytes);
}

public interface IManageState {
    // linkable component state management
    public IState keepCurrentState();
    public void restoreState(IState state);
    public void clearState(IState state);
 
    // TODO: decide if states should be publically visible
    public IState[] getStates();
 
    // factory method to revive state
    public IState createStateFromByteArray(byte[] bytes);
}