GroupPath

sealed interface GroupPath

Where a group sits in a Topology, read from root down: a child the config declares, a child the consumer attached while running beneath a group with a template, or a child it attached beneath one of those, whose template carries a template of its own.

The arms are what keep an attached child apart from a declared sibling of the same name: Attached(listOf("tenants"), "x") and Declared(listOf("tenants", "x")) are different paths, and Topology.findGroupId gives them different ids. Each group has exactly one path: a child of a declared group is Attached, and a child of an attached one is Nested.

Every name is non-empty, because no topology declares or attaches an empty one; a path holding one names nothing, so it cannot be built.

Samples

val pool = draft("pool") {
    group("tenants") {
        lane("x")
        template()
    }
}
// A declared lane and an attached child share the name `x`, and their paths stay apart.
val lane = GroupPath.Declared(listOf("tenants", "x"))
val tenant = GroupPath.Attached(group = listOf("tenants"), name = "x")
val laneId = checkNotNull(pool.findGroupId(lane))
val tenantId = checkNotNull(pool.findGroupId(tenant))
check(laneId == pool.groupId("tenants", "x") && tenantId == pool.attachedChildId(listOf("tenants"), "x"))
check(laneId != tenantId)

// Back from an id: the arm says whether the last name is an attached child's.
check(pool.findPath(laneId) == lane && pool.findPath(tenantId) == tenant)
check(pool.findPath(tenantId)?.names == listOf("tenants", "x"))
check(pool.findPath(pool.groupId()) == GroupPath.Declared(emptyList()))

// Not in this topology: `null`, never an exception.
check(pool.findGroupId(GroupPath.Declared(listOf("tenants", "y"))) == null)
check(pool.findGroupId(GroupPath.Attached(listOf("tenants", "x"), "y")) == null)
check(pool.findPath(GroupId("elsewhere/tenants")) == null)

Inheritors

Types

Link copied to clipboard
data class Attached(val group: List<String>, val name: String) : GroupPath

An attached child name of the declared group at group, which is never the root: the root carries no template.

Link copied to clipboard
data class Declared(val names: List<String>) : GroupPath

A group the topology declares: names from just below the root, [] for the root itself.

Link copied to clipboard
data class Nested(val parent: GroupPath, val name: String) : GroupPath

An attached child name of the attached group at parent: a child the consumer attached beneath another attached child, whose template carries a template of its own.

Properties

Link copied to clipboard
abstract val names: List<String>

The names from just below the root down to the group, ending with the attached child's own name if this is an Attached or a Nested. [] is the root.