|
|
|
@ -3,6 +3,7 @@ package net.pokeranalytics.android.model.realm |
|
|
|
import io.realm.RealmObject |
|
|
|
import io.realm.RealmObject |
|
|
|
import io.realm.annotations.Ignore |
|
|
|
import io.realm.annotations.Ignore |
|
|
|
import io.realm.annotations.PrimaryKey |
|
|
|
import io.realm.annotations.PrimaryKey |
|
|
|
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.util.UserDefaults |
|
|
|
import net.pokeranalytics.android.util.UserDefaults |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
@ -22,6 +23,17 @@ open class Currency : RealmObject() { |
|
|
|
* The currency code of the currency, i.e. USD, EUR... |
|
|
|
* The currency code of the currency, i.e. USD, EUR... |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
var code: String? = null |
|
|
|
var code: String? = null |
|
|
|
|
|
|
|
set(value) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (value != null) { |
|
|
|
|
|
|
|
java.util.Currency.getInstance(value) // test validity of code |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
field = value |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
// make app crash earlier than later, possibly to show an error message to the user in the future |
|
|
|
|
|
|
|
throw PAIllegalStateException(e.localizedMessage) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The rate of the currency with the main currency |
|
|
|
* The rate of the currency with the main currency |
|
|
|
|