本文整理了Java中com.querydsl.core.types.ExpressionUtils.extract()
方法的一些代码示例,展示了ExpressionUtils.extract()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExpressionUtils.extract()
方法的具体详情如下:
包路径:com.querydsl.core.types.ExpressionUtils
类名称:ExpressionUtils
方法名:extract
[英]Get the potentially wrapped expression
[中]获取潜在的包装表达式
代码示例来源:origin: querydsl/querydsl
/**
* Create a BooleanBuilder with the given initial value
*
* @param initial initial value
*/
public BooleanBuilder(Predicate initial) {
predicate = (Predicate) ExpressionUtils.extract(initial);
}
代码示例来源:origin: querydsl/querydsl
/**
* Create a new JTSGeometryExpression
*
* @param expr Expression of type Geometry
* @return new JTSGeometryExpression
*/
public static <T extends Geometry> JTSGeometryExpression<T> asJTSGeometry(
Expression<T> expr) {
Expression<T> underlyingMixin = ExpressionUtils.extract(expr);
return new JTSGeometryExpression<T>(underlyingMixin) {
private static final long serialVersionUID = -6714044005570420009L;
@Override
public <R, C> R accept(Visitor<R, C> v, C context) {
return this.mixin.accept(v, context);
}
};
}
代码示例来源:origin: querydsl/querydsl
@Override
public Object convert(final List<?> args) {
final Object arg = args.get(index);
if (arg instanceof Expression) {
return ExpressionUtils.extract((Expression<?>) arg);
} else {
return arg;
}
}
代码示例来源:origin: querydsl/querydsl
/**
* Create the intersection of the given arguments
*
* @param left lhs of expression
* @param right rhs of expression
* @return left and right
*/
public static Predicate and(Predicate left, Predicate right) {
left = (Predicate) extract(left);
right = (Predicate) extract(right);
if (left == null) {
return right;
} else if (right == null) {
return left;
} else {
return predicate(Ops.AND, left, right);
}
}
代码示例来源:origin: querydsl/querydsl
/**
* Create a {@code left or right} expression
*
* @param left lhs of expression
* @param right rhs of expression
* @return left or right
*/
public static Predicate or(Predicate left, Predicate right) {
left = (Predicate) extract(left);
right = (Predicate) extract(right);
if (left == null) {
return right;
} else if (right == null) {
return left;
} else {
return predicate(Ops.OR, left, right);
}
}
代码示例来源:origin: querydsl/querydsl
@Override
public void addHaving(Predicate e) {
if (e == null) {
return;
}
e = (Predicate) ExpressionUtils.extract(e);
if (e != null) {
// having elements can't be validated, since they can refer to projection elements
// that are declared later
having = and(having, e);
}
}
代码示例来源:origin: querydsl/querydsl
private static Expression<?> asExpression(Object arg) {
if (arg instanceof Expression) {
return ExpressionUtils.extract((Expression<?>) arg);
} else {
return Expressions.constant(arg);
}
}
代码示例来源:origin: querydsl/querydsl
/**
* Create a {@code this && right} expression
*
* <p>Returns an intersection of this and the given expression</p>
*
* @param right right hand side of the union
* @return {@code this && right}
*/
public BooleanExpression and(@Nullable Predicate right) {
right = (Predicate) ExpressionUtils.extract(right);
if (right != null) {
return Expressions.booleanOperation(Ops.AND, mixin, right);
} else {
return this;
}
}
代码示例来源:origin: querydsl/querydsl
/**
* Create a {@code this || right} expression
*
* <p>Returns a union of this and the given expression</p>
*
* @param right right hand side of the union
* @return this || right
*/
public BooleanExpression or(@Nullable Predicate right) {
right = (Predicate) ExpressionUtils.extract(right);
if (right != null) {
return Expressions.booleanOperation(Ops.OR, mixin, right);
} else {
return this;
}
}
代码示例来源:origin: querydsl/querydsl
private static Expression<?> unwrap(Expression<?> expr) {
expr = ExpressionUtils.extract(expr);
if (expr instanceof Operation && ((Operation<?>) expr).getOperator() == Ops.ALIAS) {
return ((Operation<?>) expr).getArg(0);
}
return expr;
}
代码示例来源:origin: querydsl/querydsl
public Query toQuery(Expression<?> expr, QueryMetadata metadata) {
if (expr instanceof Operation<?>) {
return toQuery((Operation<?>) expr, metadata);
} else {
return toQuery(ExpressionUtils.extract(expr), metadata);
}
}
代码示例来源:origin: querydsl/querydsl
public Query toQuery(Expression<?> expr, QueryMetadata metadata) {
if (expr instanceof Operation<?>) {
return toQuery((Operation<?>) expr, metadata);
} else {
return toQuery(ExpressionUtils.extract(expr), metadata);
}
}
代码示例来源:origin: querydsl/querydsl
public Query toQuery(Expression<?> expr, QueryMetadata metadata) {
if (expr instanceof Operation<?>) {
return toQuery((Operation<?>) expr, metadata);
} else {
return toQuery(ExpressionUtils.extract(expr), metadata);
}
}
代码示例来源:origin: querydsl/querydsl
@Override
public void addWhere(Predicate e) {
if (e == null) {
return;
}
e = (Predicate) ExpressionUtils.extract(e);
if (e != null) {
validate(e);
where = and(where, e);
}
}
代码示例来源:origin: querydsl/querydsl
/**
* Create a new GeometryExpression
*
* @param expr Expression of type Geometry
* @return new GeometryExpression
*/
public static <T extends Geometry> GeometryExpression<T> asGeometry(Expression<T> expr) {
Expression<T> underlyingMixin = ExpressionUtils.extract(expr);
if (underlyingMixin instanceof PathImpl) {
return new GeometryPath<T>((PathImpl<T>) underlyingMixin);
} else if (underlyingMixin instanceof OperationImpl) {
return new GeometryOperation<T>((OperationImpl<T>) underlyingMixin);
} else {
return new GeometryExpression<T>(underlyingMixin) {
private static final long serialVersionUID = -6714044005570420009L;
@Override
public <R, C> R accept(Visitor<R, C> v, C context) {
return this.mixin.accept(v, context);
}
};
}
}
代码示例来源:origin: querydsl/querydsl
@Override
protected Predicate convert(Predicate predicate, Role role) {
predicate = (Predicate) ExpressionUtils.extract(predicate);
if (predicate != null) {
Context context = new Context();
Predicate transformed = (Predicate) predicate.accept(collectionAnyVisitor, context);
for (int i = 0; i < context.paths.size(); i++) {
leftJoin(
(Path) context.paths.get(i).getMetadata().getParent(),
(Path) context.replacements.get(i));
on(ANY);
}
return transformed;
} else {
return predicate;
}
}
}
代码示例来源:origin: querydsl/querydsl
/**
* Create a new NumberExpression
*
* @param expr Expression of type Number
* @return new NumberExpression
*/
public static <T extends Number & Comparable<?>> NumberExpression<T> asNumber(Expression<T> expr) {
Expression<T> underlyingMixin = ExpressionUtils.extract(expr);
if (underlyingMixin instanceof PathImpl) {
return new NumberPath<T>((PathImpl<T>) underlyingMixin);
} else if (underlyingMixin instanceof OperationImpl) {
return new NumberOperation<T>((OperationImpl<T>) underlyingMixin);
} else if (underlyingMixin instanceof TemplateExpressionImpl) {
return new NumberTemplate<T>((TemplateExpressionImpl<T>) underlyingMixin);
} else {
return new NumberExpression<T>(underlyingMixin) {
private static final long serialVersionUID = -8712299418891960222L;
@Override
public <R, C> R accept(Visitor<R, C> v, C context) {
return this.mixin.accept(v, context);
}
};
}
}
代码示例来源:origin: querydsl/querydsl
/**
* Create a new BooleanExpression
*
* @param expr Expression of type Boolean
* @return new BooleanExpression
*/
public static BooleanExpression asBoolean(Expression<Boolean> expr) {
Expression<Boolean> underlyingMixin = ExpressionUtils.extract(expr);
if (underlyingMixin instanceof PathImpl) {
return new BooleanPath((PathImpl<Boolean>) underlyingMixin);
} else if (underlyingMixin instanceof PredicateOperation) {
return new BooleanOperation((PredicateOperation) underlyingMixin);
} else if (underlyingMixin instanceof PredicateTemplate) {
return new BooleanTemplate((PredicateTemplate) underlyingMixin);
} else {
return new BooleanExpression(underlyingMixin) {
private static final long serialVersionUID = -8712299418891960222L;
@Override
public <R, C> R accept(Visitor<R, C> v, C context) {
return this.mixin.accept(v, context);
}
};
}
}
代码示例来源:origin: querydsl/querydsl
/**
* Create a new EnumExpression
*
* @param expr Expression of type Enum
* @return new EnumExpression
*/
public static <T extends Enum<T>> EnumExpression<T> asEnum(Expression<T> expr) {
Expression<T> underlyingMixin = ExpressionUtils.extract(expr);
if (underlyingMixin instanceof PathImpl) {
return new EnumPath<T>((PathImpl<T>) underlyingMixin);
} else if (underlyingMixin instanceof OperationImpl) {
return new EnumOperation<T>((OperationImpl<T>) underlyingMixin);
} else if (underlyingMixin instanceof TemplateExpressionImpl) {
return new EnumTemplate<T>((TemplateExpressionImpl<T>) underlyingMixin);
} else {
return new EnumExpression<T>(underlyingMixin) {
private static final long serialVersionUID = 949681836002045152L;
@Override
public <R, C> R accept(Visitor<R, C> v, C context) {
return this.mixin.accept(v, context);
}
};
}
}
代码示例来源:origin: querydsl/querydsl
@Test
public void and_empty() {
BooleanBuilder builder = new BooleanBuilder();
builder.and(new BooleanBuilder());
assertNull(ExpressionUtils.extract(builder));
}
内容来源于网络,如有侵权,请联系作者删除!