File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
main/kotlin/behaviorgraph
test/kotlin/behaviorgraph Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,9 @@ open class Extent<ExtentContext: Any> @JvmOverloads constructor(val graph: Graph
104104 */
105105 fun addToGraph () {
106106 if (graph.currentEvent != null ) {
107- nameResources()
107+ if (graph.automaticResourceNaming) {
108+ nameResources()
109+ }
108110 graph.addExtent(this )
109111 } else {
110112 throw BehaviorGraphException (" addToGraph must be called within an event. Extent=$this " )
Original file line number Diff line number Diff line change @@ -58,6 +58,13 @@ class Graph @JvmOverloads constructor(private val dateProvider: DateProvider? =
5858 */
5959 var validateLifetimes: Boolean = true
6060
61+ /* *
62+ * System uses reflection to automatically name resources as extents are added to the graph.
63+ * This makes debugging significantly easier; however it does come with some small cost.
64+ * You may disable this here.
65+ */
66+ var automaticResourceNaming: Boolean = true
67+
6168 /* *
6269 * The current action may update one or more resources. Inspecting this list lets us
6370 * identify which action initiated the current event.
Original file line number Diff line number Diff line change @@ -50,6 +50,18 @@ class ExtentTest : AbstractBehaviorGraphTest() {
5050 assertEquals(" custom_r2" , e.r2.debugName)
5151 }
5252
53+ @Test
54+ fun `automatic naming can be disabled` () {
55+ g.automaticResourceNaming = false
56+ val e = TestExtentLocal (g)
57+ e.addToGraphWithAction()
58+
59+ // won't get automatic name
60+ assertEquals(null , e.r1.debugName)
61+ // custom name still works
62+ assertEquals(" custom_r2" , e.r2.debugName)
63+ }
64+
5365 @Test
5466 fun `added resource is updated on adding` () {
5567 val e = TestExtent (g)
You can’t perform that action at this time.
0 commit comments