All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geolatte.common.expressions.NumberExpression Maven / Gradle / Ivy

Go to download

This GeoLatte-common library contains the transformer framework and other common classes used by other GeoLatte modules.

There is a newer version: 0.8
Show newest version
/*
 * This file is part of the GeoLatte project.
 *
 *     GeoLatte 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, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     GeoLatte 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.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with GeoLatte.  If not, see .
 *
 * Copyright (C) 2010 - 2010 and Ownership of code is shared by:
 * Qmino bvba - Romeinsestraat 18 - 3001 Heverlee  (http://www.qmino.com)
 * Geovise bvba - Generaal Eisenhowerlei 9 - 2140 Antwerpen (http://www.geovise.com)
 */

package org.geolatte.common.expressions;

/**
 * 

* Abstract base class for all Number expressions. Offers further concatenation operations such as {@link NumberExpression#isEqual(ComparableExpression)} and {@link NumberExpression#add(Expression)}. *

*

* Creation-Date: 9-apr-2010
* Creation-Time: 11:48:54
*

* * @author Peter Rigole * @author Bert Vanhooff * @author Qmino bvba * @since SDK1.5 */ public abstract class NumberExpression implements ComparableExpression { /** * Creates an IsEqual expression from this expression (as left expression) and the given expression (as * the right expression). * * @param right The right expression. * @return A new IsEqual binary expression. */ public IsEqual isEqual(ComparableExpression right) { return new IsEqual(this, right); } /** * Creates an IsGreaterThan expression from this expression (as left expression) and the given expression (as * the right expression). * * @param right The right expression. * @return A new IsGreaterThan binary expression. */ public IsGreaterThan isGreaterThan(ComparableExpression right) { return new IsGreaterThan(this, right); } /** * Creates an IsGreaterThanOrEqual expression from this expression (as left expression) and the given expression (as * the right expression). * * @param right The right expression. * @return A new IsGreaterThanOrEqual binary expression. */ public IsGreaterThanOrEqual isGreaterThanOrEqual(ComparableExpression right) { return new IsGreaterThanOrEqual(this, right); } /** * Creates an is less than expression from this expression (as left expression) and the given expression (as * the right expression). * * @param right The right expression. * @return A new is less than binary expression. */ public IsLessThan isLessThan(ComparableExpression right) { return new IsLessThan(this, right); } /** * Creates an IsLessThanOrEqual expression from this expression (as left expression) and the given expression (as * the right expression). * * @param right The right expression. * @return A new IsLessThanOrEqual binary expression. */ public IsLessThanOrEqual isLessThanOrEqual(ComparableExpression right) { return new IsLessThanOrEqual(this, right); } /** * Creates an IsNotEqual expression from this expression (as left expression) and the given expression (as * the right expression). * * @param right The right expression. * @return A new IsNotEqual binary expression. */ public IsNotEqual isNotEqual(ComparableExpression right) { return new IsNotEqual(this, right); } /** * Creates an Add expression form this expression (as left expression) and the given right expression. * * @param right The right expression. * @return A new binary expression that contains two number expressions and evaluates to a number expression. */ public Add add(Expression right) { return new Add(this, right); } public int compareTo(Object evaluateObject, Number value) { Number thisNumber = evaluate(evaluateObject); double difference = thisNumber.doubleValue() - value.doubleValue(); return (int)Math.signum(difference); } public void switchOn(BasicTypeSwitch switcher) { switcher.caseNumber(this); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy