-
Notifications
You must be signed in to change notification settings - Fork 73
/
ComponentDescription.scala
56 lines (45 loc) · 1.47 KB
/
ComponentDescription.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package ch.epfl.bluebrain.nexus.delta.sdk.model
/**
* The description of a component of the system (service or plugin)
*/
sealed trait ComponentDescription extends Product with Serializable {
/**
* @return
* the name of the component
*/
def name: Name
/**
* @return
* the version of the component
*/
def version: String
}
object ComponentDescription {
private val unknownVersion = "unknown"
/**
* The description of a service
*/
sealed trait ServiceDescription extends ComponentDescription
object ServiceDescription {
final case class ResolvedServiceDescription private (name: Name, version: String) extends ServiceDescription
final case class UnresolvedServiceDescription private (name: Name) extends ServiceDescription {
override val version: String = unknownVersion
}
/**
* Creates a [[ResolvedServiceDescription]] from the passed ''name'' and ''version''.
*/
def apply(name: Name, version: String): ResolvedServiceDescription =
ResolvedServiceDescription(name, version)
/**
* Creates a [[UnresolvedServiceDescription]] with the passed ''name''.
*/
def unresolved(name: Name): UnresolvedServiceDescription =
UnresolvedServiceDescription(name)
}
/**
* The description of a plugin
*/
final case class PluginDescription(name: Name, version: String) extends ComponentDescription {
override def toString: String = s"$name-$version"
}
}