Type nullif in ComparableExpression and StringExpression

This commit is contained in:
Jan-Willem Gmelig Meyling 2021-01-25 23:05:25 +01:00
parent d651911bd5
commit 3ed6c822bb
2 changed files with 46 additions and 0 deletions

View File

@ -13,6 +13,7 @@
*/
package com.querydsl.core.types.dsl;
import com.querydsl.core.types.ConstantImpl;
import com.querydsl.core.types.Ops;
import org.jetbrains.annotations.Nullable;
@ -80,6 +81,28 @@ public abstract class ComparableExpressionBase<T extends Comparable> extends Sim
return coalesce;
}
/**
* Create a {@code nullif(this, other)} expression
*
* @param other
* @return nullif(this, other)
*/
@Override
public ComparableExpression<T> nullif(Expression<T> other) {
return Expressions.comparableOperation(this.getType(), Ops.NULLIF, this, other);
}
/**
* Create a {@code nullif(this, other)} expression
*
* @param other
* @return nullif(this, other)
*/
@Override
public ComparableExpression<T> nullif(T other) {
return nullif(ConstantImpl.create(other));
}
/**
* Create an OrderSpecifier for descending order of this expression
*

View File

@ -840,4 +840,27 @@ public abstract class StringExpression extends LiteralExpression<String> {
return upper;
}
/**
* Create a {@code nullif(this, other)} expression
*
* @param other
* @return nullif(this, other)
*/
@Override
public StringExpression nullif(Expression<String> other) {
return Expressions.stringOperation(Ops.NULLIF, this, other);
}
/**
* Create a {@code nullif(this, other)} expression
*
* @param other
* @return nullif(this, other)
*/
@Override
public StringExpression nullif(String other) {
return nullif(ConstantImpl.create(other));
}
}