Skip to content

Commit d91ccf4

Browse files
committed
equals and hashcode for Selection
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@313 c6a108a4-781c-0410-a6c6-c2d559e19af0
1 parent 01238b8 commit d91ccf4

File tree

1 file changed

+56
-7
lines changed

1 file changed

+56
-7
lines changed

src/org/olap4j/query/SelectionImpl.java

+56-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright (C) 2007-2010 Julian Hyde
77
// All Rights Reserved.
88
// You must accept the terms of that agreement to use this software.
9-
*/
9+
*/
1010
package org.olap4j.query;
1111

1212
import java.util.ArrayList;
@@ -39,12 +39,12 @@ class SelectionImpl extends QueryNodeImpl implements Selection {
3939
* @pre operator != null
4040
*/
4141
public SelectionImpl(
42-
Member member,
43-
Dimension dimension,
44-
String hierarchyName,
45-
String levelName,
46-
String memberName,
47-
Operator operator)
42+
Member member,
43+
Dimension dimension,
44+
String hierarchyName,
45+
String levelName,
46+
String memberName,
47+
Operator operator)
4848
{
4949
super();
5050
this.member = member;
@@ -55,6 +55,55 @@ public SelectionImpl(
5555
this.operator = operator;
5656
}
5757

58+
public int hashCode() {
59+
final int prime = 31;
60+
int result = 1;
61+
result = prime * result
62+
+ ((member == null) ? 0 : member.getUniqueName().hashCode());
63+
result = prime * result
64+
+ ((operator == null) ? 0 : operator.hashCode());
65+
result = prime * result
66+
+ ((selectionContext == null) ? 0 : selectionContext.hashCode());
67+
return result;
68+
}
69+
70+
public boolean equals(Object obj) {
71+
if (this == obj) {
72+
return true;
73+
}
74+
if (obj == null) {
75+
return false;
76+
}
77+
if (!(obj instanceof SelectionImpl)) {
78+
return false;
79+
}
80+
SelectionImpl other = (SelectionImpl) obj;
81+
if (member == null) {
82+
if (other.member != null) {
83+
return false;
84+
}
85+
} else if (!member.getUniqueName().equals(
86+
other.member.getUniqueName()))
87+
{
88+
return false;
89+
}
90+
if (operator == null) {
91+
if (other.operator != null) {
92+
return false;
93+
}
94+
} else if (!operator.equals(other.operator)) {
95+
return false;
96+
}
97+
if (selectionContext == null) {
98+
if (other.selectionContext != null) {
99+
return false;
100+
}
101+
} else if (!selectionContext.equals(other.selectionContext)) {
102+
return false;
103+
}
104+
return true;
105+
}
106+
58107
public String getName() {
59108
return memberName;
60109
}

0 commit comments

Comments
 (0)