Przeglądaj źródła

Added a firstLeg() method

peter_backlund 17 lat temu
rodzic
commit
69947e03ec

+ 11
- 0
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Itinerary.java Wyświetl plik

@@ -133,6 +133,17 @@ public class Itinerary implements ValueObject<Itinerary> {
133 133
   }
134 134
 
135 135
   /**
136
+   * @return The first leg on the itinerary.
137
+   */
138
+  Leg firstLeg() {
139
+    if (legs.isEmpty()) {
140
+      return null;
141
+    } else {
142
+      return legs.get(0);
143
+    }
144
+  }
145
+
146
+  /**
136 147
    * @param other itinerary to compare
137 148
    * @return <code>true</code> if the legs in this and the other itinerary are all equal.
138 149
    */