All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hopper.cloud.airlines.model.CfarOfferPassenger Maven / Gradle / Ivy

The newest version!
/*
 * Airline API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v1.0
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.hopper.cloud.airlines.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.gson.*;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.hopper.cloud.airlines.JSON;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.IOException;
import java.util.Objects;

/**
 * An object detailing a passenger when creating offers
 */
@ApiModel(description = "An object detailing a passenger when creating offers")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CfarOfferPassenger {
    public static final String SERIALIZED_NAME_PASSENGER_REFERENCE = "passenger_reference";
    @SerializedName(SERIALIZED_NAME_PASSENGER_REFERENCE)
    private String passengerReference;

    public static final String SERIALIZED_NAME_PASSENGER_TYPE = "passenger_type";
    @SerializedName(SERIALIZED_NAME_PASSENGER_TYPE)
    private PassengerType passengerType;

    public CfarOfferPassenger() {
    }

    public CfarOfferPassenger passengerReference(String passengerReference) {
        this.passengerReference = passengerReference;
        return this;
    }

    @javax.annotation.Nonnull
    public String getPassengerReference() {
        return passengerReference;
    }

    public void setPassengerReference(String passengerReference) {
        this.passengerReference = passengerReference;
    }

    public CfarOfferPassenger passengerType(PassengerType passengerType) {
        this.passengerType = passengerType;
        return this;
    }

    /**
     * Get passenger type
     * @return type
     **/
    @javax.annotation.Nonnull
    @ApiModelProperty(required = true, value = "")
    public PassengerType getPassengerType() {
        return passengerType;
    }


    public void setPassengerType(PassengerType passengerType) {
        this.passengerType = passengerType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CfarOfferPassenger cfarOfferPassenger = (CfarOfferPassenger) o;
        return Objects.equals(this.passengerReference, cfarOfferPassenger.passengerReference) &&
                Objects.equals(this.passengerType, cfarOfferPassenger.passengerType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(passengerReference, passengerType);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class CfarOfferPassenger {\n");
        sb.append("    passengerReference: ").append(toIndentedString(passengerReference)).append("\n");
        sb.append("    passengerType: ").append(toIndentedString(passengerType)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }

    public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
        @SuppressWarnings("unchecked")
        @Override
        public  TypeAdapter create(Gson gson, TypeToken type) {
            if (!CfarOfferPassenger.class.isAssignableFrom(type.getRawType())) {
                return null; // this class only serializes 'CfarOfferPassenger' and its subtypes
            }
            final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
            final TypeAdapter thisAdapter
                    = gson.getDelegateAdapter(this, TypeToken.get(CfarOfferPassenger.class));

            return (TypeAdapter) new TypeAdapter() {
                @Override
                public void write(JsonWriter out, CfarOfferPassenger value) throws IOException {
                    JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
                    elementAdapter.write(out, obj);
                }

                @Override
                public CfarOfferPassenger read(JsonReader in) throws IOException {
                    JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
                    return thisAdapter.fromJsonTree(jsonObj);
                }

            }.nullSafe();
        }
    }

    /**
     * Create an instance of CfarOfferPassenger given an JSON string
     *
     * @param jsonString JSON string
     * @return An instance of CfarOfferPassenger
     * @throws IOException if the JSON string is invalid with respect to CfarOfferPassenger
     */
    public static CfarOfferPassenger fromJson(String jsonString) throws IOException {
        return JSON.getGson().fromJson(jsonString, CfarOfferPassenger.class);
    }

    /**
     * Convert an instance of CfarOfferPassenger to an JSON string
     *
     * @return JSON string
     */
    public String toJson() {
        return JSON.getGson().toJson(this);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy