-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added constructor for safe gson deserialization
- Loading branch information
Showing
1 changed file
with
13 additions
and
2 deletions.
There are no files selected for viewing
15 changes: 13 additions & 2 deletions
15
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/CurrencyPairInfo.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 |
---|---|---|
@@ -1,9 +1,20 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
open class CurrencyPairInfo(val currencyBase: String, val currencyCounter: String, val currencyPairId: String?) : Comparable<CurrencyPairInfo> { | ||
open class CurrencyPairInfo( | ||
val currencyBase: String, | ||
val currencyCounter: String, | ||
val currencyPairId: String? | ||
) : Comparable<CurrencyPairInfo> { | ||
|
||
@Suppress("unused") // Used by Gson | ||
private constructor() : this("", "", null) | ||
|
||
@Throws(NullPointerException::class) | ||
override fun compareTo(other: CurrencyPairInfo): Int { | ||
val compBase = currencyBase.compareTo(other.currencyBase, ignoreCase = true) | ||
return if (compBase != 0) compBase else currencyCounter.compareTo(other.currencyCounter, ignoreCase = true) | ||
return if (compBase != 0) compBase else currencyCounter.compareTo( | ||
other.currencyCounter, | ||
ignoreCase = true | ||
) | ||
} | ||
} |