com.zepben.evolve.services.network.tracing.tree.TreeNode.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of evolve-sdk Show documentation
Show all versions of evolve-sdk Show documentation
SDK for interaction with the evolve platform
/*
* Copyright 2021 Zeppelin Bend Pty Ltd
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.zepben.evolve.services.network.tracing.tree
import com.zepben.evolve.cim.iec61970.base.core.ConductingEquipment
import com.zepben.evolve.services.common.extensions.asUnmodifiable
import java.lang.ref.WeakReference
class TreeNode(
val conductingEquipment: ConductingEquipment,
parent: TreeNode?
) {
val parent: TreeNode?
get() = _parent.get()
val children: List
get() = _children.asUnmodifiable()
val sortWeight: Int by lazy { conductingEquipment.terminals.maxOfOrNull { it.phases.singlePhases.size } ?: 1 }
private val _parent: WeakReference = WeakReference(parent)
private val _children = mutableListOf()
internal fun addChild(child: TreeNode) {
_children.add(child)
}
override fun toString(): String {
return "{conductingEquipment: " + conductingEquipment.mRID + ", parent: " + (parent?.conductingEquipment?.mRID
?: "") + ", num children: " + children.size + "}"
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy