MethodBehavior { @Override public int hashCode() { return new HashCodeBuilder(11, 74377) .append(signature) .append(arity) .append(varArgs) .append(complete) .append(visited) .append(declaredExceptions) .append(yields) .toHashCode(); } MethodBehavior(String signature, boolean varArgs); void addYield(MethodYield yield); void createYield(ExplodedGraph.Node node); ExceptionalYield createExceptionalCheckBasedYield(SymbolicValue target, ExplodedGraph.Node node, String exceptionType, SECheck check); boolean isMethodVarArgs(); int methodArity(); List<MethodYield> yields(); Stream<ExceptionalYield> exceptionalPathYields(); Stream<HappyPathYield> happyPathYields(); void addParameter(SymbolicValue sv); List<SymbolicValue> parameters(); boolean isComplete(); void completed(); boolean isVisited(); void visited(); String signature(); void setVarArgs(boolean varArgs); List<String> getDeclaredExceptions(); void setDeclaredExceptions(List<String> declaredExceptions); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test void hashcode() { MethodBehavior mb = newMethodBehavior("foo()Ljava/lang/Object;"); addYield(mb, ObjectConstraint.NOT_NULL); addYield(mb, ObjectConstraint.NULL); MethodBehavior sameSignatureAndYield = newMethodBehavior("foo()Ljava/lang/Object;"); addYield(sameSignatureAndYield, ObjectConstraint.NOT_NULL); addYield(sameSignatureAndYield, ObjectConstraint.NULL); MethodBehavior differentYield = newMethodBehavior("foo()Ljava/lang/Object;"); addYield(differentYield, ObjectConstraint.NULL); MethodBehavior differentSignature = newMethodBehavior("bar()Ljava/lang/Object;"); addYield(differentSignature, ObjectConstraint.NOT_NULL); addYield(differentSignature, ObjectConstraint.NULL); assertThat(mb).hasSameHashCodeAs(sameSignatureAndYield); assertThat(mb.hashCode()) .isNotEqualTo(differentYield.hashCode()) .isNotEqualTo(differentSignature.hashCode()); }