Bytecode implements Cloneable, Serializable { @Override public int hashCode() { return Objects.hash(sourceInstructions, stepInstructions); }  void addSource(final String sourceName, final Object... arguments); void addStep(final String stepName, final Object... arguments); List<Instruction> getSourceInstructions(); List<Instruction> getStepInstructions(); Iterable<Instruction> getInstructions(); Map<String, Object> getBindings(); boolean isEmpty(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") @Override Bytecode clone();  }
@Test public void shouldHaveProperHashAndEquality() { final GraphTraversalSource g = EmptyGraph.instance().traversal(); final Traversal.Admin traversal1 = g.V().out().repeat(__.out().in()).times(2).groupCount().by(__.outE().count()).select(Column.keys).order().by(Order.desc).asAdmin(); final Traversal.Admin traversal2 = g.V().out().repeat(__.out().in()).times(2).groupCount().by(__.outE().count()).select(Column.keys).order().by(Order.desc).asAdmin(); final Traversal.Admin traversal3 = g.V().out().repeat(__.out().in()).times(2).groupCount().by(__.outE().count()).select(Column.values).order().by(Order.desc).asAdmin(); assertEquals(traversal1, traversal2); assertNotEquals(traversal1, traversal3); assertNotEquals(traversal2, traversal3); assertEquals(traversal1.hashCode(), traversal2.hashCode()); assertNotEquals(traversal1.hashCode(), traversal3.hashCode()); assertNotEquals(traversal2.hashCode(), traversal3.hashCode()); assertEquals(traversal1.getBytecode(), traversal2.getBytecode()); assertNotEquals(traversal1.getBytecode(), traversal3.getBytecode()); assertNotEquals(traversal2.getBytecode(), traversal3.getBytecode()); assertEquals(traversal1.getBytecode().hashCode(), traversal2.getBytecode().hashCode()); assertNotEquals(traversal1.getBytecode().hashCode(), traversal3.getBytecode().hashCode()); assertNotEquals(traversal2.getBytecode().hashCode(), traversal3.getBytecode().hashCode()); }
@Test public void shouldNotHaveHashCollisionsWithBindings() { final Bytecode.Binding<String> first = new Bytecode.Binding<>("3", "7"); final Bytecode.Binding<String> second = new Bytecode.Binding<>("7", "3"); assertNotEquals(first, second); assertNotEquals(first.hashCode(), second.hashCode()); }