Exemplo de objeto aplicando somente ações a estrutura de dados imutável.
case class UserMeasures(state: Map[String,Any]) { | |
def gender : String = { | |
state.getOrElse("usr_genero", "").asInstanceOf[String] | |
} | |
def measures: List[Map[String,Any]] = { | |
state.getOrElse("measures", List[Map[String,Any]]()).asInstanceOf[List[Map[String,Any]]] | |
} | |
def findMeasureByIndustryId(id:Int): Option[Map[String, Any]] = { | |
measures.find { stateUserMeasure => | |
val userIndustryId = stateUserMeasure.getOrElse("ind_tmd_id", -1).asInstanceOf[Int] | |
id == userIndustryId | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment