本文整理汇总了Java中com.mysema.query.types.path.NumberPath.eq方法的典型用法代码示例。如果您正苦于以下问题:Java NumberPath.eq方法的具体用法?Java NumberPath.eq怎么用?Java NumberPath.eq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysema.query.types.path.NumberPath
的用法示例。
在下文中一共展示了NumberPath.eq方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNumberExpressionEqual
import com.mysema.query.types.path.NumberPath; //导入方法依赖的package包/类
/**
* Return where clause expression for number properties by casting it to
* string before check its value.
* <p/>
* Querydsl Expr:
* {@code entityPath.fieldName.stringValue() eq searchStr
* Database operation:
* {@code str(entity.fieldName) = searchStr
* <p/>
* Like operation is case sensitive.
*
* @param entityPath Full path to entity and associations. For example:
* {@code Pet} , {@code Pet.owner}
* @param fieldName Property name in the given entity path. For example:
* {@code weight} in {@code Pet} entity, {@code age} in
* {@code Pet.owner} entity.
* @param searchStr the value to find, may be null
* @return PredicateOperation
*/
@SuppressWarnings("unchecked")
public static <T, N extends java.lang.Number & java.lang.Comparable<?>> BooleanExpression createNumberExpressionEqual(
PathBuilder<T> entityPath, String fieldName, Class<N> fieldType,
TypeDescriptor descriptor, String searchStr,
ConversionService conversionService) {
if (StringUtils.isEmpty(searchStr)) {
return null;
}
NumberPath<N> numberExpression = entityPath.getNumber(fieldName,
fieldType);
TypeDescriptor strDesc = STRING_TYPE_DESCRIPTOR;
if (conversionService != null) {
try {
return numberExpression.eq((N) conversionService.convert(
searchStr, strDesc, descriptor));
}
catch (ConversionException ex) {
return numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
else {
return numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
示例2: createNumberExpressionEqual
import com.mysema.query.types.path.NumberPath; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public <T, N extends Number & Comparable<?>> BooleanExpression createNumberExpressionEqual(
PathBuilder<T> entityPath, String fieldName, Class<N> fieldType,
TypeDescriptor descriptor, String searchStr) {
if (StringUtils.isEmpty(searchStr)) {
return null;
}
NumberPath<N> numberExpression = entityPath.getNumber(fieldName,
fieldType);
TypeDescriptor strDesc = STRING_TYPE_DESCRIPTOR;
if (conversionService != null) {
try {
return numberExpression.eq((N) conversionService.convert(
searchStr, strDesc, descriptor));
}
catch (ConversionException ex) {
return numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
else {
return numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}