-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #773 from DroidKaigi/feature/issue550_add_equalabl…
…e_content_provider [Based on #766] add equalable content provider
- Loading branch information
Showing
9 changed files
with
94 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...ponent/src/main/java/io/github/droidkaigi/confsched2019/item/EqualableContentsProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.droidkaigi.confsched2019.item | ||
|
||
import java.util.Arrays | ||
|
||
interface EqualableContentsProvider { | ||
fun providerEqualableContents(): Array<*> | ||
|
||
override fun equals(other: Any?): Boolean | ||
|
||
override fun hashCode(): Int | ||
|
||
fun isSameContents(other: Any?): Boolean { | ||
other ?: return false | ||
if (other !is EqualableContentsProvider) return false | ||
if (other::class != this::class) return false | ||
return other.providerEqualableContents().contentDeepEquals(this.providerEqualableContents()) | ||
} | ||
|
||
fun contentsHash(): Int { | ||
return Arrays.deepHashCode(arrayOf(this::class, this.providerEqualableContents())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters