HHH-5736 Removing unnecessary instance check. Applying Hibernate formatting.
This commit is contained in:
parent
0b2d6da3a3
commit
d333d98f58
|
@ -24,15 +24,15 @@
|
||||||
package org.hibernate.ejb.criteria.predicate;
|
package org.hibernate.ejb.criteria.predicate;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.persistence.criteria.Predicate;
|
import java.util.List;
|
||||||
import javax.persistence.criteria.Expression;
|
import javax.persistence.criteria.Expression;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
|
|
||||||
import org.hibernate.ejb.criteria.ParameterRegistry;
|
|
||||||
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
|
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
|
||||||
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
|
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
|
||||||
|
import org.hibernate.ejb.criteria.ParameterRegistry;
|
||||||
import org.hibernate.ejb.criteria.Renderable;
|
import org.hibernate.ejb.criteria.Renderable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,9 +50,9 @@ public class CompoundPredicate
|
||||||
/**
|
/**
|
||||||
* Constructs an empty conjunction or disjunction.
|
* Constructs an empty conjunction or disjunction.
|
||||||
*
|
*
|
||||||
* @param criteriaBuilder The query builder from whcih this originates.
|
* @param criteriaBuilder The query builder from which this originates.
|
||||||
* @param operator Indicates whether this predicate will funtion
|
* @param operator Indicates whether this predicate will function
|
||||||
* as a conjunction or disjuntion.
|
* as a conjunction or disjunction.
|
||||||
*/
|
*/
|
||||||
public CompoundPredicate(CriteriaBuilderImpl criteriaBuilder, BooleanOperator operator) {
|
public CompoundPredicate(CriteriaBuilderImpl criteriaBuilder, BooleanOperator operator) {
|
||||||
super( criteriaBuilder );
|
super( criteriaBuilder );
|
||||||
|
@ -63,8 +63,8 @@ public class CompoundPredicate
|
||||||
* Constructs a conjunction or disjunction over the given expressions.
|
* Constructs a conjunction or disjunction over the given expressions.
|
||||||
*
|
*
|
||||||
* @param criteriaBuilder The query builder from which this originates.
|
* @param criteriaBuilder The query builder from which this originates.
|
||||||
* @param operator Indicates whether this predicate will funtion
|
* @param operator Indicates whether this predicate will function
|
||||||
* as a conjunction or disjuntion.
|
* as a conjunction or disjunction.
|
||||||
* @param expressions The expressions to be grouped.
|
* @param expressions The expressions to be grouped.
|
||||||
*/
|
*/
|
||||||
public CompoundPredicate(
|
public CompoundPredicate(
|
||||||
|
@ -78,9 +78,9 @@ public class CompoundPredicate
|
||||||
/**
|
/**
|
||||||
* Constructs a conjunction or disjunction over the given expressions.
|
* Constructs a conjunction or disjunction over the given expressions.
|
||||||
*
|
*
|
||||||
* @param criteriaBuilder The query builder from whcih this originates.
|
* @param criteriaBuilder The query builder from which this originates.
|
||||||
* @param operator Indicates whether this predicate will funtion
|
* @param operator Indicates whether this predicate will function
|
||||||
* as a conjunction or disjuntion.
|
* as a conjunction or disjunction.
|
||||||
* @param expressions The expressions to be grouped.
|
* @param expressions The expressions to be grouped.
|
||||||
*/
|
*/
|
||||||
public CompoundPredicate(
|
public CompoundPredicate(
|
||||||
|
@ -153,24 +153,24 @@ public class CompoundPredicate
|
||||||
* Create negation of compound predicate by using logic rules:
|
* Create negation of compound predicate by using logic rules:
|
||||||
* 1. not (x || y) is (not x && not y)
|
* 1. not (x || y) is (not x && not y)
|
||||||
* 2. not (x && y) is (not x || not y)
|
* 2. not (x && y) is (not x || not y)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Predicate not() {
|
public Predicate not() {
|
||||||
if (this.operator == BooleanOperator.AND) {
|
toggleOperator();
|
||||||
this.operator = BooleanOperator.OR;
|
|
||||||
} else {
|
|
||||||
this.operator = BooleanOperator.AND;
|
|
||||||
}
|
|
||||||
for ( Expression expr : this.getExpressions() ) {
|
for ( Expression expr : this.getExpressions() ) {
|
||||||
if ( Predicate.class.isInstance( expr ) ) {
|
if ( Predicate.class.isInstance( expr ) ) {
|
||||||
( (Predicate) expr ).not();
|
( (Predicate) expr ).not();
|
||||||
}
|
}
|
||||||
else if(CompoundPredicate.class.isInstance(expr)) {
|
|
||||||
( (CompoundPredicate) expr ).not();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toggleOperator() {
|
||||||
|
if ( this.operator == BooleanOperator.AND ) {
|
||||||
|
this.operator = BooleanOperator.OR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.operator = BooleanOperator.AND;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue