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

org.hibernate.query.criteria.internal.predicate.NullnessPredicate 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 javax.persistence.criteria.Expression;

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

/**
 * Defines a {@link javax.persistence.criteria.Predicate} for checking the
 * nullness state of an expression, aka an IS [NOT] NULL predicate.
 * 

* The NOT NULL form can be built by calling the constructor and then * calling {@link #not}. * * @author Steve Ebersole */ public class NullnessPredicate extends AbstractSimplePredicate implements UnaryOperatorExpression, Serializable { private final Expression operand; /** * Constructs the affirmitive form of nullness checking (IS NULL). To * construct the negative form (IS NOT NULL) call {@link #not} on the * constructed instance. * * @param criteriaBuilder The query builder from whcih this originates. * @param operand The expression to check. */ public NullnessPredicate(CriteriaBuilderImpl criteriaBuilder, Expression operand) { super( criteriaBuilder ); this.operand = operand; } @Override public Expression getOperand() { return operand; } @Override public void registerParameters(ParameterRegistry registry) { Helper.possibleParameter( getOperand(), registry ); } @Override public String render(boolean isNegated, RenderingContext renderingContext) { return ( (Renderable) operand ).render( renderingContext ) + check( isNegated ); } private String check(boolean negated) { return negated ? " is not null" : " is null"; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy