From d91ccf405fca7aa9a12baad978ccd954780a6083 Mon Sep 17 00:00:00 2001 From: Paul Stoellberger Date: Thu, 20 May 2010 20:53:50 +0000 Subject: [PATCH] equals and hashcode for Selection git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@313 c6a108a4-781c-0410-a6c6-c2d559e19af0 --- src/org/olap4j/query/SelectionImpl.java | 63 ++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/src/org/olap4j/query/SelectionImpl.java b/src/org/olap4j/query/SelectionImpl.java index 3918638..91693ad 100644 --- a/src/org/olap4j/query/SelectionImpl.java +++ b/src/org/olap4j/query/SelectionImpl.java @@ -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; @@ -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; @@ -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; }