All Downloads are FREE. Search and download functionalities are using the official Maven repository.

verfi_2.9.0.0.1.0.source-code.semver.scala Maven / Gradle / Ivy

There is a newer version: 0.1.2
Show newest version
package semverfi

object Version {
  def apply(in: String): SemVersion =
     Parse(in) match {
      case Parse.Success(v, _) => v
      case _ => Invalid(in)
    }
}

sealed trait SemVersion {
  def major: Int
  def minor: Int
  def patch: Int
}

case class Invalid(raw: String) extends SemVersion {
  def major = -1
  def minor = -1
  def patch = -1
}

abstract class Valid extends SemVersion with Bumping

case class NormalVersion(major: Int, minor: Int, patch: Int)
     extends Valid

case class PreReleaseVersion(major: Int,
                     minor: Int,
                     patch: Int,
                     classifier: Seq[String])
     extends Valid

case class BuildVersion(major: Int,
                     minor: Int,
                     patch: Int,
                     classifier: Seq[String],
                     build: Seq[String])
  extends Valid {
    lazy val classified = ! classifier.isEmpty
    lazy val unclassified = ! classified
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy