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

odata.test.trip.pin.entity.Flight Maven / Gradle / Ivy

There is a newer version: 0.1.13
Show newest version
package odata.test.trip.pin.entity;

import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.github.davidmoten.odata.client.ODataEntityType;
import com.github.davidmoten.odata.client.RequestOptions;
import com.github.davidmoten.odata.client.Util;
import com.github.davidmoten.odata.client.internal.ChangedFields;
import com.github.davidmoten.odata.client.internal.RequestHelper;
import com.github.davidmoten.odata.client.internal.UnmappedFields;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.Optional;
import odata.test.trip.pin.entity.PublicTransportation;
import odata.test.trip.pin.entity.request.AirlineRequest;
import odata.test.trip.pin.entity.request.AirportRequest;
import odata.test.trip.pin.schema.SchemaInfo;

@JsonInclude(Include.NON_NULL)
@JsonPropertyOrder({
    "@odata.type", 
    "FlightNumber"})
public class Flight extends PublicTransportation implements ODataEntityType {

    @JsonProperty("FlightNumber")
    protected String flightNumber;

    protected Flight() {
        super();
    }

    public static Builder builderFlight() {
        return new Builder();
    }

    public static final class Builder {
        private Integer planItemId;
        private String confirmationCode;
        private OffsetDateTime startsAt;
        private OffsetDateTime endsAt;
        private Duration duration;
        private String seatNumber;
        private String flightNumber;
        private ChangedFields changedFields = ChangedFields.EMPTY;

        Builder() {
            // prevent instantiation
        }

        public Builder planItemId(Integer planItemId) {
            this.planItemId = planItemId;
            this.changedFields = changedFields.add("PlanItemId");
            return this;
        }

        public Builder confirmationCode(String confirmationCode) {
            this.confirmationCode = confirmationCode;
            this.changedFields = changedFields.add("ConfirmationCode");
            return this;
        }

        public Builder startsAt(OffsetDateTime startsAt) {
            this.startsAt = startsAt;
            this.changedFields = changedFields.add("StartsAt");
            return this;
        }

        public Builder endsAt(OffsetDateTime endsAt) {
            this.endsAt = endsAt;
            this.changedFields = changedFields.add("EndsAt");
            return this;
        }

        public Builder duration(Duration duration) {
            this.duration = duration;
            this.changedFields = changedFields.add("Duration");
            return this;
        }

        public Builder seatNumber(String seatNumber) {
            this.seatNumber = seatNumber;
            this.changedFields = changedFields.add("SeatNumber");
            return this;
        }

        public Builder flightNumber(String flightNumber) {
            this.flightNumber = flightNumber;
            this.changedFields = changedFields.add("FlightNumber");
            return this;
        }

        public Flight build() {
            Flight _x = new Flight();
            _x.contextPath = null;
            _x.changedFields = changedFields;
            _x.unmappedFields = UnmappedFields.EMPTY;
            _x.odataType = "Microsoft.OData.SampleService.Models.TripPin.Flight";
            _x.planItemId = planItemId;
            _x.confirmationCode = confirmationCode;
            _x.startsAt = startsAt;
            _x.endsAt = endsAt;
            _x.duration = duration;
            _x.seatNumber = seatNumber;
            _x.flightNumber = flightNumber;
            return _x;
        }
    }

    public ChangedFields getChangedFields() {
        return changedFields;
    }

    public Optional getFlightNumber() {
        return Optional.ofNullable(flightNumber);
    }

    public Flight withFlightNumber(String flightNumber) {
        Flight _x = _copy();
        _x.changedFields = changedFields.add("FlightNumber");
        _x.odataType = Util.nvl(odataType, "Microsoft.OData.SampleService.Models.TripPin.Flight");
        _x.flightNumber = flightNumber;
        return _x;
    }

    public AirportRequest getFrom() {
        return new AirportRequest(contextPath.addSegment("From"));
    }

    public AirportRequest getTo() {
        return new AirportRequest(contextPath.addSegment("To"));
    }

    public AirlineRequest getAirline() {
        return new AirlineRequest(contextPath.addSegment("Airline"));
    }

    @JsonAnySetter
    private void setUnmappedField(String name, Object value) {
        if (unmappedFields == null) {
            unmappedFields = new UnmappedFields();
        }
        unmappedFields.put(name, value);
    }

    @Override
    public UnmappedFields getUnmappedFields() {
        return unmappedFields == null ? UnmappedFields.EMPTY : unmappedFields;
    }

    public Flight patch() {
        RequestHelper.patch(this, contextPath, RequestOptions.EMPTY,  SchemaInfo.INSTANCE);
        Flight _x = _copy();
        _x.changedFields = null;
        return _x;
    }

    public Flight put() {
        RequestHelper.put(this, contextPath, RequestOptions.EMPTY,  SchemaInfo.INSTANCE);
        Flight _x = _copy();
        _x.changedFields = null;
        return _x;
    }
    private Flight _copy() {
        Flight _x = new Flight();
        _x.contextPath = contextPath;
        _x.changedFields = changedFields;
        _x.unmappedFields = unmappedFields;
        _x.odataType = odataType;
        _x.planItemId = planItemId;
        _x.confirmationCode = confirmationCode;
        _x.startsAt = startsAt;
        _x.endsAt = endsAt;
        _x.duration = duration;
        _x.seatNumber = seatNumber;
        _x.flightNumber = flightNumber;
        return _x;
    }

    @Override
    public String toString() {
        StringBuilder b = new StringBuilder();
        b.append("Flight[");
        b.append("PlanItemId=");
        b.append(this.planItemId);
        b.append(", ");
        b.append("ConfirmationCode=");
        b.append(this.confirmationCode);
        b.append(", ");
        b.append("StartsAt=");
        b.append(this.startsAt);
        b.append(", ");
        b.append("EndsAt=");
        b.append(this.endsAt);
        b.append(", ");
        b.append("Duration=");
        b.append(this.duration);
        b.append(", ");
        b.append("SeatNumber=");
        b.append(this.seatNumber);
        b.append(", ");
        b.append("FlightNumber=");
        b.append(this.flightNumber);
        b.append("]");
        b.append(",unmappedFields=");
        b.append(unmappedFields);
        b.append(",odataType=");
        b.append(odataType);
        return b.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy