package net.pokeranalytics.android.model.filter.interfaces

import net.pokeranalytics.android.exceptions.FilterValueMapException

interface ValueFilterable {

    var valueMap: Map<String, Any?>?

    var filterValues : Map<String, Any?>?
        get() {
            this.filterValuesExceptedKeys?.let { valueMapExceptedKeys ->
                valueMap?.let { map ->
                    var missingKeys = map.keys.filter { !valueMapExceptedKeys.contains(it) }
                    if (map.keys.size == valueMapExceptedKeys.size && missingKeys.isNotEmpty()) {
                        throw FilterValueMapException("valueMap does not contain ${missingKeys}")
                    }
                } ?: run {
                    throw FilterValueMapException("valueMap null not expected")
                }
            }
            return this.valueMap
        }
        set(value) {
            valueMap = value
        }

    val filterValuesExceptedKeys : Array<String>?
}