package net.onrc.onos.intent;

/**
 * @author Toshio Koide (t-koide@onlab.us)
 */
public class Intent {
	public enum IntentState {
		CREATED,
		INST_REQ,
		INST_NACK,
		INST_ACK,
		DEL_REQ,
		DEL_PENDING,
		DEL_ACK,
		REROUTE_REQ,
	}

	private String id;
	private IntentState state = IntentState.CREATED;

	/**
	 * Default constructor for Kryo deserialization
	 */
	protected Intent() {
	}

	public Intent(String id) {
		this.id = id;
	}

	public Intent(String id, IntentState state) {
		this.id = id;
		this.state = state;
	}

	public String getId() {
		return id;
	}

	public IntentState getState() {
		return state;
	}

	public IntentState setState(IntentState newState) {
		IntentState oldState = state;
		state = newState;
		return oldState;
	}

	@Override
	public int hashCode() {
		return (id == null) ? 0 : id.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if ((obj == null) || (getClass() != obj.getClass()))
			return false;
		Intent other = (Intent) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return id.toString() + ", " + state.toString();
	}
}

@@ -24,16 +24,118 @@
 ntent;%0A%0A
+import java.util.LinkedList;%0A%0Aimport com.esotericsoftware.kryo.serializers.FieldSerializer.Optional;%0A%0A
 /**%0A * @
@@ -406,223 +406,556 @@
 ;%0A%0A%09
-/**%0A%09 * Default constructor for Kryo deserialization%0A%09 */%0A%09protected Intent() %7B%0A%09%7D%0A%0A%09public Intent(String id) %7B%0A%09%09this.id = id;%0A%09%7D%0A%0A%09public Intent(String id, IntentState state) %7B%0A%09%09this.id = id;%0A%09%09this.s
+@Optional(value=%22logs%22)%0A%09private LinkedList%3CString%3E logs = new LinkedList%3C%3E();%0A%0A%09/**%0A%09 * Default constructor for Kryo deserialization%0A%09 */%0A%09protected Intent() %7B%0A%09%09logs.add(String.format(%22created, time:%25d%22, System.nanoTime())); // for measurement%0A%09%7D%0A%0A%09public Intent(String id) %7B%0A%09%09logs.add(String.format(%22created, time:%25d%22, System.nanoTime())); // for measurement%0A%09%09this.id = id;%0A%09%7D%0A%0A%09public Intent(String id, IntentState state) %7B%0A%09%09logs.add(String.format(%22created, time:%25d%22, System.nanoTime())); // for measurement%0A%09%09setS
 tate
- = 
+(
 state
+);%0A%09%09this.id = id
 ;%0A%09%7D
@@ -1104,16 +1104,149 @@
 tate) %7B%0A
+%09%09logs.add(String.format(%22setState, oldState:%25s, newState:%25s, time:%25d%22,%0A%09%09%09%09state, newState, System.nanoTime())); // for measurement%0A
 %09%09Intent
@@ -1308,24 +1308,82 @@
 dState;%0A%09%7D%0A%0A
+%09public LinkedList%3CString%3E getLogs() %7B%0A%09%09return logs;%0A%09%7D%0A%0A
 %09@Override%0A%09

Add logging feature for each Intent instances