Skip to content

Commit

Permalink
equals and hashcode for Selection
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@313 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
pstoellberger committed May 20, 2010
1 parent 01238b8 commit d91ccf4
Showing 1 changed file with 56 additions and 7 deletions.
63 changes: 56 additions & 7 deletions src/org/olap4j/query/SelectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (C) 2007-2010 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
*/
package org.olap4j.query;

import java.util.ArrayList;
Expand Down Expand Up @@ -39,12 +39,12 @@ class SelectionImpl extends QueryNodeImpl implements Selection {
* @pre operator != null
*/
public SelectionImpl(
Member member,
Dimension dimension,
String hierarchyName,
String levelName,
String memberName,
Operator operator)
Member member,
Dimension dimension,
String hierarchyName,
String levelName,
String memberName,
Operator operator)
{
super();
this.member = member;
Expand All @@ -55,6 +55,55 @@ public SelectionImpl(
this.operator = operator;
}

public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((member == null) ? 0 : member.getUniqueName().hashCode());
result = prime * result
+ ((operator == null) ? 0 : operator.hashCode());
result = prime * result
+ ((selectionContext == null) ? 0 : selectionContext.hashCode());
return result;
}

public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SelectionImpl)) {
return false;
}
SelectionImpl other = (SelectionImpl) obj;
if (member == null) {
if (other.member != null) {
return false;
}
} else if (!member.getUniqueName().equals(
other.member.getUniqueName()))
{
return false;
}
if (operator == null) {
if (other.operator != null) {
return false;
}
} else if (!operator.equals(other.operator)) {
return false;
}
if (selectionContext == null) {
if (other.selectionContext != null) {
return false;
}
} else if (!selectionContext.equals(other.selectionContext)) {
return false;
}
return true;
}

public String getName() {
return memberName;
}
Expand Down

0 comments on commit d91ccf4

Please sign in to comment.