*/
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
* @param value
*/
public TmfEventField(TmfEventContent parent, String id, Object value) {
+ if (id == null) {
+ throw new IllegalArgumentException();
+ }
fParent = parent;
fFieldId = id;
fValue = value;
* @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
}
/**
- * @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