aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Perot2014-08-05 16:55:13 (EDT)
committerAlexandre Montplaisir2014-08-06 17:45:45 (EDT)
commit05ed4d406964fd7c13d2a431671bbb50ceb99a46 (patch)
tree9219f1adfaf5530eee273386d141f949c0deb5a2
parentfd18d71252a8bbf541ecd93339e1cdac1713d85e (diff)
downloadorg.eclipse.linuxtools-05ed4d406964fd7c13d2a431671bbb50ceb99a46.zip
org.eclipse.linuxtools-05ed4d406964fd7c13d2a431671bbb50ceb99a46.tar.gz
org.eclipse.linuxtools-05ed4d406964fd7c13d2a431671bbb50ceb99a46.tar.bz2
tmf: implement hashcode and equals on filter classesrefs/changes/62/31062/5
Change-Id: Ic72c475995aaf63f3cb2cff83c4a7de395543f30 Signed-off-by: Vincent Perot <vincent.perot@ericsson.com> Reviewed-on: https://git.eclipse.org/r/31062 Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterAndNode.java26
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java54
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java48
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java46
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java38
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java44
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java30
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterOrNode.java26
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java36
9 files changed, 342 insertions, 6 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterAndNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterAndNode.java
index 2c05425..6aaef33 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterAndNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterAndNode.java
@@ -87,4 +87,30 @@ public class TmfFilterAndNode extends TmfFilterTreeNode {
return buf.toString();
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + (fNot ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterAndNode other = (TmfFilterAndNode) obj;
+ if (fNot != other.fNot) {
+ return false;
+ }
+ return true;
+ }
+
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java
index a452753..0037532 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java
@@ -51,8 +51,8 @@ public class TmfFilterCompareNode extends TmfFilterTreeNode {
private int fResult;
private Type fType = Type.NUM;
private String fValue;
- private Number fValueNumber;
- private TmfTimestamp fValueTimestamp;
+ private transient Number fValueNumber;
+ private transient TmfTimestamp fValueTimestamp;
/**
* @param parent the parent node
@@ -217,4 +217,54 @@ public class TmfFilterCompareNode extends TmfFilterTreeNode {
clone.setValue(fValue);
return clone;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fField == null) ? 0 : fField.hashCode());
+ result = prime * result + (fNot ? 1231 : 1237);
+ result = prime * result + fResult;
+ result = prime * result + ((fType == null) ? 0 : fType.hashCode());
+ result = prime * result + ((fValue == null) ? 0 : fValue.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterCompareNode other = (TmfFilterCompareNode) obj;
+ if (fField == null) {
+ if (other.fField != null) {
+ return false;
+ }
+ } else if (!fField.equals(other.fField)) {
+ return false;
+ }
+ if (fNot != other.fNot) {
+ return false;
+ }
+ if (fResult != other.fResult) {
+ return false;
+ }
+ if (fType != other.fType) {
+ return false;
+ }
+ if (fValue == null) {
+ if (other.fValue != null) {
+ return false;
+ }
+ } else if (!fValue.equals(other.fValue)) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java
index ee91c7d..798787d 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java
@@ -35,7 +35,7 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
private boolean fNot = false;
private String fField;
private String fValue;
- private String fValueUpperCase;
+ private transient String fValueUpperCase;
private boolean fIgnoreCase = false;
/**
@@ -139,4 +139,50 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
clone.setValue(fValue);
return clone;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fField == null) ? 0 : fField.hashCode());
+ result = prime * result + (fIgnoreCase ? 1231 : 1237);
+ result = prime * result + (fNot ? 1231 : 1237);
+ result = prime * result + ((fValue == null) ? 0 : fValue.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterContainsNode other = (TmfFilterContainsNode) obj;
+ if (fField == null) {
+ if (other.fField != null) {
+ return false;
+ }
+ } else if (!fField.equals(other.fField)) {
+ return false;
+ }
+ if (fIgnoreCase != other.fIgnoreCase) {
+ return false;
+ }
+ if (fNot != other.fNot) {
+ return false;
+ }
+ if (fValue == null) {
+ if (other.fValue != null) {
+ return false;
+ }
+ } else if (!fValue.equals(other.fValue)) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java
index d718376..a85a43a 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java
@@ -139,4 +139,50 @@ public class TmfFilterEqualsNode extends TmfFilterTreeNode {
clone.fValue = fValue;
return clone;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fField == null) ? 0 : fField.hashCode());
+ result = prime * result + (fIgnoreCase ? 1231 : 1237);
+ result = prime * result + (fNot ? 1231 : 1237);
+ result = prime * result + ((fValue == null) ? 0 : fValue.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterEqualsNode other = (TmfFilterEqualsNode) obj;
+ if (fField == null) {
+ if (other.fField != null) {
+ return false;
+ }
+ } else if (!fField.equals(other.fField)) {
+ return false;
+ }
+ if (fIgnoreCase != other.fIgnoreCase) {
+ return false;
+ }
+ if (fNot != other.fNot) {
+ return false;
+ }
+ if (fValue == null) {
+ if (other.fValue != null) {
+ return false;
+ }
+ } else if (!fValue.equals(other.fValue)) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java
index 28f7ef9..ab98b37 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java
@@ -26,6 +26,44 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
@SuppressWarnings("javadoc")
public class TmfFilterEventTypeNode extends TmfFilterTreeNode {
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fName == null) ? 0 : fName.hashCode());
+ result = prime * result + ((fType == null) ? 0 : fType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterEventTypeNode other = (TmfFilterEventTypeNode) obj;
+ if (fName == null) {
+ if (other.fName != null) {
+ return false;
+ }
+ } else if (!fName.equals(other.fName)) {
+ return false;
+ }
+ if (fType == null) {
+ if (other.fType != null) {
+ return false;
+ }
+ } else if (!fType.equals(other.fType)) {
+ return false;
+ }
+ return true;
+ }
+
public static final String NODE_NAME = "EVENTTYPE"; //$NON-NLS-1$
public static final String TYPE_ATTR = "type"; //$NON-NLS-1$
public static final String NAME_ATTR = "name"; //$NON-NLS-1$
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java
index fc8b918..d321157 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java
@@ -36,7 +36,7 @@ public class TmfFilterMatchesNode extends TmfFilterTreeNode {
private boolean fNot = false;
private String fField;
private String fRegex;
- private Pattern fPattern;
+ private transient Pattern fPattern;
/**
* @param parent
@@ -151,4 +151,46 @@ public class TmfFilterMatchesNode extends TmfFilterTreeNode {
}
return ret;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fField == null) ? 0 : fField.hashCode());
+ result = prime * result + (fNot ? 1231 : 1237);
+ result = prime * result + ((fRegex == null) ? 0 : fRegex.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterMatchesNode other = (TmfFilterMatchesNode) obj;
+ if (fField == null) {
+ if (other.fField != null) {
+ return false;
+ }
+ } else if (!fField.equals(other.fField)) {
+ return false;
+ }
+ if (fNot != other.fNot) {
+ return false;
+ }
+ if (fRegex == null) {
+ if (other.fRegex != null) {
+ return false;
+ }
+ } else if (!fRegex.equals(other.fRegex)) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java
index fa20c0d..59ae9c2 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java
@@ -104,4 +104,34 @@ public class TmfFilterNode extends TmfFilterTreeNode {
}
return buf.toString();
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fFilterName == null) ? 0 : fFilterName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterNode other = (TmfFilterNode) obj;
+ if (fFilterName == null) {
+ if (other.fFilterName != null) {
+ return false;
+ }
+ } else if (!fFilterName.equals(other.fFilterName)) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterOrNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterOrNode.java
index 30bbcdf..a8579e6 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterOrNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterOrNode.java
@@ -85,4 +85,30 @@ public class TmfFilterOrNode extends TmfFilterTreeNode {
}
return buf.toString();
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + (fNot ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterOrNode other = (TmfFilterOrNode) obj;
+ if (fNot != other.fNot) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java
index 6f6c5ef..6bf7f5f 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java
@@ -126,8 +126,10 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable
public abstract boolean matches(ITmfEvent event);
/**
- * @param event the event
- * @param field the field id
+ * @param event
+ * the event
+ * @param field
+ * the field id
* @return the field value
*/
protected Object getFieldValue(ITmfEvent event, String field) {
@@ -229,4 +231,34 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable
return null;
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((children == null) ? 0 : children.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfFilterTreeNode other = (TmfFilterTreeNode) obj;
+ if (children == null) {
+ if (other.children != null) {
+ return false;
+ }
+ } else if (!children.equals(other.children)) {
+ return false;
+ }
+ return true;
+ }
}