private FieldTextBuilder binaryOperation ( final String operator , final FieldText fieldText ) { // This should never happen as the AND, OR, XOR and WHEN methods should already have checked this Validate . isTrue ( fieldText != this ) ; // Optimized case when fieldText is a FieldTextBuilder if ( fieldText instanceof FieldTextBuilder ) { return binaryOp ( operator , ( FieldTextBuilder ) fieldText ) ; } // Special case when we're empty if ( componentCount == 0 ) { fieldTextString . append ( fieldText . toString ( ) ) ; if ( fieldText . size ( ) > 1 ) { lastOperator = "" ; } } else { // Add the NOTs, parentheses and operator addOperator ( operator ) ; // Size 1 means a single specifier, so no parentheses if ( fieldText . size ( ) == 1 ) { fieldTextString . append ( fieldText . toString ( ) ) ; } else { fieldTextString . append ( ' ' ) . append ( fieldText . toString ( ) ) . append ( ' ' ) ; } } componentCount += fieldText . size ( ) ; not = false ; return this ; }
Does the work for the OR AND XOR and WHEN methods .