Added some more JUnit tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / model / impl / UstProviderInfo.java
index 537d7341177f2b1c980366affc9521d52f5d1a5f..c3d4b4cec7a402c62b32281246bc073b8cd2dd11 100644 (file)
@@ -125,16 +125,37 @@ public class UstProviderInfo extends TraceInfo implements IUstProviderInfo {
     
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
+     * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#formatString()
      */
+    @SuppressWarnings("nls")
     @Override
-    public int hashCode() {
-        int result = 17;
-        result = 37 * result + super.hashCode();
+    public String formatString() {
+        StringBuffer output = new StringBuffer();
+        //PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+        output.append("\nPID: ");
+        output.append(fPid);
+        output.append(" - Name: ");
+        output.append(getName());
         for (Iterator<IBaseEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
             IBaseEventInfo event = (IBaseEventInfo) iterator.next();
-            result = 37 * result + event.hashCode();
+            output.append(event.formatString());
         }
+        output.append("\n");
+
+        return output.toString();
+    }
+
+    
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((fEvents == null) ? 0 : fEvents.hashCode());
+        result = prime * result + fPid;
         return result;
     }
 
@@ -143,23 +164,26 @@ public class UstProviderInfo extends TraceInfo implements IUstProviderInfo {
      * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
      */
     @Override
-    public boolean equals(Object other) {
-        if (!(other instanceof UstProviderInfo)) {
-            return false;
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
         }
-
-        UstProviderInfo otherUstInfo = (UstProviderInfo) other;
-        if (!super.equals(otherUstInfo)) {
+        if (!super.equals(obj)) {
             return false;
         }
-
-        if (fEvents.size() != otherUstInfo.fEvents.size()) {
+        if (getClass() != obj.getClass()) {
             return false;
         }
-        for (int i = 0; i < fEvents.size(); i++) {
-            if (!fEvents.get(i).equals(otherUstInfo.fEvents.get(i))) {
+        UstProviderInfo other = (UstProviderInfo) obj;
+        if (fEvents == null) {
+            if (other.fEvents != null) {
                 return false;
             }
+        } else if (!fEvents.equals(other.fEvents)) {
+            return false;
+        }
+        if (fPid != other.fPid) {
+            return false;
         }
         return true;
     }
@@ -188,4 +212,6 @@ public class UstProviderInfo extends TraceInfo implements IUstProviderInfo {
             output.append(")]");
             return output.toString();
     }
+
 }
This page took 0.026558 seconds and 5 git commands to generate.