Migration implements Comparable<Migration> { @Override public int hashCode() { int result = oldVersion; result = 31 * result + newVersion; return result; } Migration(int oldVersion, int newVersion); @Override int compareTo(@NonNull Migration o); @Override boolean equals(Object o); @Override int hashCode(); abstract void migrate(SQLiteDatabase database); final int oldVersion; final int newVersion; }
@Test public void hashCodeTest() throws Exception { MigrationStub migrationStub1 = new MigrationStub(1, 2); MigrationStub migrationStub2 = new MigrationStub(1, 2); assertEquals(migrationStub1.hashCode(), migrationStub1.hashCode()); assertEquals(migrationStub1, migrationStub2); assertEquals(migrationStub1.hashCode(), migrationStub2.hashCode()); }