if (stateObject.isDecorated()) {
toText(stateObject);
}
else {
ExistsExpression expression = stateObject.getExpression();
// 'NOT'
if (stateObject.hasNot()) {
appendIdentifier((expression != null) ? expression.getActualNotIdentifier() : NOT, NOT);
writer.append(SPACE);
}
// 'EXISTS'
String actualIdentifier = (expression != null) ? expression.getActualIdentifier() : null;
if ((actualIdentifier != null) && actualIdentifier.startsWith(NOT)) {
actualIdentifier = actualIdentifier.substring(4);
}
appendIdentifier(actualIdentifier, EXISTS);
// '('
if (shouldOutput(expression) || expression.hasLeftParenthesis()) {
writer.append(formatIdentifier(LEFT_PARENTHESIS));
}
// Subquery
if (stateObject.hasStateObject()) {
stateObject.getStateObject().accept(this);
}
// ')'
if (shouldOutput(expression) || expression.hasRightParenthesis()) {
writer.append(formatIdentifier(RIGHT_PARENTHESIS));
}
}
}