Scala:枚举类型的用法

枚举定义:

/**
  * 场景类型的划分分类:划分出7类
  */
object BuildingCalibrateHeightType extends Enumeration {
  type BuildingCalibrateHeightType = Value

  val UnKnow = Value("-1")
  val HeightType1 = Value("1") // 0-21
  val HeightType2 = Value("2") // 21-45
  val HeightType3 = Value("3") // 45-100
  val HeightType4 = Value("4") // 45-100
  val HeightType5 = Value("5") // 45-100
  val HeightType6 = Value("6") // 45-100
  val HeightType7 = Value("7") // 45-100

  def checkExists(day: String) = this.values.exists(_.toString == day)

  def showAll = this.values.foreach(println)
}

 

posted @ 2018-03-01 21:43  cctext  阅读(1397)  评论(0编辑  收藏  举报