Make most case classes final

This commit is contained in:
Alexandre Archambault 2016-01-31 21:06:06 +01:00
parent 5f9f854562
commit 2e50db9486
6 changed files with 28 additions and 28 deletions

View File

@ -9,7 +9,7 @@ package coursier.core
* *
* Using the same terminology as Ivy. * Using the same terminology as Ivy.
*/ */
case class Module( final case class Module(
organization: String, organization: String,
name: String, name: String,
attributes: Map[String, String] attributes: Map[String, String]
@ -36,7 +36,7 @@ case class Module(
* The remaining fields are left untouched, some being transitively * The remaining fields are left untouched, some being transitively
* propagated (exclusions, optional, in particular). * propagated (exclusions, optional, in particular).
*/ */
case class Dependency( final case class Dependency(
module: Module, module: Module,
version: String, version: String,
configuration: String, configuration: String,
@ -52,7 +52,7 @@ case class Dependency(
} }
// Maven-specific // Maven-specific
case class Attributes( final case class Attributes(
`type`: String, `type`: String,
classifier: String classifier: String
) { ) {
@ -60,7 +60,7 @@ case class Attributes(
Publication(name, `type`, ext, classifier) Publication(name, `type`, ext, classifier)
} }
case class Project( final case class Project(
module: Module, module: Module,
version: String, version: String,
// First String is configuration (scope for Maven) // First String is configuration (scope for Maven)
@ -91,7 +91,7 @@ case class Project(
} }
/** Extra project info, not used during resolution */ /** Extra project info, not used during resolution */
case class Info( final case class Info(
description: String, description: String,
homePage: String, homePage: String,
licenses: Seq[(String, Option[String])], licenses: Seq[(String, Option[String])],
@ -100,7 +100,7 @@ case class Info(
) )
object Info { object Info {
case class Developer( final case class Developer(
id: String, id: String,
name: String, name: String,
url: String url: String
@ -110,10 +110,10 @@ object Info {
} }
// Maven-specific // Maven-specific
case class Activation(properties: Seq[(String, Option[String])]) final case class Activation(properties: Seq[(String, Option[String])])
// Maven-specific // Maven-specific
case class Profile( final case class Profile(
id: String, id: String,
activeByDefault: Option[Boolean], activeByDefault: Option[Boolean],
activation: Activation, activation: Activation,
@ -123,7 +123,7 @@ case class Profile(
) )
// Maven-specific // Maven-specific
case class Versions( final case class Versions(
latest: String, latest: String,
release: String, release: String,
available: List[String], available: List[String],
@ -131,7 +131,7 @@ case class Versions(
) )
object Versions { object Versions {
case class DateTime( final case class DateTime(
year: Int, year: Int,
month: Int, month: Int,
day: Int, day: Int,
@ -142,7 +142,7 @@ object Versions {
} }
// Maven-specific // Maven-specific
case class SnapshotVersion( final case class SnapshotVersion(
classifier: String, classifier: String,
extension: String, extension: String,
value: String, value: String,
@ -150,7 +150,7 @@ case class SnapshotVersion(
) )
// Maven-specific // Maven-specific
case class SnapshotVersioning( final case class SnapshotVersioning(
module: Module, module: Module,
version: String, version: String,
latest: String, latest: String,
@ -163,7 +163,7 @@ case class SnapshotVersioning(
) )
// Ivy-specific // Ivy-specific
case class Publication( final case class Publication(
name: String, name: String,
`type`: String, `type`: String,
ext: String, ext: String,
@ -172,7 +172,7 @@ case class Publication(
def attributes: Attributes = Attributes(`type`, classifier) def attributes: Attributes = Attributes(`type`, classifier)
} }
case class Artifact( final case class Artifact(
url: String, url: String,
checksumUrls: Map[String, String], checksumUrls: Map[String, String],
extra: Map[String, Artifact], extra: Map[String, Artifact],

View File

@ -424,7 +424,7 @@ object Resolution {
* @param projectCache: cache of known projects * @param projectCache: cache of known projects
* @param errorCache: keeps track of the modules whose project definition could not be found * @param errorCache: keeps track of the modules whose project definition could not be found
*/ */
case class Resolution( final case class Resolution(
rootDependencies: Set[Dependency], rootDependencies: Set[Dependency],
dependencies: Set[Dependency], dependencies: Set[Dependency],
forceVersions: Map[Module, String], forceVersions: Map[Module, String],

View File

@ -52,7 +52,7 @@ sealed trait ResolutionProcess {
def current: Resolution def current: Resolution
} }
case class Missing( final case class Missing(
missing: Seq[(Module, String)], missing: Seq[(Module, String)],
current: Resolution, current: Resolution,
cont: Resolution => ResolutionProcess cont: Resolution => ResolutionProcess
@ -93,7 +93,7 @@ case class Missing(
} }
case class Continue( final case class Continue(
current: Resolution, current: Resolution,
cont: Resolution => ResolutionProcess cont: Resolution => ResolutionProcess
) extends ResolutionProcess { ) extends ResolutionProcess {
@ -108,7 +108,7 @@ case class Continue(
} }
case class Done(resolution: Resolution) extends ResolutionProcess { final case class Done(resolution: Resolution) extends ResolutionProcess {
def current: Resolution = resolution def current: Resolution = resolution
} }

View File

@ -47,23 +47,23 @@ object Version {
def repr: String def repr: String
def next: Numeric def next: Numeric
} }
case class Number(value: Int) extends Numeric { final case class Number(value: Int) extends Numeric {
val order = 0 val order = 0
def next: Number = Number(value + 1) def next: Number = Number(value + 1)
def repr: String = value.toString def repr: String = value.toString
override def compareToEmpty = value.compare(0) override def compareToEmpty = value.compare(0)
} }
case class BigNumber(value: BigInt) extends Numeric { final case class BigNumber(value: BigInt) extends Numeric {
val order = 0 val order = 0
def next: BigNumber = BigNumber(value + 1) def next: BigNumber = BigNumber(value + 1)
def repr: String = value.toString def repr: String = value.toString
override def compareToEmpty = value.compare(0) override def compareToEmpty = value.compare(0)
} }
case class Qualifier(value: String, level: Int) extends Item { final case class Qualifier(value: String, level: Int) extends Item {
val order = -2 val order = -2
override def compareToEmpty = level.compare(0) override def compareToEmpty = level.compare(0)
} }
case class Literal(value: String) extends Item { final case class Literal(value: String) extends Item {
val order = -1 val order = -1
override def compareToEmpty = if (value.isEmpty) 0 else 1 override def compareToEmpty = if (value.isEmpty) 0 else 1
} }

View File

@ -88,15 +88,15 @@ sealed trait VersionConstraint {
} }
object VersionConstraint { object VersionConstraint {
/** Currently treated as minimum... */ /** Currently treated as minimum... */
case class Preferred(version: Version) extends VersionConstraint { final case class Preferred(version: Version) extends VersionConstraint {
def interval: VersionInterval = VersionInterval(Some(version), Option.empty, fromIncluded = true, toIncluded = false) def interval: VersionInterval = VersionInterval(Some(version), Option.empty, fromIncluded = true, toIncluded = false)
def repr: String = version.repr def repr: String = version.repr
} }
case class Interval(interval: VersionInterval) extends VersionConstraint { final case class Interval(interval: VersionInterval) extends VersionConstraint {
def repr: String = interval.repr def repr: String = interval.repr
} }
case object None extends VersionConstraint { case object None extends VersionConstraint {
val interval = VersionInterval.zero val interval = VersionInterval.zero
def repr: String = "" // Once parsed, "(,)" becomes "" because of this def repr: String = "" // Once parsed, "(,)" becomes "" because of this
} }
} }

View File

@ -23,7 +23,7 @@ object Pattern {
def apply(content: String): Map[String, String] => String \/ String def apply(content: String): Map[String, String] => String \/ String
} }
object PatternPart { object PatternPart {
case class Literal(override val effectiveStart: Int, override val effectiveEnd: Int) extends PatternPart(effectiveStart, effectiveEnd) { final case class Literal(override val effectiveStart: Int, override val effectiveEnd: Int) extends PatternPart(effectiveStart, effectiveEnd) {
def apply(content: String): Map[String, String] => String \/ String = { def apply(content: String): Map[String, String] => String \/ String = {
assert(content.length == effectiveEnd - effectiveStart) assert(content.length == effectiveEnd - effectiveStart)
val matches = variableRegex.findAllMatchIn(content).toList val matches = variableRegex.findAllMatchIn(content).toList
@ -54,7 +54,7 @@ object Pattern {
helper(0, matches, new StringBuilder) helper(0, matches, new StringBuilder)
} }
} }
case class Optional(start0: Int, end0: Int) extends PatternPart(start0 + 1, end0 - 1) { final case class Optional(start0: Int, end0: Int) extends PatternPart(start0 + 1, end0 - 1) {
override def start = start0 override def start = start0
override def end = end0 override def end = end0
@ -78,7 +78,7 @@ object Pattern {
} }
case class Pattern( final case class Pattern(
pattern: String, pattern: String,
properties: Map[String, String] properties: Map[String, String]
) { ) {