public ExpressionBuilder or ( ) { GroupExpression lastGroupExpression = stack . isEmpty ( ) ? null : stack . peek ( ) ; if ( lhsExpression == null ) { throw new SyntaxException ( "Syntax exception: OR missing LHS operand" ) ; } else if ( lastGroupExpression == null ) { GroupExpression or = new GroupExpression ( GroupExpression . Type . OR ) ; or . add ( lhsExpression ) ; stack . push ( or ) ; expression . setExpression ( or ) ; lhsExpression = null ; } else if ( lastGroupExpression . getType ( ) . equals ( GroupExpression . Type . OR ) ) { // Keep using the existing OR lhsExpression = null ; return this ; } else if ( lastGroupExpression . getType ( ) . equals ( GroupExpression . Type . AND ) ) { // AND takes precedence over OR, so we wrap the AND // by removing it from any parent expressions and inserting the OR in its place GroupExpression and = stack . pop ( ) ; GroupExpression or = new GroupExpression ( GroupExpression . Type . OR ) ; if ( stack . isEmpty ( ) ) { expression . setExpression ( or ) ; or . add ( and ) ; } else { // need to get at the parent GroupExpression parent = stack . pop ( ) ; parent . remove ( and ) ; parent . add ( or ) ; or . add ( and ) ; } stack . push ( and ) ; stack . push ( or ) ; lhsExpression = null ; } return this ; }
Appends an OR expression to the RHS of the expression . The current RHS of the expression must be an Operand .