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

nz.co.gregs.dbvolution.operators.DBPermittedRangeExclusiveOperator Maven / Gradle / Ivy

/*
 * Copyright 2013 Gregory Graham.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nz.co.gregs.dbvolution.operators;

import nz.co.gregs.dbvolution.datatypes.QueryableDatatype;

/**
 * Implements a BETWEEN operator that excludes the end points of the range.
 *
 * 

* Given a set of 1,2,3,4,5, using DBPermittedRangeExclusiveOperator(1,5) will * produce an operation such that 2,3, and 4 will be returned but not 1, or 5. * *

* Unbounded ranges are created by passing null as the lower- or upper-bound. * For example, DBPermittedRangeExclusiveOperator(1,null) will produce an * operation such that every number larger than 1 will be returned. * *

Support DBvolution at * Patreon

* * @author Gregory Graham */ public class DBPermittedRangeExclusiveOperator extends DBMetaOperator { private static final long serialVersionUID = 1L; /** * Implements a BETWEEN operator that excludes the end points of the range. * *

* Use a null value to create open or unbounded ranges. * * @param lowerBound the largest value smaller than the desired range * @param upperBound the smallest value larger than the desired range */ public DBPermittedRangeExclusiveOperator(Object lowerBound, Object upperBound) { if (lowerBound != null && upperBound != null) { operator = new DBBetweenExclusiveOperator( QueryableDatatype.getQueryableDatatypeForObject(lowerBound), QueryableDatatype.getQueryableDatatypeForObject(upperBound)); } else if (lowerBound == null && upperBound != null) { QueryableDatatype qdt = QueryableDatatype.getQueryableDatatypeForObject(upperBound); operator = new DBLessThanOperator(qdt); } else if (lowerBound != null && upperBound == null) { final QueryableDatatype qdt = QueryableDatatype.getQueryableDatatypeForObject(lowerBound); operator = new DBGreaterThanOperator(qdt); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy