MethodTreeUtils { public static boolean isHashCodeMethod(MethodTree m) { boolean hasHashCodeSignature = isNamed(m, "hashCode") && m.parameters().isEmpty() && returnsInt(m); return isPublic(m) && !isStatic(m) && hasHashCodeSignature; } 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_hashcode_method() { assertTrue(MethodTreeUtils.isHashCodeMethod(parseMethod("class A { public int hashCode(){} }"))); assertFalse(MethodTreeUtils.isHashCodeMethod(parseMethod("class A { public static int hashCode(){} }"))); assertFalse(MethodTreeUtils.isHashCodeMethod(parseMethod("class A { private int hashCode(){} }"))); assertFalse(MethodTreeUtils.isHashCodeMethod(parseMethod("class A { public int hashcode(){} }"))); assertFalse(MethodTreeUtils.isHashCodeMethod(parseMethod("class A { public boolean hashCode(){} }"))); assertFalse(MethodTreeUtils.isHashCodeMethod(parseMethod("class A { public int hashCode(int a){} }"))); }