def leadParser(optionTuples: Option[(Option[(Option[(Option[(Option[(
Option[Iterable[EmailLead]],
Option[Iterable[QuestionLead]])],
Option[Iterable[LocalMarketQuestionLead]])],
Option[Iterable[OfferLead]])],
Option[Iterable[Bid]])],
Option[Iterable[CreditApplicationLeadWithEbayId]])]) = {
optionTuples match{
case None => (None, None, None, None, None, None)
case Some(c) =>
val creditApplictaionIteratorOption = c._2
c._1 match {
case None => (None, None, None, None, None, creditApplictaionIteratorOption)
case Some(b) =>
val bidIteratorOption = b._2
b._1 match {
case None => (None, None, None, None, bidIteratorOption, creditApplictaionIteratorOption)
case Some(o) =>
val offerIteratorOption = o._2
o._1 match {
case None => (None, None, None, offerIteratorOption, bidIteratorOption, creditApplictaionIteratorOption)
case Some(l) =>
val localMarketQuestionIteratorOption = l._2
l._1 match {
case None => (None, None, localMarketQuestionIteratorOption, offerIteratorOption, bidIteratorOption, creditApplictaionIteratorOption)
case Some(q) =>
val questionIteratorOption = q._2
val emailIteratorOption = q._1
(emailIteratorOption, questionIteratorOption, localMarketQuestionIteratorOption, offerIteratorOption, bidIteratorOption, creditApplictaionIteratorOption)
}
}
}
}
}
}
I know the input Option[... looks insane but this is what I receive from a Spark operation so I have to deal with it. Could there be a better way of getting all the Iterator Options from this complicated tuple/option structure ?