This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 3543694192880438b9cb03153472749a36dc1712
Author: Alex Heneveld <[email protected]>
AuthorDate: Mon May 1 12:20:49 2023 +0100

    no need for children to be a field in template processor
---
 .../org/apache/brooklyn/util/core/text/TemplateProcessor.java    | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git 
a/core/src/main/java/org/apache/brooklyn/util/core/text/TemplateProcessor.java 
b/core/src/main/java/org/apache/brooklyn/util/core/text/TemplateProcessor.java
index e37d2d7164..066489c3d1 100644
--- 
a/core/src/main/java/org/apache/brooklyn/util/core/text/TemplateProcessor.java
+++ 
b/core/src/main/java/org/apache/brooklyn/util/core/text/TemplateProcessor.java
@@ -619,7 +619,6 @@ public class TemplateProcessor {
         protected final EntityDriver driver;
         protected final ManagementContext mgmt;
         protected final DotSplittingTemplateModel extraSubstitutionsModel;
-        protected final Collection<Entity> children;
 
         // TODO the extra substitutions here (and in 
LocationAndMapTemplateModel) could be replaced with
         // FirstAvailableTemplateModel(entityModel, mapHashModel)
@@ -629,7 +628,6 @@ public class TemplateProcessor {
             this.entity = entity !=null ? entity : driver!=null ? 
(EntityInternal) driver.getEntity() : null;
             this.mgmt = mgmt != null ? mgmt : this.entity!=null ? 
this.entity.getManagementContext() : null;
             extraSubstitutionsModel = new DotSplittingTemplateModel(null);
-            this.children = this.entity !=null ? this.entity.getChildren(): 
null;
         }
 
         @Override
@@ -652,7 +650,6 @@ public class TemplateProcessor {
         @Deprecated /** @deprecated since 1.1 use {@link #forEntity(Entity, 
Map)} and related instead; substitions added separately using {@link 
FirstAvailableTemplateModel }*/
         protected EntityAndMapTemplateModel(ManagementContext mgmt, 
Map<String,? extends Object> extraSubstitutions) {
             this.entity = null;
-            this.children = null;
             this.driver = null;
             this.mgmt = mgmt;
             this.extraSubstitutionsModel = new 
DotSplittingTemplateModel(extraSubstitutions);
@@ -662,7 +659,6 @@ public class TemplateProcessor {
         protected EntityAndMapTemplateModel(EntityDriver driver, Map<String,? 
extends Object> extraSubstitutions) {
             this.driver = driver;
             this.entity = (EntityInternal) driver.getEntity();
-            this.children = this.entity != null ? this.entity.getChildren(): 
null;
             this.mgmt = entity.getManagementContext();
             this.extraSubstitutionsModel = new 
DotSplittingTemplateModel(extraSubstitutions);
         }
@@ -670,7 +666,6 @@ public class TemplateProcessor {
         @Deprecated /** @deprecated since 1.1 use {@link #forEntity(Entity, 
Map)} and related instead; substitions added separately using {@link 
FirstAvailableTemplateModel }*/
         protected EntityAndMapTemplateModel(EntityInternal entity, 
Map<String,? extends Object> extraSubstitutions) {
             this.entity = entity;
-            this.children = this.entity != null ? this.entity.getChildren(): 
null;
             this.driver = null;
             this.mgmt = entity.getManagementContext();
             this.extraSubstitutionsModel = new 
DotSplittingTemplateModel(extraSubstitutions);
@@ -704,8 +699,8 @@ public class TemplateProcessor {
                 if (entity!=null)
                     return wrapAsTemplateModel( Iterables.getOnlyElement( 
entity.getLocations() ) );
             }
-            if ("children".equals(key) && children!=null)
-                return wrapAsTemplateModel( children );
+            if ("children".equals(key) && entity!=null)
+                return wrapAsTemplateModel( entity.getChildren() );
             if ("sensor".equals(key)) return new 
EntityAttributeTemplateModel(entity, 
EntityAttributeTemplateModel.SensorResolutionMode.ATTRIBUTE_VALUE);
             if ("attribute".equals(key)) return new 
EntityAttributeTemplateModel(entity, 
EntityAttributeTemplateModel.SensorResolutionMode.ATTRIBUTE_VALUE);
             if ("attributeWhenReady".equals(key)) return new 
EntityAttributeTemplateModel(entity, 
EntityAttributeTemplateModel.SensorResolutionMode.ATTRIBUTE_WHEN_READY);

Reply via email to