Skip to content

Commit

Permalink
Added constructor for safe gson deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
aneonex committed Sep 5, 2021
1 parent 29101f7 commit 84cd192
Showing 1 changed file with 13 additions and 2 deletions.
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
)
}
}

0 comments on commit 84cd192

Please sign in to comment.