![JAR search and dependency download from the Maven repository](/logo.png)
org.ibatis.persist.impl.expression.NullifExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbatis Show documentation
Show all versions of jbatis Show documentation
The jBATIS persistence framework will help you to significantly reduce the amount of Java code that you normally need to access a relational database. iBATIS simply maps JavaBeans to SQL statements using a very simple XML descriptor.
The newest version!
package org.ibatis.persist.impl.expression;
import org.ibatis.persist.criteria.Expression;
import org.ibatis.persist.impl.CriteriaBuilderImpl;
import org.ibatis.persist.impl.Renderable;
import org.ibatis.persist.impl.RenderingContext;
/**
* Models an ANSI SQL NULLIF expression. NULLIF is a specialized CASE statement.
*/
@SuppressWarnings("unchecked")
public class NullifExpression extends ExpressionImpl {
private final Expression extends T> primaryExpression;
private final Expression> secondaryExpression;
public NullifExpression(
CriteriaBuilderImpl criteriaBuilder,
Class javaType,
Expression extends T> primaryExpression,
Expression> secondaryExpression) {
super( criteriaBuilder, (Class)determineType(javaType, primaryExpression) );
this.primaryExpression = primaryExpression;
this.secondaryExpression = secondaryExpression;
}
public NullifExpression(
CriteriaBuilderImpl criteriaBuilder,
Class javaType,
Expression extends T> primaryExpression,
Object secondaryExpression) {
super( criteriaBuilder, (Class)determineType(javaType, primaryExpression) );
this.primaryExpression = primaryExpression;
this.secondaryExpression = new LiteralExpression( criteriaBuilder, secondaryExpression );
}
private static Class determineType(Class javaType, Expression primaryExpression) {
return javaType != null ? javaType : primaryExpression.getJavaType();
}
public Expression extends T> getPrimaryExpression() {
return primaryExpression;
}
public Expression> getSecondaryExpression() {
return secondaryExpression;
}
public void render(RenderingContext rc) {
rc.append("nullif(");
((Renderable) getPrimaryExpression()).render(rc);
rc.append(',');
((Renderable) getSecondaryExpression()).render(rc);
rc.append(")");
}
public void renderProjection(RenderingContext rc) {
render(rc);
if (getAlias() != null) {
rc.append(" AS ").append(getAlias());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy