Created
May 21, 2024 16:07
-
-
Save eutkin/cd66190f856313f745a35e2d76291515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Component | |
class Detail : Component | |
class Model(val details: List<Component> = ArrayList()) : Component | |
operator fun Model.plusAssign(component: Component) { | |
this.details + component | |
} | |
interface Source | |
class DetailSource : Source | |
class Packet(val content : List<Source>) : Source | |
val rootPacket = Packet(arrayListOf()) // пакет с другими пакетами и деталями | |
val rootModel = Model() | |
rootModel += buildModel(rootPacket) | |
fun buildModel(packet: Packet) : Model { | |
val packets = packet.content | |
val model = Model() | |
for (childPacket in packets) { | |
val childModel = buildModel(packet) | |
model += childModel | |
} | |
return model | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment