Breadcrumb
- Digital Connect Online Help
- Architecture
- Technical Aspects
Technical Aspects
Polymorphic Type Handling
Digital Connect messages definition (schema) uses polymorphic types, where an object of a generic type can be substituted with a concrete object of a more defined type. A derived type inherits all properties of the parent type.
Type of the object is declared in a property “@type”.
Examples
TravelPart - an abstract class consisting of: origin, destination, departure and arrival properties, which is extended by the concrete classes based on the declared "@type:"
- Itinerary;
- Itinerary Part;
- Segment.
@ApiModel(description="Parent class for all travel part data: Segment, ItineraryPart, Itinerary") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) @JsonIdentityInfo(generator = JSOGGenerator.class) @JsonSubTypes({ @JsonSubTypes.Type(value = Itinerary.class, name = "Itinerary"), @JsonSubTypes.Type(value = ItineraryPart.class, name = "ItineraryPart"), @JsonSubTypes.Type(value = Segment.class, name = "Segment") }) public class TravelPart { public enum TravelPartType { SEGMENT, ITINERARY_PART, ITINERARY; }
An example of the Segment object:
{ "@type": "Segment", "@id": "2", "segmentOfferInformation": { "flightsMiles": 0, "awardFare": false }, "duration": 95, "cabinClass": "Economy", "equipment": "32S", "flight": { "flightNumber": 1763, "airlineCode": "AZ", "operatingAirlineCode": "AZ", "stopAirports": [], "advisories": [] }, "origin": "LIN", "destination": "PMO", "departure": "2016-08-01T09:35:00", "arrival": "2016-08-01T11:10:00", "bookingClass": "Q", "layoverDuration": 0, "fareBasis": "QOWLGN1" }
An example of the ItineraryPart object:
{ "@type": "ItineraryPart", "@id": "37", "segments": [ { "@type": "Segment", "@id": "38", "segmentOfferInformation": { "flightsMiles": 0, "awardFare": false }, "duration": 75, "cabinClass": "Economy", "equipment": "E75", "aircraftLeaseText": "ALITALIA CITYLINER SPA", "flight": { "flightNumber": 1023, "airlineCode": "AZ", "operatingAirlineCode": "AZ", "stopAirports": [], "advisories": [] }, "origin": "MXP", "destination": "FCO", "departure": "2016-08-01T19:25:00", "arrival": "2016-08-01T20:40:00", "bookingClass": "L", "layoverDuration": 0, "fareBasis": "LOWLGN4" }, { "@type": "Segment", "@id": "39", "segmentOfferInformation": { "flightsMiles": 0, "awardFare": false }, "duration": 70, "cabinClass": "Economy", "equipment": "319", "flight": { "flightNumber": 1783, "airlineCode": "AZ", "operatingAirlineCode": "AZ", "stopAirports": [], "advisories": [] }, "origin": "FCO", "destination": "PMO", "departure": "2016-08-01T21:30:00", "arrival": "2016-08-01T22:40:00", "bookingClass": "L", "layoverDuration": 0, "fareBasis": "LOWLGN4" } ], "stops": 1, "totalDuration": 195, "connectionInformations": [ { "@id": "40", "duration": 50, "changeOfAirport": false } ], "bookingClass": "L", "advisories": [] }