One possibility would be to hide (a bit) the class from your users:
sealed trait DeptEntry
object DeptEntry {
def apply(url: String, fullName: String,
address: String, city: String): DeptEntry = // ...
case class Value protected[DeptEntry](
url: String, fullName: String, address: String, city: String
)
}
This way there is no conflict and you still can pattern match on DeptEntry.Value
if you need. It depends on your use case if this solution is convenient or not. If you want that the trait has the proper val
s, you can declare it as
sealed trait DeptEntry {
val url: String
val fullName: String
val address: String
val city: String
}
and the fields in the case class
will override them.