now making sure that ids re prefixed by the config id.
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / RobustIdentifiable.java
index f3da5f401e98f0dd7ae252c8c04458c781a51ad9..640e37e13385402e9414c6beb2719bb3d6e2d378 100644 (file)
@@ -37,15 +37,16 @@ public class RobustIdentifiable<T> implements Identifiable<T> {
     // TODO test this class.
     // TODO test that id is constant even though delegated changes its id.
 
-    public RobustIdentifiable(Identifiable<T> aIdentifiable) {
+    public RobustIdentifiable(String aPrefix, Identifiable<T> aIdentifiable) {
         // TODO test id is null
         // TODO getId() throws exception
         try {
             id = aIdentifiable.getId();
             if (id == null) {
                 id = new Id<T>(Constants.UNKNOWN_ID.toString());
-                throw new RuntimeException(
-                    "Temporary to catch nulls during refactoring");
+                temporarilyThrowException();
+            } else {
+                id = new Id<T>(aPrefix + id.getId());
             }
         } catch (Exception e) {
             LOGGER
@@ -54,6 +55,11 @@ public class RobustIdentifiable<T> implements Identifiable<T> {
 
     }
 
+    private void temporarilyThrowException() {
+        throw new RuntimeException(
+            "Temporary to catch nulls during refactoring");
+    }
+
     @Override
     public Id<T> getId() {
         return id;