001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Nuxeo - initial API and implementation 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.ecm.core.query.sql.model; 016 017/** 018 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 019 */ 020public class HavingClause extends Clause { 021 022 private static final long serialVersionUID = 3686852512501042627L; 023 024 public final Predicate predicate; 025 026 public HavingClause() { 027 this(null); 028 } 029 030 public HavingClause(Predicate predicate) { 031 super("HAVING"); 032 this.predicate = predicate; 033 } 034 035 @Override 036 public void accept(IVisitor visitor) { 037 visitor.visitHavingClause(this); 038 } 039 040 @Override 041 public boolean equals(Object obj) { 042 if (this == obj) { 043 return true; 044 } 045 if (obj instanceof HavingClause) { 046 if (predicate != null) { 047 return predicate.equals(((HavingClause) obj).predicate); 048 } 049 } 050 return false; 051 } 052 053 @Override 054 public int hashCode() { 055 if (predicate == null) { 056 return 0; 057 } 058 return predicate.hashCode(); 059 } 060 061}