private def unwrapOptionType()

in elitzur-scio/src/main/scala/com/spotify/elitzur/scio/ElitzurMetrics.scala [79:93]


  private def unwrapOptionType(optType: Type): Class[_] =
    getParameterizedInnerType(optType).asInstanceOf[Class[_]]

  private def unwrapValidationStatus(vsType: Type): Class[_] = {
    // assume we either have a ValidationStatus[Option[T]] or a ValidationStatus[T]
    val innerType = getParameterizedInnerType(vsType)
    innerType match {
      case it: Class[_] =>
        // if innerType is a Class[_] then the nested type wasn't itself parameterized
        it
      case pt: ParameterizedType =>
        // we can't cast this to a Class, so it's an Option[T], remove one layer and cast that
        getParameterizedInnerType(pt).asInstanceOf[Class[_]]
    }
  }