Eliminate the Properties.Task inner class

Previously we had a Properties.Task and a Properties.NamesFactory. This
was done mostly so that they could extend the Expander class which was
also defined as an inner class of Properties. However the NamesFactory
class was removed in a previous change because it made calling
conventions a bit clunky when applying the COW pattern. Because they are
tied together and can potentially need to influence each other's
behavior, it also helps to have a single class which handles the
properties for both Tasks and NamesFactories. Now that there is a single
class, it makes more sense to have that class be the top level
Properties class, and not the Properties.Task class. Move all the
Porperties.Task logic to Properties and eliminate Properties.Task.

Change-Id: Ib540986b403c984bed22826e84a08305d7626426
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 8f5e1fd..ae40364 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/Properties.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/Properties.java
@@ -19,6 +19,7 @@
 import com.google.gerrit.server.query.change.ChangeData;
 import com.google.gwtorm.server.OrmException;
 import com.googlesource.gerrit.plugins.task.TaskConfig.NamesFactory;
+import com.googlesource.gerrit.plugins.task.TaskConfig.Task;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -32,35 +33,38 @@
 import java.util.regex.Pattern;
 
 /** Use to expand properties like ${_name} in the text of various definitions. */
+/** Use to expand properties specifically for Tasks. */
 public class Properties {
-  /** Use to expand properties specifically for Tasks. */
-  public static class Task extends Expander {
-    public static final Task EMPTY_PARENT = new Task();
+  public static final Properties EMPTY_PARENT = new Properties();
 
-    public Task() {}
+  protected Expander expander;
 
-    public Task(ChangeData changeData, TaskConfig.Task definition, Task parentProperties)
-        throws OrmException {
-      putAll(parentProperties.getAll());
-      putAll(getInternalProperties(definition, changeData));
-      putAll(definition.getAllProperties());
-
-      definition.setExpandedProperties(getAll());
-
-      expandFieldValues(definition, Collections.emptySet());
-    }
-
-    /** Use to expand properties specifically for NamesFactories. */
-    public NamesFactory getNamesFactory(NamesFactory namesFactory) {
-      return expand(
-          namesFactory,
-          nf -> namesFactory.config.new NamesFactory(nf),
-          Sets.newHashSet(TaskConfig.KEY_TYPE));
-    }
+  public Properties() {
+    expander = new Expander();
   }
 
-  protected static Map<String, String> getInternalProperties(
-      TaskConfig.Task definition, ChangeData changeData) throws OrmException {
+  public Properties(ChangeData changeData, Task definition, Properties parentProperties)
+      throws OrmException {
+    expander = new Expander();
+    expander.putAll(parentProperties.expander.getAll());
+    expander.putAll(getInternalProperties(definition, changeData));
+    expander.putAll(definition.getAllProperties());
+
+    definition.setExpandedProperties(expander.getAll());
+
+    expander.expandFieldValues(definition, Collections.emptySet());
+  }
+
+  /** Use to expand properties specifically for NamesFactories. */
+  public NamesFactory getNamesFactory(NamesFactory namesFactory) {
+    return expander.expand(
+        namesFactory,
+        nf -> namesFactory.config.new NamesFactory(nf),
+        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);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java
index a359764..16126af 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java
@@ -146,14 +146,14 @@
       return parent == null ? TaskTree.this.changeData : parent.getChangeData();
     }
 
-    protected Properties.Task getProperties() {
-      return Properties.Task.EMPTY_PARENT;
+    protected Properties getProperties() {
+      return Properties.EMPTY_PARENT;
     }
   }
 
   public class Node extends NodeList {
     public final Task task;
-    protected final Properties.Task properties;
+    protected final Properties properties;
 
     public Node(NodeList parent, Task definition) throws ConfigInvalidException, OrmException {
       this.parent = parent;
@@ -161,7 +161,7 @@
       this.path.addAll(parent.path);
       this.path.add(key());
       Preloader.preload(definition);
-      properties = new Properties.Task(getChangeData(), definition, parent.getProperties());
+      properties = new Properties(getChangeData(), definition, parent.getProperties());
     }
 
     public String key() {
@@ -284,7 +284,7 @@
     }
 
     @Override
-    protected Properties.Task getProperties() {
+    protected Properties getProperties() {
       return properties;
     }
   }