/* * Geotoolkit - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) * (C) 2009, Geomatys * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.geotoolkit.filter.binarycomparison; import org.geotoolkit.util.StringUtilities; import org.opengis.filter.FilterVisitor; import org.opengis.filter.MatchAction; import org.opengis.filter.PropertyIsGreaterThanOrEqualTo; import org.opengis.filter.expression.Expression; /** * Immutable "is greater than or equal" fitler. * * @author Johann Sorel (Geomatys) * @module */ public class DefaultPropertyIsGreaterThanOrEqualTo extends AbstractBinaryComparisonOperator<Expression,Expression> implements PropertyIsGreaterThanOrEqualTo{ public DefaultPropertyIsGreaterThanOrEqualTo(final Expression left, final Expression right, final boolean match, final MatchAction matchAction) { super(left,right,match,matchAction); } /** * {@inheritDoc } */ @Override public boolean evaluateOne(Object l, Object r) { final Integer v = compare(l,r); return (v == null) ? false : (v >= 0) ; } /** * {@inheritDoc } */ @Override public Object accept(final FilterVisitor visitor, final Object extraData) { return visitor.visit(this, extraData); } /** * {@inheritDoc } */ @Override public String toString() { final StringBuilder sb = new StringBuilder("PropertyIsGreaterThanOrEqualTo (matchcase="); sb.append(match).append(")\n"); sb.append(StringUtilities.toStringTree(left,right)); return sb.toString(); } /** * {@inheritDoc } */ @Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final AbstractBinaryComparisonOperator other = (AbstractBinaryComparisonOperator) obj; if (this.left != other.left && !this.left.equals(other.left)) { return false; } if (this.right != other.right && !this.right.equals(other.right)) { return false; } if (this.match != other.match) { return false; } return true; } /** * {@inheritDoc } */ @Override public int hashCode() { int hash = 9; hash = 23 * hash + this.left.hashCode(); hash = 23 * hash + this.right.hashCode() ; hash = 23 * hash + (this.match ? 1 : 0); return hash; } }