I'm working with a lot of Option and I need to use pattern match/case almost every call to check if object is None or not.
Is possible to write cleaner code when you use a lot of match cases?
def process(schema: Option[String], body: String, token:String, queueInfo: Map[String, String]) = {
jsonSchemaService.findByDescriptionFromCache(schema) match {
case Some(jsonSchema) =>
jsonSchema.schema match {
case Some(s) =>
val ku = buildKinesisUtils(token, queueInfo)
validateAndPublish(body, s, ku)
case None =>
Future(Left(SchemaNotDefinedException(s"O Json schema [$schema] não possui um schema definido")))
}
case None =>
Future(Left(SchemaNotFoundException("Não foi possível encontrar o JsonSchema informado")))
}
}