|
| 1 | +package com.hopper.cloud.airlines.model; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonInclude; |
| 4 | +import com.google.gson.*; |
| 5 | +import com.google.gson.annotations.SerializedName; |
| 6 | +import com.google.gson.reflect.TypeToken; |
| 7 | +import com.google.gson.stream.JsonReader; |
| 8 | +import com.google.gson.stream.JsonWriter; |
| 9 | +import com.hopper.cloud.airlines.JSON; |
| 10 | +import io.swagger.annotations.ApiModel; |
| 11 | +import io.swagger.annotations.ApiModelProperty; |
| 12 | + |
| 13 | +import java.io.IOException; |
| 14 | +import java.util.ArrayList; |
| 15 | +import java.util.List; |
| 16 | +import java.util.Objects; |
| 17 | + |
| 18 | +@JsonInclude(JsonInclude.Include.NON_NULL) |
| 19 | +public class CfarItineraryPricing { |
| 20 | + public static final String SERIALIZED_NAME_PASSENGER_PRICING = "passenger_pricing"; |
| 21 | + @SerializedName(SERIALIZED_NAME_PASSENGER_PRICING) |
| 22 | + private List<PassengerPricing> passengerPricing = new ArrayList<>(); |
| 23 | + |
| 24 | + public static final String SERIALIZED_NAME_ANCILLARIES = "ancillaries"; |
| 25 | + @SerializedName(SERIALIZED_NAME_ANCILLARIES) |
| 26 | + private List<Ancillary> ancillaries = null; |
| 27 | + |
| 28 | + public static final String SERIALIZED_NAME_PASSENGERS = "passengers"; |
| 29 | + @SerializedName(SERIALIZED_NAME_PASSENGERS) |
| 30 | + private List<CfarPassenger> passengers = null; |
| 31 | + |
| 32 | + public CfarItineraryPricing() { |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * List of pricing per passenger for a fare |
| 37 | + * |
| 38 | + * @return passengerPricing |
| 39 | + **/ |
| 40 | + @javax.annotation.Nonnull |
| 41 | + @ApiModelProperty(required = true, value = "List of pricing per passenger for a fare") |
| 42 | + |
| 43 | + public List<PassengerPricing> getPassengerPricing() { |
| 44 | + return passengerPricing; |
| 45 | + } |
| 46 | + |
| 47 | + |
| 48 | + public void setPassengerPricing(List<PassengerPricing> passengerPricing) { |
| 49 | + this.passengerPricing = passengerPricing; |
| 50 | + } |
| 51 | + |
| 52 | + public CfarItineraryPricing passengerPricing(List<PassengerPricing> passengerPricing) { |
| 53 | + |
| 54 | + this.passengerPricing = passengerPricing; |
| 55 | + return this; |
| 56 | + } |
| 57 | + |
| 58 | + public CfarItineraryPricing addPassengerPricingItem(PassengerPricing passengerPricingItem) { |
| 59 | + this.passengerPricing.add(passengerPricingItem); |
| 60 | + return this; |
| 61 | + } |
| 62 | + |
| 63 | + |
| 64 | + /** |
| 65 | + * Ancillaries attached to a fare and their prices |
| 66 | + * |
| 67 | + * @return ancillaries |
| 68 | + **/ |
| 69 | + @javax.annotation.Nullable |
| 70 | + @ApiModelProperty(value = "Ancillaries attached to a fare and their prices") |
| 71 | + public List<Ancillary> getAncillaries() { |
| 72 | + return ancillaries; |
| 73 | + } |
| 74 | + |
| 75 | + public void setAncillaries(List<Ancillary> ancillaries) { |
| 76 | + this.ancillaries = ancillaries; |
| 77 | + } |
| 78 | + |
| 79 | + public CfarItineraryPricing ancillaries(List<Ancillary> ancillaries) { |
| 80 | + |
| 81 | + this.ancillaries = ancillaries; |
| 82 | + return this; |
| 83 | + } |
| 84 | + |
| 85 | + public CfarItineraryPricing addAncillariesItem(Ancillary ancillariesItem) { |
| 86 | + if (this.ancillaries == null) { |
| 87 | + this.ancillaries = new ArrayList<>(); |
| 88 | + } |
| 89 | + this.ancillaries.add(ancillariesItem); |
| 90 | + return this; |
| 91 | + } |
| 92 | + |
| 93 | + public CfarItineraryPricing passengers(List<CfarPassenger> passengers) { |
| 94 | + this.passengers = passengers; |
| 95 | + return this; |
| 96 | + } |
| 97 | + |
| 98 | + public CfarItineraryPricing addPassengersItem(CfarPassenger passengerItem) { |
| 99 | + if (this.passengers == null) { |
| 100 | + this.passengers = new ArrayList<>(); |
| 101 | + } |
| 102 | + this.passengers.add(passengerItem); |
| 103 | + return this; |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Retrieve Passengers |
| 108 | + * @return passengers |
| 109 | + **/ |
| 110 | + @javax.annotation.Nullable |
| 111 | + @ApiModelProperty(value = "Passengers associated with the itinerary") |
| 112 | + |
| 113 | + public List<CfarPassenger> getPassengers() { |
| 114 | + return passengers; |
| 115 | + } |
| 116 | + |
| 117 | + public void setPassengers(List<CfarPassenger> passengers) { |
| 118 | + this.passengers = passengers; |
| 119 | + } |
| 120 | + |
| 121 | + |
| 122 | + @Override |
| 123 | + public boolean equals(Object o) { |
| 124 | + if (this == o) { |
| 125 | + return true; |
| 126 | + } |
| 127 | + if (o == null || getClass() != o.getClass()) { |
| 128 | + return false; |
| 129 | + } |
| 130 | + CfarItineraryPricing cfarItineraryPricing = (CfarItineraryPricing) o; |
| 131 | + return Objects.equals(this.passengerPricing, cfarItineraryPricing.passengerPricing) && |
| 132 | + Objects.equals(this.passengers, cfarItineraryPricing.passengers) && |
| 133 | + Objects.equals(this.ancillaries, cfarItineraryPricing.ancillaries); |
| 134 | + } |
| 135 | + |
| 136 | + @Override |
| 137 | + public int hashCode() { |
| 138 | + return Objects.hash(passengerPricing, passengers, ancillaries); |
| 139 | + } |
| 140 | + |
| 141 | + @Override |
| 142 | + public String toString() { |
| 143 | + StringBuilder sb = new StringBuilder(); |
| 144 | + sb.append("class CfarItineraryPricing {\n"); |
| 145 | + sb.append(" passengerPricing: ").append(toIndentedString(passengerPricing)).append("\n"); |
| 146 | + sb.append(" passengers: ").append(toIndentedString(passengers)).append("\n"); |
| 147 | + sb.append(" ancillaries: ").append(toIndentedString(ancillaries)).append("\n"); |
| 148 | + sb.append("}"); |
| 149 | + return sb.toString(); |
| 150 | + } |
| 151 | + |
| 152 | + /** |
| 153 | + * Convert the given object to string with each line indented by 4 spaces |
| 154 | + * (except the first line). |
| 155 | + */ |
| 156 | + private String toIndentedString(Object o) { |
| 157 | + if (o == null) { |
| 158 | + return "null"; |
| 159 | + } |
| 160 | + return o.toString().replace("\n", "\n "); |
| 161 | + } |
| 162 | + |
| 163 | + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { |
| 164 | + @SuppressWarnings("unchecked") |
| 165 | + @Override |
| 166 | + public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { |
| 167 | + if (!CfarItineraryPricing.class.isAssignableFrom(type.getRawType())) { |
| 168 | + return null; // this class only serializes 'CfarItineraryPricing' and its subtypes |
| 169 | + } |
| 170 | + final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); |
| 171 | + final TypeAdapter<CfarItineraryPricing> thisAdapter |
| 172 | + = gson.getDelegateAdapter(this, TypeToken.get(CfarItineraryPricing.class)); |
| 173 | + |
| 174 | + return (TypeAdapter<T>) new TypeAdapter<CfarItineraryPricing>() { |
| 175 | + @Override |
| 176 | + public void write(JsonWriter out, CfarItineraryPricing value) throws IOException { |
| 177 | + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); |
| 178 | + elementAdapter.write(out, obj); |
| 179 | + } |
| 180 | + |
| 181 | + @Override |
| 182 | + public CfarItineraryPricing read(JsonReader in) throws IOException { |
| 183 | + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); |
| 184 | + return thisAdapter.fromJsonTree(jsonObj); |
| 185 | + } |
| 186 | + |
| 187 | + }.nullSafe(); |
| 188 | + } |
| 189 | + } |
| 190 | + |
| 191 | + /** |
| 192 | + * Create an instance of CfarItineraryPricing given an JSON string |
| 193 | + * |
| 194 | + * @param jsonString JSON string |
| 195 | + * @return An instance of CfarItineraryPricing |
| 196 | + * @throws IOException if the JSON string is invalid with respect to CfarItineraryPricing |
| 197 | + */ |
| 198 | + public static CfarItineraryPricing fromJson(String jsonString) throws IOException { |
| 199 | + return JSON.getGson().fromJson(jsonString, CfarItineraryPricing.class); |
| 200 | + } |
| 201 | + |
| 202 | + /** |
| 203 | + * Convert an instance of CfarItineraryPricing to an JSON string |
| 204 | + * |
| 205 | + * @return JSON string |
| 206 | + */ |
| 207 | + public String toJson() { |
| 208 | + return JSON.getGson().toJson(this); |
| 209 | + } |
| 210 | +} |
| 211 | + |
0 commit comments