MCPcopy Index your code
hub / github.com/apache/tomcat / equals

Method equals

java/org/apache/el/lang/ELSupport.java:146–179  ·  view source on GitHub ↗

Compare two objects for equality, after coercing to the same type if appropriate. If the objects are identical (including both null) return true. If either object is null, return false. If either object is Boolean, coerce both to Boolean and check equality. Similarly for Enum, String

(final ELContext ctx, final Object obj0, final Object obj1)

Source from the content-addressed store, hash-verified

144 * @throws ELException if one of the coercion fails
145 */
146 public static boolean equals(final ELContext ctx, final Object obj0, final Object obj1) throws ELException {
147 if (obj0 == obj1) {
148 return true;
149 } else if (obj0 == null || obj1 == null) {
150 return false;
151 } else if (isBigDecimalOp(obj0, obj1)) {
152 BigDecimal bd0 = (BigDecimal) coerceToNumber(ctx, obj0, BigDecimal.class);
153 BigDecimal bd1 = (BigDecimal) coerceToNumber(ctx, obj1, BigDecimal.class);
154 return bd0.equals(bd1);
155 } else if (isDoubleOp(obj0, obj1)) {
156 Double d0 = (Double) coerceToNumber(ctx, obj0, Double.class);
157 Double d1 = (Double) coerceToNumber(ctx, obj1, Double.class);
158 return d0.equals(d1);
159 } else if (isBigIntegerOp(obj0, obj1)) {
160 BigInteger bi0 = (BigInteger) coerceToNumber(ctx, obj0, BigInteger.class);
161 BigInteger bi1 = (BigInteger) coerceToNumber(ctx, obj1, BigInteger.class);
162 return bi0.equals(bi1);
163 } else if (isLongOp(obj0, obj1)) {
164 Long l0 = (Long) coerceToNumber(ctx, obj0, Long.class);
165 Long l1 = (Long) coerceToNumber(ctx, obj1, Long.class);
166 return l0.equals(l1);
167 } else if (obj0 instanceof Boolean || obj1 instanceof Boolean) {
168 return coerceToBoolean(ctx, obj0, false).equals(coerceToBoolean(ctx, obj1, false));
169 } else if (obj0.getClass().isEnum()) {
170 return obj0.equals(coerceToEnum(ctx, obj1, obj0.getClass()));
171 } else if (obj1.getClass().isEnum()) {
172 return obj1.equals(coerceToEnum(ctx, obj0, obj1.getClass()));
173 } else if (obj0 instanceof String || obj1 instanceof String) {
174 int lexCompare = coerceToString(ctx, obj0).compareTo(coerceToString(ctx, obj1));
175 return lexCompare == 0;
176 } else {
177 return obj0.equals(obj1);
178 }
179 }
180
181 /**
182 * Coerces an object to an Enum value of the specified type.

Callers 13

testEqualsMethod · 0.95
testValidDoubleMethod · 0.95
testValidBigDecimalMethod · 0.95
doTestValidMethod · 0.95
testAverage01Method · 0.95
testAverage02Method · 0.95
testSum01Method · 0.95
testSum02Method · 0.95
testCount01Method · 0.95
testCount02Method · 0.95
compareMethod · 0.95
getValueMethod · 0.95

Calls 10

isBigDecimalOpMethod · 0.95
coerceToNumberMethod · 0.95
isDoubleOpMethod · 0.95
isBigIntegerOpMethod · 0.95
isLongOpMethod · 0.95
coerceToBooleanMethod · 0.95
coerceToEnumMethod · 0.95
coerceToStringMethod · 0.95
equalsMethod · 0.65
compareToMethod · 0.65

Tested by 10

testEqualsMethod · 0.76
testValidDoubleMethod · 0.76
testValidBigDecimalMethod · 0.76
doTestValidMethod · 0.76
testAverage01Method · 0.76
testAverage02Method · 0.76
testSum01Method · 0.76
testSum02Method · 0.76
testCount01Method · 0.76
testCount02Method · 0.76