public static int comparePrimaryPredicates ( boolean isFirstNegated , PrimaryPredicateExpr first , boolean isSecondNegated , PrimaryPredicateExpr second ) { if ( first . getClass ( ) == second . getClass ( ) ) { if ( first instanceof ComparisonExpr ) { ComparisonExpr comparison1 = ( ComparisonExpr ) first ; ComparisonExpr comparison2 = ( ComparisonExpr ) second ; assert comparison1 . getLeftChild ( ) instanceof PropertyValueExpr ; assert comparison1 . getRightChild ( ) instanceof ConstantValueExpr ; assert comparison2 . getLeftChild ( ) instanceof PropertyValueExpr ; assert comparison2 . getRightChild ( ) instanceof ConstantValueExpr ; if ( comparison1 . getLeftChild ( ) . equals ( comparison2 . getLeftChild ( ) ) && comparison1 . getRightChild ( ) . equals ( comparison2 . getRightChild ( ) ) ) { ComparisonExpr . Type cmpType1 = comparison1 . getComparisonType ( ) ; if ( isFirstNegated ) { cmpType1 = cmpType1 . negate ( ) ; } ComparisonExpr . Type cmpType2 = comparison2 . getComparisonType ( ) ; if ( isSecondNegated ) { cmpType2 = cmpType2 . negate ( ) ; } return cmpType1 == cmpType2 ? 0 : ( cmpType1 == cmpType2 . negate ( ) ? 1 : - 1 ) ; } } else if ( first . equals ( second ) ) { return isFirstNegated == isSecondNegated ? 0 : 1 ; } } return - 1 ; }
Checks if two predicates are identical or opposite .