cleanup and javadoc for remaining files in onos.core.intent

Change-Id: I3bfe85579daa4bb35be6133b3221fabd80b10e00
diff --git a/src/main/java/net/onrc/onos/core/intent/IntentMap.java b/src/main/java/net/onrc/onos/core/intent/IntentMap.java
index 7d87fa2..136e442 100644
--- a/src/main/java/net/onrc/onos/core/intent/IntentMap.java
+++ b/src/main/java/net/onrc/onos/core/intent/IntentMap.java
@@ -9,16 +9,19 @@
 
 import net.onrc.onos.core.intent.Intent.IntentState;
 import net.onrc.onos.core.intent.runtime.IntentStateList;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * @author Toshio Koide (t-koide@onlab.us)
+ * The IntentMap contains all of the Intents in the system. It is also
+ * responsible for handling notifications to interested listeners when
+ * Intents are changed/updated.
  */
 public class IntentMap {
-    private HashSet<ChangedListener> listeners = new HashSet<>();
-    private HashMap<String, Intent> intents = new HashMap<>();
-    private LinkedList<ChangedEvent> events = new LinkedList<>();
+    private final HashSet<ChangedListener> listeners = new HashSet<>();
+    private final HashMap<String, Intent> intents = new HashMap<>();
+    private final LinkedList<ChangedEvent> events = new LinkedList<>();
     private static final Logger log = LoggerFactory.getLogger(IntentMap.class);
 
     public enum ChangedEventType {
@@ -42,7 +45,17 @@
         STATE_CHANGED,
     }
 
+    /**
+     * This class is a wrapper for Intent event notifications.
+     */
     public static class ChangedEvent {
+
+        /**
+         * Constructor.
+         *
+         * @param eventType the type of event
+         * @param intent the affected Intent
+         */
         public ChangedEvent(ChangedEventType eventType, Intent intent) {
             this.eventType = eventType;
             this.intent = intent;
@@ -71,6 +84,9 @@
         }
     }
 
+    /**
+     * An interface to listen to Intent updates.
+     */
     public interface ChangedListener extends EventListener {
         void intentsChange(LinkedList<ChangedEvent> events);
     }
@@ -79,21 +95,26 @@
     // public methods
     //================================================================================
 
+    /**
+     * Performs the specified operations on a list of Intents.
+     *
+     * @param operations list of Intents and associated operations
+     */
     public void executeOperations(IntentOperationList operations) {
         for (IntentOperation operation : operations) {
             switch (operation.operator) {
-                case ADD:
-                    handleAddOperation(operation);
-                    break;
-                case REMOVE:
-                    handleRemoveOperation(operation);
-                    break;
-                case ERROR:
-                    handleErrorOperation(operation);
-                    break;
-                default:
-                    log.error("Unknown intent operation {}", operation.operator);
-                    break;
+            case ADD:
+                handleAddOperation(operation);
+                break;
+            case REMOVE:
+                handleRemoveOperation(operation);
+                break;
+            case ERROR:
+                handleErrorOperation(operation);
+                break;
+            default:
+                log.error("Unknown intent operation {}", operation.operator);
+                break;
             }
         }
         notifyEvents();
@@ -132,6 +153,11 @@
         notifyEvents();
     }
 
+    /**
+     * Update the states of intents in the map to match those provided.
+     *
+     * @param states list of new Intent states
+     */
     public void changeStates(IntentStateList states) {
         for (Entry<String, IntentState> state : states.entrySet()) {
             setState(state.getKey(), state.getValue());
@@ -139,18 +165,39 @@
         notifyEvents();
     }
 
+    /**
+     * Get an Intent from the map.
+     *
+     * @param intentId ID of requested Intent
+     * @return Intent with specified ID
+     */
     public Intent getIntent(String intentId) {
         return intents.get(intentId);
     }
 
+    /**
+     * Get all Intents from the map.
+     *
+     * @return a collection including all Intents
+     */
     public Collection<Intent> getAllIntents() {
         return intents.values();
     }
 
+    /**
+     * Add a change listener.
+     *
+     * @param listener new listener to change events
+     */
     public void addChangeListener(ChangedListener listener) {
         listeners.add(listener);
     }
 
+    /**
+     * Remove a change listener.
+     *
+     * @param listener the listener to be removed
+     */
     public void removeChangedListener(ChangedListener listener) {
         listeners.remove(listener);
     }
@@ -159,6 +206,11 @@
     // methods that affect intents map (protected)
     //================================================================================
 
+    /**
+     * Put an intent in the map.
+     *
+     * @param intent intent to be added
+     */
     protected void putIntent(Intent intent) {
         if (intents.containsKey(intent.getId())) {
             removeIntent(intent.getId());
@@ -167,6 +219,11 @@
         events.add(new ChangedEvent(ChangedEventType.ADDED, intent));
     }
 
+    /**
+     * Remove an intent from the map.
+     *
+     * @param intentId intent to be removed
+     */
     protected void removeIntent(String intentId) {
         Intent intent = intents.remove(intentId);
         if (intent == null) {
@@ -175,6 +232,12 @@
         events.add(new ChangedEvent(ChangedEventType.REMOVED, intent));
     }
 
+    /**
+     * Change the state of an Intent in the map.
+     *
+     * @param intentId ID of the Intent to change
+     * @param state new state for the specified Intent
+     */
     protected void setState(String intentId, IntentState state) {
         Intent intent = intents.get(intentId);
         if (intent == null) {
@@ -188,10 +251,20 @@
     // helper methods (protected)
     //================================================================================
 
+    /**
+     * Helper to add Intents to the map.
+     *
+     * @param operation the Intent to be added
+     */
     protected void handleAddOperation(IntentOperation operation) {
         putIntent(operation.intent);
     }
 
+    /**
+     * Helper to remove Intents from the map.
+     *
+     * @param operation the Intent to be removed
+     */
     protected void handleRemoveOperation(IntentOperation operation) {
         Intent intent = getIntent(operation.intent.getId());
         if (intent == null) {
@@ -202,6 +275,11 @@
         }
     }
 
+    /**
+     * Helper to handle Intents in the error state.
+     *
+     * @param operation the Intent to be resolved
+     */
     protected void handleErrorOperation(IntentOperation operation) {
         //TODO put error message into the intent
 
@@ -213,26 +291,29 @@
         }
 
         switch (targetIntent.getState()) {
-            case CREATED:
-            case INST_REQ:
-            case INST_ACK:
-            case REROUTE_REQ:
-                setState(targetIntent.getId(), IntentState.INST_NACK);
-                break;
-            case DEL_REQ:
-                setState(targetIntent.getId(), IntentState.DEL_PENDING);
-                break;
-            case INST_NACK:
-            case DEL_PENDING:
-            case DEL_ACK:
-                // do nothing
-                break;
-            default:
-                log.error("Unknown intent state {}", targetIntent.getState());
-                break;
+        case CREATED:
+        case INST_REQ:
+        case INST_ACK:
+        case REROUTE_REQ:
+            setState(targetIntent.getId(), IntentState.INST_NACK);
+            break;
+        case DEL_REQ:
+            setState(targetIntent.getId(), IntentState.DEL_PENDING);
+            break;
+        case INST_NACK:
+        case DEL_PENDING:
+        case DEL_ACK:
+            // do nothing
+            break;
+        default:
+            log.error("Unknown intent state {}", targetIntent.getState());
+            break;
         }
     }
 
+    /**
+     * Notify all registered listeners of events in queue.
+     */
     protected void notifyEvents() {
         if (events.isEmpty()) {
             return;