Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfEventField.java
index 9cbd789af3e0e965feb53fd63139ac52db0ec245..6729b776ece9f06e0dc7170fa74f32e426ee494f 100644 (file)
@@ -21,17 +21,22 @@ package org.eclipse.linuxtools.tmf.event;
  */
 public class TmfEventField implements Cloneable {
 
-    // ========================================================================
+    // ------------------------------------------------------------------------
     // Attributes
-    // ========================================================================
+    // ------------------------------------------------------------------------
 
-       private final TmfEventContent fParent;
-    private final String fFieldId;
-    private       Object fValue;
+       protected TmfEventContent fParent;
+       protected String fFieldId;
+       protected Object fValue;
 
-    // ========================================================================
+    // ------------------------------------------------------------------------
     // Constructors
-    // ========================================================================
+    // ------------------------------------------------------------------------
+
+    @SuppressWarnings("unused")
+       private TmfEventField() {
+               throw new AssertionError();
+    }
 
     /**
      * @param parent
@@ -39,6 +44,9 @@ public class TmfEventField implements Cloneable {
      * @param value
      */
     public TmfEventField(TmfEventContent parent, String id, Object value) {
+       if (id == null) {
+               throw new IllegalArgumentException();
+       }
        fParent  = parent;
        fFieldId = id;
         fValue   = value;
@@ -48,22 +56,16 @@ public class TmfEventField implements Cloneable {
      * @param other
      */
     public TmfEventField(TmfEventField other) {
-       assert(other != null);
+       if (other == null)
+               throw new IllegalArgumentException();
        fParent  = other.fParent;
        fFieldId = other.fFieldId;
                fValue   = other.fValue;
     }
 
-    @SuppressWarnings("unused")
-       private TmfEventField() {
-       fParent  = null;
-       fFieldId = null;
-        fValue   = null;
-    }
-
-    // ========================================================================
+    // ------------------------------------------------------------------------
     // Accessors
-    // ========================================================================
+    // ------------------------------------------------------------------------
 
     /**
      * @return
@@ -87,27 +89,50 @@ public class TmfEventField implements Cloneable {
     }
 
     /**
-     * @param value
+     * @param value new field value
      */
     protected void setValue(Object value) {
         fValue = value;
     }
 
-    // ========================================================================
-    // Operators
-    // ========================================================================
+    // ------------------------------------------------------------------------
+    // Object
+    // ------------------------------------------------------------------------
 
-       /**
-        * Clone: shallow copy by default; override for deep copy.
-        */
     @Override
-    public TmfEventField clone() {
-       return new TmfEventField(this);
+    public int hashCode() {
+               int result = 17;
+               result = 37 * result + fFieldId.hashCode();
+               result = 37 * result + fValue.hashCode();
+        return result;
+    }
+
+       @Override
+       public boolean equals(Object other) {
+       if (!(other instanceof TmfEventField))
+               return false;
+               TmfEventField o = (TmfEventField) other;
+               return fParent.equals(o.fParent) && fFieldId.equals(o.fFieldId) && fValue.equals(o.fValue); 
     }
 
     @Override
+    @SuppressWarnings("nls")
        public String toString() {
         return "[TmfEventField(" + fFieldId + ":" + fValue.toString() + ")]";
     }
+    @Override
+       public TmfEventField clone() {
+       TmfEventField clone = null;
+       try {
+                       clone = (TmfEventField) super.clone();
+                       clone.fParent = fParent;
+                       clone.fFieldId = new String(fFieldId);
+                       clone.fValue = null;                    
+               } catch (CloneNotSupportedException e) {
+                       e.printStackTrace();
+               }
+               return clone;
+    }
+
 
 }
\ No newline at end of file
This page took 0.026004 seconds and 5 git commands to generate.