Migration implements Comparable<Migration> { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Migration migration = (Migration) o; return oldVersion == migration.oldVersion && newVersion == migration.newVersion; } 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 equalsTest() throws Exception { assertEquals(new MigrationStub(1, 2), new MigrationStub(1, 2)); assertNotEquals(new MigrationStub(1, 2), new MigrationStub(1, 3)); assertNotEquals(new MigrationStub(1, 3), new MigrationStub(2, 3)); assertNotEquals(new MigrationStub(1, 2), new MigrationStub(2, 3)); }