private[sorter] def featureValueSortDefaultValue[FeatureValue: Ordering]()

in product-mixer/component-library/src/main/scala/com/twitter/product_mixer/component_library/selector/sorter/FeatureValueSorter.scala [185:215]


  private[sorter] def featureValueSortDefaultValue[FeatureValue: Ordering](
    feature: Feature[_, FeatureValue],
    sortOrder: SortOrder
  )(
    implicit typeTag: TypeTag[FeatureValue]
  ): FeatureValue = {
    val defaultValue = sortOrder match {
      case Descending =>
        typeOf[FeatureValue] match {
          case t if t <:< typeOf[Short] => Short.MinValue
          case t if t <:< typeOf[Int] => Int.MinValue
          case t if t <:< typeOf[Long] => Long.MinValue
          case t if t <:< typeOf[Double] => Double.MinValue
          case t if t <:< typeOf[Float] => Float.MinValue
          case _ =>
            throw new UnsupportedOperationException(s"Default value not supported for $feature")
        }
      case Ascending =>
        typeOf[FeatureValue] match {
          case t if t <:< typeOf[Short] => Short.MaxValue
          case t if t <:< typeOf[Int] => Int.MaxValue
          case t if t <:< typeOf[Long] => Long.MaxValue
          case t if t <:< typeOf[Double] => Double.MaxValue
          case t if t <:< typeOf[Float] => Float.MaxValue
          case _ =>
            throw new UnsupportedOperationException(s"Default value not supported for $feature")
        }
    }

    defaultValue.asInstanceOf[FeatureValue]
  }