mirror of https://github.com/sbt/sbt.git
Make most case classes final
This commit is contained in:
parent
5f9f854562
commit
2e50db9486
|
|
@ -9,7 +9,7 @@ package coursier.core
|
|||
*
|
||||
* Using the same terminology as Ivy.
|
||||
*/
|
||||
case class Module(
|
||||
final case class Module(
|
||||
organization: String,
|
||||
name: String,
|
||||
attributes: Map[String, String]
|
||||
|
|
@ -36,7 +36,7 @@ case class Module(
|
|||
* The remaining fields are left untouched, some being transitively
|
||||
* propagated (exclusions, optional, in particular).
|
||||
*/
|
||||
case class Dependency(
|
||||
final case class Dependency(
|
||||
module: Module,
|
||||
version: String,
|
||||
configuration: String,
|
||||
|
|
@ -52,7 +52,7 @@ case class Dependency(
|
|||
}
|
||||
|
||||
// Maven-specific
|
||||
case class Attributes(
|
||||
final case class Attributes(
|
||||
`type`: String,
|
||||
classifier: String
|
||||
) {
|
||||
|
|
@ -60,7 +60,7 @@ case class Attributes(
|
|||
Publication(name, `type`, ext, classifier)
|
||||
}
|
||||
|
||||
case class Project(
|
||||
final case class Project(
|
||||
module: Module,
|
||||
version: String,
|
||||
// First String is configuration (scope for Maven)
|
||||
|
|
@ -91,7 +91,7 @@ case class Project(
|
|||
}
|
||||
|
||||
/** Extra project info, not used during resolution */
|
||||
case class Info(
|
||||
final case class Info(
|
||||
description: String,
|
||||
homePage: String,
|
||||
licenses: Seq[(String, Option[String])],
|
||||
|
|
@ -100,7 +100,7 @@ case class Info(
|
|||
)
|
||||
|
||||
object Info {
|
||||
case class Developer(
|
||||
final case class Developer(
|
||||
id: String,
|
||||
name: String,
|
||||
url: String
|
||||
|
|
@ -110,10 +110,10 @@ object Info {
|
|||
}
|
||||
|
||||
// Maven-specific
|
||||
case class Activation(properties: Seq[(String, Option[String])])
|
||||
final case class Activation(properties: Seq[(String, Option[String])])
|
||||
|
||||
// Maven-specific
|
||||
case class Profile(
|
||||
final case class Profile(
|
||||
id: String,
|
||||
activeByDefault: Option[Boolean],
|
||||
activation: Activation,
|
||||
|
|
@ -123,7 +123,7 @@ case class Profile(
|
|||
)
|
||||
|
||||
// Maven-specific
|
||||
case class Versions(
|
||||
final case class Versions(
|
||||
latest: String,
|
||||
release: String,
|
||||
available: List[String],
|
||||
|
|
@ -131,7 +131,7 @@ case class Versions(
|
|||
)
|
||||
|
||||
object Versions {
|
||||
case class DateTime(
|
||||
final case class DateTime(
|
||||
year: Int,
|
||||
month: Int,
|
||||
day: Int,
|
||||
|
|
@ -142,7 +142,7 @@ object Versions {
|
|||
}
|
||||
|
||||
// Maven-specific
|
||||
case class SnapshotVersion(
|
||||
final case class SnapshotVersion(
|
||||
classifier: String,
|
||||
extension: String,
|
||||
value: String,
|
||||
|
|
@ -150,7 +150,7 @@ case class SnapshotVersion(
|
|||
)
|
||||
|
||||
// Maven-specific
|
||||
case class SnapshotVersioning(
|
||||
final case class SnapshotVersioning(
|
||||
module: Module,
|
||||
version: String,
|
||||
latest: String,
|
||||
|
|
@ -163,7 +163,7 @@ case class SnapshotVersioning(
|
|||
)
|
||||
|
||||
// Ivy-specific
|
||||
case class Publication(
|
||||
final case class Publication(
|
||||
name: String,
|
||||
`type`: String,
|
||||
ext: String,
|
||||
|
|
@ -172,7 +172,7 @@ case class Publication(
|
|||
def attributes: Attributes = Attributes(`type`, classifier)
|
||||
}
|
||||
|
||||
case class Artifact(
|
||||
final case class Artifact(
|
||||
url: String,
|
||||
checksumUrls: Map[String, String],
|
||||
extra: Map[String, Artifact],
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ object Resolution {
|
|||
* @param projectCache: cache of known projects
|
||||
* @param errorCache: keeps track of the modules whose project definition could not be found
|
||||
*/
|
||||
case class Resolution(
|
||||
final case class Resolution(
|
||||
rootDependencies: Set[Dependency],
|
||||
dependencies: Set[Dependency],
|
||||
forceVersions: Map[Module, String],
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ sealed trait ResolutionProcess {
|
|||
def current: Resolution
|
||||
}
|
||||
|
||||
case class Missing(
|
||||
final case class Missing(
|
||||
missing: Seq[(Module, String)],
|
||||
current: Resolution,
|
||||
cont: Resolution => ResolutionProcess
|
||||
|
|
@ -93,7 +93,7 @@ case class Missing(
|
|||
|
||||
}
|
||||
|
||||
case class Continue(
|
||||
final case class Continue(
|
||||
current: Resolution,
|
||||
cont: Resolution => 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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,23 +47,23 @@ object Version {
|
|||
def repr: String
|
||||
def next: Numeric
|
||||
}
|
||||
case class Number(value: Int) extends Numeric {
|
||||
final case class Number(value: Int) extends Numeric {
|
||||
val order = 0
|
||||
def next: Number = Number(value + 1)
|
||||
def repr: String = value.toString
|
||||
override def compareToEmpty = value.compare(0)
|
||||
}
|
||||
case class BigNumber(value: BigInt) extends Numeric {
|
||||
final case class BigNumber(value: BigInt) extends Numeric {
|
||||
val order = 0
|
||||
def next: BigNumber = BigNumber(value + 1)
|
||||
def repr: String = value.toString
|
||||
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
|
||||
override def compareToEmpty = level.compare(0)
|
||||
}
|
||||
case class Literal(value: String) extends Item {
|
||||
final case class Literal(value: String) extends Item {
|
||||
val order = -1
|
||||
override def compareToEmpty = if (value.isEmpty) 0 else 1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,15 +88,15 @@ sealed trait VersionConstraint {
|
|||
}
|
||||
object VersionConstraint {
|
||||
/** 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 repr: String = version.repr
|
||||
}
|
||||
case class Interval(interval: VersionInterval) extends VersionConstraint {
|
||||
final case class Interval(interval: VersionInterval) extends VersionConstraint {
|
||||
def repr: String = interval.repr
|
||||
}
|
||||
case object None extends VersionConstraint {
|
||||
val interval = VersionInterval.zero
|
||||
def repr: String = "" // Once parsed, "(,)" becomes "" because of this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ object Pattern {
|
|||
def apply(content: String): Map[String, String] => String \/ String
|
||||
}
|
||||
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 = {
|
||||
assert(content.length == effectiveEnd - effectiveStart)
|
||||
val matches = variableRegex.findAllMatchIn(content).toList
|
||||
|
|
@ -54,7 +54,7 @@ object Pattern {
|
|||
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 end = end0
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ object Pattern {
|
|||
|
||||
}
|
||||
|
||||
case class Pattern(
|
||||
final case class Pattern(
|
||||
pattern: String,
|
||||
properties: Map[String, String]
|
||||
) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue