MethodTreeUtils { public static boolean isEqualsMethod(MethodTree m) { boolean hasEqualsSignature = isNamed(m, "equals") && returnsPrimitive(m, "boolean") && hasObjectParameter(m); return isPublic(m) && !isStatic(m) && hasEqualsSignature; } private  MethodTreeUtils(); static boolean isMainMethod(MethodTree m); static boolean isEqualsMethod(MethodTree m); static boolean isHashCodeMethod(MethodTree m); static Optional<MethodInvocationTree> consecutiveMethodInvocation(Tree tree); static Optional<MethodInvocationTree> subsequentMethodInvocation(Tree tree, MethodMatchers methodMatchers);  }
@Test void is_equals_method() { assertTrue(MethodTreeUtils.isEqualsMethod(parseMethod("class A { public boolean equals(Object o){} }"))); assertFalse(MethodTreeUtils.isEqualsMethod(parseMethod("class A { private boolean equals(Object o){} }"))); assertFalse(MethodTreeUtils.isEqualsMethod(parseMethod("class A { public static boolean equals(Object o){} }"))); assertFalse(MethodTreeUtils.isEqualsMethod(parseMethod("class A { public boolean equal(Object o){} }"))); assertFalse(MethodTreeUtils.isEqualsMethod(parseMethod("class A { public boolean equals(Object o, int a){} }"))); assertFalse(MethodTreeUtils.isEqualsMethod(parseMethod("class A { public boolean equals(int a){} }"))); assertFalse(MethodTreeUtils.isEqualsMethod(parseMethod("class equals { public equals(Object o){} }"))); assertTrue(MethodTreeUtils.isEqualsMethod(parseMethod("interface I { public abstract boolean equals(Object o); }"))); }