create getInternalProperties() method Separate out the construction details of internal properties to a separate method so that higher level property expansion policies are more obvious. Change-Id: I981a50ea4013a1f6a8fe198901fb399071c2d4ef
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/Properties.java b/src/main/java/com/googlesource/gerrit/plugins/task/Properties.java index d63d441..51887a7 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/task/Properties.java +++ b/src/main/java/com/googlesource/gerrit/plugins/task/Properties.java
@@ -37,15 +37,7 @@ public Properties(ChangeData changeData, Task definition, Map<String, String> parentProperties) throws OrmException { Map<String, String> expanded = new HashMap<>(parentProperties); - expanded.put("_name", definition.name); - Change c = changeData.change(); - expanded.put("_change_number", String.valueOf(c.getId().get())); - expanded.put("_change_id", c.getKey().get()); - expanded.put("_change_project", c.getProject().get()); - expanded.put("_change_branch", c.getDest().get()); - expanded.put("_change_status", c.getStatus().toString()); - expanded.put("_change_topic", c.getTopic()); - + expanded.putAll(getInternalProperties(definition, changeData)); Map<String, String> unexpanded = definition.properties; unexpanded.putAll(definition.exported); new RecursiveExpander(expanded).expand(unexpanded); @@ -62,6 +54,23 @@ new Expander(properties).expandFieldValues(namesFactory, Sets.newHashSet(TaskConfig.KEY_TYPE)); } + protected static Map<String, String> getInternalProperties(Task definition, ChangeData changeData) + throws OrmException { + Map<String, String> properties = new HashMap<>(); + + properties.put("_name", definition.name); + + Change c = changeData.change(); + properties.put("_change_number", String.valueOf(c.getId().get())); + properties.put("_change_id", c.getKey().get()); + properties.put("_change_project", c.getProject().get()); + properties.put("_change_branch", c.getDest().get()); + properties.put("_change_status", c.getStatus().toString()); + properties.put("_change_topic", c.getTopic()); + + return properties; + } + /** * Use to expand properties whose values may contain other references to properties. *