summaryrefslogtreecommitdiff
path: root/opendc-core/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2017-09-08 12:57:12 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2017-09-08 12:57:12 +0200
commit314c68fb4b4202538cfdb21aa2a56b2aa3aad6fb (patch)
tree8047a1855ee70653083f2d8977cf6790c056526d /opendc-core/src/main
parent1a9cb7cfd2a67c32fd89d490f1462c59fa0d33b9 (diff)
Allow easier construction of graph via TopologyBuilder
This change allows for easier construction of a topology.
Diffstat (limited to 'opendc-core/src/main')
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt8
1 files changed, 8 insertions, 0 deletions
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt
index 5752eb89..20cbdb0c 100644
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt
+++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt
@@ -31,6 +31,14 @@ package nl.atlarge.opendc.topology
*/
interface TopologyBuilder {
/**
+ * Construct a [Topology] from the given block and return it.
+ *
+ * @param block The block to construct the topology.
+ * @return The topology that has been built.
+ */
+ fun construct(block: MutableTopology.() -> Unit): Topology = build().apply(block)
+
+ /**
* Build a [Topology] instance from the current state of this builder.
*
* @return The graph built from this builder.