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

org.hibernate.query.criteria.internal.predicate.IsEmptyPredicate Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.query.criteria.internal.predicate;

import java.io.Serializable;
import java.util.Collection;

import org.hibernate.query.criteria.internal.CriteriaBuilderImpl;
import org.hibernate.query.criteria.internal.ParameterRegistry;
import org.hibernate.query.criteria.internal.compile.RenderingContext;
import org.hibernate.query.criteria.internal.expression.UnaryOperatorExpression;
import org.hibernate.query.criteria.internal.path.PluralAttributePath;

/**
 * Models an IS [NOT] EMPTY restriction
 *
 * @author Steve Ebersole
 */
public class IsEmptyPredicate
		extends AbstractSimplePredicate
		implements UnaryOperatorExpression, Serializable {

	private final PluralAttributePath collectionPath;

	public IsEmptyPredicate(
			CriteriaBuilderImpl criteriaBuilder,
			PluralAttributePath collectionPath) {
		super( criteriaBuilder );
		this.collectionPath = collectionPath;
	}

	@Override
	public PluralAttributePath getOperand() {
		return collectionPath;
	}

	@Override
	public void registerParameters(ParameterRegistry registry) {
		// nothing to do
	}

	@Override
	public String render(boolean isNegated, RenderingContext renderingContext) {
		final String operator = isNegated ? " is not empty" : " is empty";
		return getOperand().render( renderingContext ) + operator;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy