Removed DOCUMENT ME comments that were generated and applied source code
[utils] / support / general / src / test / java / org / wamblee / test / EventTracker.java
index 9e9c472ddfe65d0e87cc0db45365328d71c3a961..37a4c76ae3326e4aac786264cfaa0c01f42637ad 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2006 the original author or authors.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  */
 package org.wamblee.test;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 /**
  * Tracks the occurence of certain events in a test environment. Threads in a
  * test environment tell the event tracker of the occurrence of certain events
@@ -37,11 +37,10 @@ import org.apache.commons.logging.LogFactory;
  *            Type of event sent from test code. Usually String will be
  *            sufficient. The event type must provide a sensible implementation
  *            of {@link java.lang.Object#equals(java.lang.Object)}.
- *
+ * 
  * @author Erik Brakkee
  */
 public class EventTracker<Event> {
-
     private static final Log LOG = LogFactory.getLog(EventTracker.class);
 
     /**
@@ -57,9 +56,9 @@ public class EventTracker<Event> {
         clear();
     }
 
-       public void clear() {
-               events = new HashMap<Thread, List<Event>>();
-       }
+    public void clear() {
+        events = new HashMap<Thread, List<Event>>();
+    }
 
     /**
      * Called by a thread to inform that an event has occurred.
@@ -69,12 +68,15 @@ public class EventTracker<Event> {
      */
     public synchronized void eventOccurred(Event aEvent) {
         LOG.info("Event '" + aEvent + "' sent.");
+
         Thread current = Thread.currentThread();
         List<Event> eventList = events.get(current);
+
         if (eventList == null) {
             eventList = new ArrayList<Event>();
             events.put(current, eventList);
         }
+
         eventList.add(aEvent);
     }
 
@@ -89,9 +91,11 @@ public class EventTracker<Event> {
      */
     public synchronized boolean isEventSent(Thread aThread, Event aEvent) {
         List<Event> eventList = events.get(aThread);
+
         if (eventList == null) {
             return false;
         }
+
         return eventList.contains(aEvent);
     }
 
@@ -105,15 +109,16 @@ public class EventTracker<Event> {
      */
     public synchronized List<Event> getEvents(Thread aThread) {
         List<Event> eventList = events.get(aThread);
+
         if (eventList == null) {
             eventList = Collections.emptyList();
         }
+
         return Collections.unmodifiableList(eventList);
     }
 
     /**
-     * Gets the number of times an event was sent summed up
-     * over all threads. 
+     * Gets the number of times an event was sent summed up over all threads.
      * 
      * @param aEvent
      *            Event to check.
@@ -121,26 +126,32 @@ public class EventTracker<Event> {
      */
     public synchronized int getEventCount(Event aEvent) {
         int count = 0;
+
         for (Thread thread : events.keySet()) {
             List<Event> eventList = events.get(thread);
+
             for (Event event : eventList) {
                 if (event.equals(aEvent)) {
                     count++;
                 }
             }
         }
+
         return count;
     }
-    
+
     /**
-     * Gets the total event count over all threads. 
+     * Gets the total event count over all threads.
+     * 
      * @return
      */
-    public synchronized int getEventCount() { 
-       int count = 0; 
-       for (Thread thread: events.keySet()) { 
-               count += events.get(thread).size();
-       }
-       return count; 
+    public synchronized int getEventCount() {
+        int count = 0;
+
+        for (Thread thread : events.keySet()) {
+            count += events.get(thread).size();
+        }
+
+        return count;
     }
 }