|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object se.citerus.dddsample.domain.model.cargo.Cargo
public class Cargo
A Cargo. This is the central class in the domain model, and it is the root of the Cargo-Itinerary-Leg-Delivery-RouteSpecification aggregate. A cargo is identified by a unique tracking id, and it always has an origin and a route specification. The life cycle of a cargo begins with the booking procedure, when the tracking id is assigned. During a (short) period of time, between booking and initial routing, the cargo has no itinerary. The booking clerk requests a list of possible routes, matching the route specification, and assigns the cargo to one route. The route to which a cargo is assigned is described by an itinerary. A cargo can be re-routed during transport, on demand of the customer, in which case a new route is specified for the cargo and a new route is requested. The old itinerary, being a value object, is discarded and a new one is attached. It may also happen that a cargo is accidentally misrouted, which should notify the proper personnel and also trigger a re-routing procedure. When a cargo is handled, the status of the delivery changes. Everything about the delivery of the cargo is contained in the Delivery value object, which is replaced whenever a cargo is handled by an asynchronous event triggered by the registration of the handling event. The delivery can also be affected by routing changes, i.e. when a the route specification changes, or the cargo is assigned to a new route. In that case, the delivery update is performed synchronously within the cargo aggregate. The life cycle of a cargo ends when the cargo is claimed by the customer. The cargo aggregate, and the entre domain model, is built to solve the problem of booking and tracking cargo. All important business rules for determining whether or not a cargo is misdirected, what the current status of the cargo is (on board carrier, in port etc), are captured in this aggregate.
Constructor Summary | |
---|---|
Cargo(TrackingId trackingId,
RouteSpecification routeSpecification)
|
Method Summary | |
---|---|
void |
assignToRoute(Itinerary itinerary)
Attach a new itinerary to this cargo. |
Delivery |
delivery()
|
void |
deriveDeliveryProgress(HandlingHistory handlingHistory)
Updates all aspects of the cargo aggregate status based on the current route specification, itinerary and handling of the cargo. |
boolean |
equals(java.lang.Object object)
|
int |
hashCode()
|
Itinerary |
itinerary()
|
Location |
origin()
|
RouteSpecification |
routeSpecification()
|
boolean |
sameIdentityAs(Cargo other)
Entities compare by identity, not by attributes. |
void |
specifyNewRoute(RouteSpecification routeSpecification)
Specifies a new route for this cargo. |
java.lang.String |
toString()
|
TrackingId |
trackingId()
The tracking id is the identity of this entity, and is unique. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Cargo(TrackingId trackingId, RouteSpecification routeSpecification)
Method Detail |
---|
public TrackingId trackingId()
public Location origin()
public Delivery delivery()
public Itinerary itinerary()
public RouteSpecification routeSpecification()
public void specifyNewRoute(RouteSpecification routeSpecification)
routeSpecification
- route specification.public void assignToRoute(Itinerary itinerary)
itinerary
- an itinerary. May not be null.public void deriveDeliveryProgress(HandlingHistory handlingHistory)
RouteSpecification
and Itinerary
are both inside the Cargo
aggregate, so changes to them cause the status to be updated synchronously,
but changes to the delivery history (when a cargo is handled) cause the status update
to happen asynchronously since HandlingEvent
is in a different aggregate.
handlingHistory
- handling historypublic boolean sameIdentityAs(Cargo other)
Entity
sameIdentityAs
in interface Entity<Cargo>
other
- The other entity.
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- to compare
sameIdentityAs(Cargo)
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |