From a5fc2c635599d1a760b1a22b2e4e3033c4f13c06 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Mon, 8 Apr 2019 08:37:45 +0200 Subject: [PATCH] switch to a private constructor for filter element --- .../android/model/realm/FilterElement.kt | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/FilterElement.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/FilterElement.kt index be590588..d6eb5d55 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/FilterElement.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/FilterElement.kt @@ -9,7 +9,12 @@ import net.pokeranalytics.android.ui.view.rowrepresentable.FilterElementRow.* import java.util.* import kotlin.collections.ArrayList -open class FilterElement(var filterName : String = "", var sectionName: String = "") : RealmObject() { +open class FilterElement() : RealmObject() { + + private constructor(filterName:String, sectionName:String) : this() { + this.filterName = filterName + this.sectionName = sectionName + } constructor(filterElementRows: ArrayList) : this(filterElementRows.first().filterName, filterElementRows.first().filterSectionRow.name) { this.stringValues = when (QueryType.valueOf(this.filterName)) { @@ -81,6 +86,9 @@ open class FilterElement(var filterName : String = "", var sectionName: String = } } + var filterName : String = "" + var sectionName : String = "" + val queryType : QueryType get() = QueryType.valueOf(filterName) .apply { @@ -93,7 +101,7 @@ open class FilterElement(var filterName : String = "", var sectionName: String = private var blindValues : RealmList? = null val ids : Array - get() = stringValues?.toTypedArray()?: throw FilterValueMapException("filter type not handled") + get() = stringValues?.toTypedArray()?: throw FilterValueMapException("filter type not handled") val blinds : RealmList get() { @@ -109,36 +117,36 @@ open class FilterElement(var filterName : String = "", var sectionName: String = val date : Date - get() = dateValue?: throw FilterValueMapException("filter type not handled") + get() = dateValue?: throw FilterValueMapException("filter type not handled") val values : Array get() = numericValues?.map { it.toInt() - }?.toTypedArray()?: throw FilterValueMapException("filter type not handled") + }?.toTypedArray()?: throw FilterValueMapException("filter type not handled") val value : Double - get() = numericValues?.first()?: throw FilterValueMapException("filter type not handled") + get() = numericValues?.first()?: throw FilterValueMapException("filter type not handled") val leftValue : Double - get() = numericValues?.first()?: throw FilterValueMapException("filter type not handled") + get() = numericValues?.first()?: throw FilterValueMapException("filter type not handled") val rightValue : Double - get() = numericValues?.last()?: throw FilterValueMapException("filter type not handled") + get() = numericValues?.last()?: throw FilterValueMapException("filter type not handled") val dayOfWeek : Int - get() = numericValues?.first()?.toInt()?: throw FilterValueMapException("filter type not handled") + get() = numericValues?.first()?.toInt()?: throw FilterValueMapException("filter type not handled") val month : Int - get() = numericValues?.first()?.toInt()?: throw FilterValueMapException("filter type not handled") + get() = numericValues?.first()?.toInt()?: throw FilterValueMapException("filter type not handled") val year : Int - get() = numericValues?.first()?.toInt()?: throw FilterValueMapException("filter type not handled") + get() = numericValues?.first()?.toInt()?: throw FilterValueMapException("filter type not handled") }