Просмотр исходного кода

Removed unused methods on inmem cargo repository

peter_backlund 17 лет назад
Родитель
Сommit
3c0e3aed43

+ 10
- 41
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/inmemory/CargoRepositoryInMem.java Просмотреть файл

@@ -2,13 +2,13 @@ package se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory;
2 2
 
3 3
 import se.citerus.dddsample.tracking.core.domain.model.cargo.Cargo;
4 4
 import se.citerus.dddsample.tracking.core.domain.model.cargo.CargoRepository;
5
-import se.citerus.dddsample.tracking.core.domain.model.cargo.RouteSpecification;
6 5
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
7
-import se.citerus.dddsample.tracking.core.domain.model.location.Location;
8
-import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
9 6
 import se.citerus.dddsample.tracking.core.domain.model.voyage.Voyage;
10 7
 
11
-import java.util.*;
8
+import java.util.ArrayList;
9
+import java.util.HashMap;
10
+import java.util.List;
11
+import java.util.Map;
12 12
 
13 13
 /**
14 14
  * CargoRepositoryInMem implement the CargoRepository interface but is a test
@@ -20,33 +20,28 @@ import java.util.*;
20 20
  */
21 21
 public class CargoRepositoryInMem implements CargoRepository {
22 22
 
23
-  private Map<String, Cargo> cargoDb;
24
-
25
-  /**
26
-   * Constructor.
27
-   */
28
-  public CargoRepositoryInMem() {
29
-    cargoDb = new HashMap<String, Cargo>();
30
-  }
23
+  private final Map<TrackingId, Cargo> cargoDb = new HashMap<TrackingId, Cargo>();
31 24
 
25
+  @Override
32 26
   public Cargo find(final TrackingId trackingId) {
33
-    return cargoDb.get(trackingId.stringValue());
27
+    return cargoDb.get(trackingId);
34 28
   }
35 29
 
36 30
   @Override
37 31
   public List<Cargo> findCargosOnVoyage(Voyage voyage) {
38
-    List<Cargo> onVoyage = new ArrayList<Cargo>();
32
+    final List<Cargo> onVoyage = new ArrayList<Cargo>();
39 33
     for (Cargo cargo : cargoDb.values()) {
40 34
       if (voyage.sameAs(cargo.currentVoyage())) {
41 35
         onVoyage.add(cargo);
42 36
       }
43 37
     }
38
+
44 39
     return onVoyage;
45 40
   }
46 41
 
47 42
   @Override
48 43
   public void store(Cargo cargo) {
49
-    cargoDb.put(cargo.trackingId().stringValue(), cargo);
44
+    cargoDb.put(cargo.trackingId(), cargo);
50 45
   }
51 46
 
52 47
   @Override
@@ -54,31 +49,5 @@ public class CargoRepositoryInMem implements CargoRepository {
54 49
     return new ArrayList<Cargo>(cargoDb.values());
55 50
   }
56 51
 
57
-  public void init() throws Exception {
58
-    final TrackingId xyz = new TrackingId("XYZ");
59
-    final Cargo cargoXYZ = createCargoWithDeliveryHistory(xyz, STOCKHOLM, MELBOURNE);
60
-    cargoDb.put(xyz.stringValue(), cargoXYZ);
61
-
62
-    final TrackingId zyx = new TrackingId("ZYX");
63
-    final Cargo cargoZYX = createCargoWithDeliveryHistory(zyx, MELBOURNE, STOCKHOLM);
64
-    cargoDb.put(zyx.stringValue(), cargoZYX);
65
-
66
-    final TrackingId abc = new TrackingId("ABC");
67
-    final Cargo cargoABC = createCargoWithDeliveryHistory(abc, STOCKHOLM, HELSINKI);
68
-    cargoDb.put(abc.stringValue(), cargoABC);
69 52
 
70
-    final TrackingId cba = new TrackingId("CBA");
71
-    final Cargo cargoCBA = createCargoWithDeliveryHistory(cba, HELSINKI, STOCKHOLM);
72
-    cargoDb.put(cba.stringValue(), cargoCBA);
73
-  }
74
-
75
-  public static Cargo createCargoWithDeliveryHistory(TrackingId trackingId,
76
-                                                     Location origin,
77
-                                                     Location destination) {
78
-
79
-    final RouteSpecification routeSpecification = new RouteSpecification(origin, destination, new Date());
80
-    final Cargo cargo = new Cargo(trackingId, routeSpecification);
81
-
82
-    return cargo;
83
-  }
84 53
 }