more typesafety in the interface
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / Transformations.java
index 20455e8a5e2b8633d4d783a5e1e26fed46e2c602..7fd3e10e7041efd6173dcc35832b94e67d0cbc46 100644 (file)
@@ -31,7 +31,7 @@ import org.wamblee.xmlrouter.config.Transformation;
 public class Transformations {
 
     private AtomicLong sequenceNumber;
-    private Map<Long, Transformation> transformations;
+    private Map<Id<Transformation>, Transformation> transformations;
     private List<String> vertices;
     private TransformationPath[][] matrix;
 
@@ -39,7 +39,7 @@ public class Transformations {
 
     public Transformations() {
         sequenceNumber = new AtomicLong(1);
-        transformations = new LinkedHashMap<Long, Transformation>();
+        transformations = new LinkedHashMap<Id<Transformation>, Transformation>();
         vertices = new ArrayList<String>();
         matrix = new TransformationPath[0][0];
     }
@@ -47,8 +47,7 @@ public class Transformations {
     public Id<Transformation> addTransformation(Transformation aTransformation) {
         long seqno = sequenceNumber.getAndIncrement();
         Id<Transformation> id = new Id<Transformation>(seqno);
-        transformations.put(seqno,
-            new RobustTransformation(id, aTransformation));
+        transformations.put(id, new RobustTransformation(id, aTransformation));
         computeTransformationSequences();
         return id;
     }
@@ -145,12 +144,16 @@ public class Transformations {
     }
 
     public void removeTransformation(Id<Transformation> aId) {
-        transformations.remove(aId.getId());
+        transformations.remove(aId);
         computeTransformationSequences();
     }
 
-    public Collection<Transformation> getTransformations() {
-        return Collections.unmodifiableCollection(transformations.values());
+    public Collection<Id<Transformation>> getTransformations() {
+        return Collections.unmodifiableCollection(transformations.keySet());
+    }
+
+    public Transformation getTransformation(Id<Transformation> aId) {
+        return transformations.get(aId);
     }
 
     @Override