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

com.intuit.ipp.query.expr.StringPath Maven / Gradle / Ivy

There is a newer version: 6.5.0
Show newest version
/*******************************************************************************
 * Copyright (c) 2017 Intuit
 *
 * 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 com.intuit.ipp.query.expr;

import com.intuit.ipp.query.Operation;
import com.intuit.ipp.query.Path;

/**
 * Class to generate the query string for string value
 *
 */
public class StringPath extends Path {

	/**
	 * Constructor StringPath
	 * 
	 * @param path the path
	 * @param entity the entity
	 */
	public StringPath(String path, String entity) {
		super(path, entity);
	}

	/**
	 * Method to construct the equals expression for string
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression eq(String value) {
		String valueString = "'" + value + "'";
		return new Expression(this, Operation.eq, valueString);
	}

	/**
	 * Method to construct the not equals expression for string
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression neq(String value) {
		String valueString = "'" + value + "'";
		return new Expression(this, Operation.neq, valueString);
	}

	/**
	 * Method to construct the less than expression for string
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression lt(String value) {
		String valueString = "'" + value + "'";
		return new Expression(this, Operation.lt, valueString);
	}

	/**
	 * Method to construct the less than or equals expression for string
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression lte(String value) {
		String valueString = "'" + value + "'";
		return new Expression(this, Operation.lte, valueString);
	}

	/**
	 * Method to construct the greater than expression for string
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression gt(String value) {
		String valueString = "'" + value + "'";
		return new Expression(this, Operation.gt, valueString);
	}

	/**
	 * Method to construct the greater than or equals expression for string
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression gte(String value) {
		String valueString = "'" + value + "'";
		return new Expression(this, Operation.gte, valueString);
	}

	/**
	 * Method to construct the in expression for string
	 * 
	 * @param value the string array
	 * @return Expression
	 */
	public Expression in(String[] value) {
		String listString = "";
		Boolean firstString = true;
		for (String v : value) {
			if (firstString) {
				listString = listString.concat("('").concat(v).concat("'");
				firstString = false;
			} else {
				listString = listString.concat(", '").concat(v).concat("'");
			}
		}
		listString = listString.concat(")");
		return new Expression(this, Operation.in, listString);
	}

	/**
	 * Method to construct the like expression for string starts with
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression startsWith(String value) {
		String valueString = "'" + value + "%'";
		return new Expression(this, Operation.like, valueString);
	}
	
	/**
	 * Method to construct the like expression for string ends with
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression endsWith(String value) {
		String valueString = "'%" + value + "'";
		return new Expression(this, Operation.like, valueString);
	}
	
	/**
	 * Method to construct the like expression for string contains
	 * 
	 * @param value the string value
	 * @return Expression
	 */
	public Expression contains(String value) {
		String valueString = "'%" + value + "%'";
		return new Expression(this, Operation.like, valueString);
	}

	/**
	 * Method to construct the between expression for string
	 * 
	 * @param startValue the start value
	 * @param endValue the end value
	 * @return Expression
	 */
	public Expression between(String startValue, String endValue) {
		String valueString = "'" + startValue + "' AND '" + endValue + "'";
		return new Expression(this, Operation.between, valueString);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy