Allow to evolve l.d.Attributes while maintaining bin compat

This commit is contained in:
Alexandre Archambault 2019-04-25 16:29:06 +02:00
parent 353e991839
commit 48f7aa41dc
1 changed files with 33 additions and 4 deletions

View File

@ -1,6 +1,35 @@
package lmcoursier.definitions
final case class Attributes(
`type`: Type,
classifier: Classifier
)
final class Attributes private (
val `type`: Type,
val classifier: Classifier
) {
override def equals(obj: Any): Boolean =
obj match {
case other: Attributes =>
`type` == other.`type` && classifier == other.classifier
case _ => false
}
override def hashCode(): Int =
37 * (37 * (37 * (17 + "lmcoursier.definitions.Attributes".##) + `type`.##) + classifier.##)
override def toString: String =
s"Attributes(${`type`}, $classifier)"
private def copy(
`type`: Type = `type`,
classifier: Classifier = classifier
): Attributes =
new Attributes(`type`, classifier)
def withType(`type`: Type): Attributes =
copy(`type` = `type`)
def withClassifier(classifier: Classifier): Attributes =
copy(classifier = classifier)
}
object Attributes {
def apply(`type`: Type, classifier: Classifier): Attributes =
new Attributes(`type`, classifier)
}