entries = node.getEntries();
if (entries.isEmpty()) {
replace(node, new SqlNull());
}
else if (entries.size() == 1) {
Entry entry = entries.get(0);
if (entry.getCondition() instanceof TrueValue) {
replace(node, entry.getResult().clone());
}
else if (entry.getCondition() instanceof FalseValue) {
replace(node, new SqlNull());
}
else if (entry.getCondition() instanceof SqlNot) {
SqlNot not = (SqlNot)entry.getCondition();
if (not.getArg() instanceof SqlIsNull) {
SqlIsNull is = (SqlIsNull)not.getArg();
if (is.getArg().equals(entry.getResult())) {
replace(node, entry.getResult().clone());
}
}
}
}
}