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

com.tri.persistence.jpql.WhereAnd Maven / Gradle / Ivy

Go to download

Create dynamic JPQL queries with a fluent API without cluttering code with String concatenations

The newest version!
package com.tri.persistence.jpql;

import com.tri.persistence.jpql.utils.StringUtils;

/**
 * AND operator for a {@literal SQL} Where Clause.
 */
public class WhereAnd extends WhereItems {

	/**
	 * Constructor
	 * 
	 * @param builder
	 *            {@link QueryBuilder} to associate
	 */
	public WhereAnd(final QueryBuilder builder) {
		super(builder);
	}

	@Override
	public String render() {
		final StringBuilder result = new StringBuilder();

		for (WhereItem item : items) {
			final String build = item.render();
			if (StringUtils.isBlank(build) == false) {

				if (result.length() > 0) {
					result.append(" AND ");
				} else {
					result.append("(");
				}

				result.append(build);

			}
		}

		if (result.length() > 0) {
			result.append(")");
		}

		return result.toString();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy