in src/main/java/org/apache/sling/scripting/sightly/compiler/expression/nodes/BinaryOperator.java [224:259]
public static boolean strictEq(Object left, Object right) {
if (left instanceof Number && right instanceof Number) {
return ((Number) left).doubleValue() == ((Number) right).doubleValue();
}
if (left instanceof String && right instanceof String) {
return left.equals(right);
}
if (left instanceof Boolean && right instanceof Boolean) {
return left.equals(right);
}
if (left instanceof Enum && right instanceof Enum) {
return left.equals(right);
}
if (left == null && right == null) {
return true;
}
if ((left instanceof Enum && right instanceof String) || (left instanceof String && right instanceof Enum)) {
String constantName = left instanceof String ? (String) left : (String) right;
Enum enumObject = left instanceof Enum ? (Enum) left : (Enum) right;
try {
Enum enumComparisonObject = Enum.valueOf(enumObject.getClass(), constantName);
return enumComparisonObject == enumObject;
} catch (Exception e) {
return false;
}
}
if (left == null || right == null) {
Object notNull = (left != null) ? left : right;
if (notNull instanceof String || notNull instanceof Boolean || notNull instanceof Number) {
return false;
}
}
throw new SightlyCompilerException(
"Operands are not of the same type: the equality operator can only be applied to String, Number,"
+ "Boolean and Enum types. Operands are: leftOperand=" + left + ", rightOperand=" + right);
}