
com.flexport.api.resources.carboncalculation.requests.CreateCarbonCalculation Maven / Gradle / Ivy
package com.flexport.api.resources.carboncalculation.requests;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.flexport.api.types.AddressForRequestBody;
import com.flexport.api.types.CoordinatesCreate;
import com.flexport.api.types.CreateCarbonCalculationFlightType;
import com.flexport.api.types.CreateCarbonCalculationTransportationMode;
import com.flexport.api.types.CreateCarbonCalculationTruckingServiceType;
import com.flexport.api.types.DistanceCreate;
import com.flexport.api.types.WeightCreate;
import java.util.Objects;
import java.util.Optional;
@JsonDeserialize(builder = CreateCarbonCalculation.Builder.class)
public final class CreateCarbonCalculation {
private final CreateCarbonCalculationTransportationMode transportationMode;
private final Optional weight;
private final Optional teus;
private final Optional distance;
private final Optional originCoordinates;
private final Optional originAddress;
private final Optional destinationCoordinates;
private final Optional destinationAddress;
private final Optional originPort;
private final Optional destinationPort;
private final Optional isInland;
private final Optional isLcl;
private final Optional isReefer;
private final Optional flightType;
private final Optional truckingServiceType;
private int _cachedHashCode;
CreateCarbonCalculation(
CreateCarbonCalculationTransportationMode transportationMode,
Optional weight,
Optional teus,
Optional distance,
Optional originCoordinates,
Optional originAddress,
Optional destinationCoordinates,
Optional destinationAddress,
Optional originPort,
Optional destinationPort,
Optional isInland,
Optional isLcl,
Optional isReefer,
Optional flightType,
Optional truckingServiceType) {
this.transportationMode = transportationMode;
this.weight = weight;
this.teus = teus;
this.distance = distance;
this.originCoordinates = originCoordinates;
this.originAddress = originAddress;
this.destinationCoordinates = destinationCoordinates;
this.destinationAddress = destinationAddress;
this.originPort = originPort;
this.destinationPort = destinationPort;
this.isInland = isInland;
this.isLcl = isLcl;
this.isReefer = isReefer;
this.flightType = flightType;
this.truckingServiceType = truckingServiceType;
}
/**
* @return The mode of transportation for calculation. One of air
, ocean
, truck
, or rail
. If transportation_mode
is truck
, ocean
, or rail
, country_code
in both origin_address
and destination_address
is required.
*/
@JsonProperty("transportation_mode")
public CreateCarbonCalculationTransportationMode getTransportationMode() {
return transportationMode;
}
@JsonProperty("weight")
public Optional getWeight() {
return weight;
}
/**
* @return The number of TEUs (Twenty-foot Equivalent Units) moved in the calculation. Either weight
or teus
is required.
*/
@JsonProperty("teus")
public Optional getTeus() {
return teus;
}
@JsonProperty("distance")
public Optional getDistance() {
return distance;
}
@JsonProperty("origin_coordinates")
public Optional getOriginCoordinates() {
return originCoordinates;
}
@JsonProperty("origin_address")
public Optional getOriginAddress() {
return originAddress;
}
@JsonProperty("destination_coordinates")
public Optional getDestinationCoordinates() {
return destinationCoordinates;
}
@JsonProperty("destination_address")
public Optional getDestinationAddress() {
return destinationAddress;
}
/**
* @return Port of origin, used if no more specific origin location is provided.
*/
@JsonProperty("origin_port")
public Optional getOriginPort() {
return originPort;
}
/**
* @return Port of destination, used if no more specific destination location is provided.
*/
@JsonProperty("destination_port")
public Optional getDestinationPort() {
return destinationPort;
}
/**
* @return For transportation_mode: ocean
, indicates if the calculation was inland or not. Defaults to false.
*/
@JsonProperty("is_inland")
public Optional getIsInland() {
return isInland;
}
/**
* @return For transportation_mode: ocean
, indicates if the calculation is less than container load or not. Defaults to false.
*/
@JsonProperty("is_lcl")
public Optional getIsLcl() {
return isLcl;
}
/**
* @return For transportation_mode: ocean
, indicates if the calculation is a reefer shipment. Defaults to false.
*/
@JsonProperty("is_reefer")
public Optional getIsReefer() {
return isReefer;
}
/**
* @return For transportation_mode: air
, the type of plane used. One of freighter
, belly_freighter
, or unknown
. Defaults to unknown
.
*/
@JsonProperty("flight_type")
public Optional getFlightType() {
return flightType;
}
/**
* @return For transportation_mode: truck
, the type of service used. One of ftl
, ltl
, drayage
, cartage
, last_mile
, airport_transfer
, or air_cartage
.
*/
@JsonProperty("trucking_service_type")
public Optional getTruckingServiceType() {
return truckingServiceType;
}
@Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof CreateCarbonCalculation && equalTo((CreateCarbonCalculation) other);
}
private boolean equalTo(CreateCarbonCalculation other) {
return transportationMode.equals(other.transportationMode)
&& weight.equals(other.weight)
&& teus.equals(other.teus)
&& distance.equals(other.distance)
&& originCoordinates.equals(other.originCoordinates)
&& originAddress.equals(other.originAddress)
&& destinationCoordinates.equals(other.destinationCoordinates)
&& destinationAddress.equals(other.destinationAddress)
&& originPort.equals(other.originPort)
&& destinationPort.equals(other.destinationPort)
&& isInland.equals(other.isInland)
&& isLcl.equals(other.isLcl)
&& isReefer.equals(other.isReefer)
&& flightType.equals(other.flightType)
&& truckingServiceType.equals(other.truckingServiceType);
}
@Override
public int hashCode() {
if (_cachedHashCode == 0) {
_cachedHashCode = Objects.hash(
this.transportationMode,
this.weight,
this.teus,
this.distance,
this.originCoordinates,
this.originAddress,
this.destinationCoordinates,
this.destinationAddress,
this.originPort,
this.destinationPort,
this.isInland,
this.isLcl,
this.isReefer,
this.flightType,
this.truckingServiceType);
}
return _cachedHashCode;
}
@Override
public String toString() {
return "CreateCarbonCalculation{" + "transportationMode: " + transportationMode + ", weight: " + weight
+ ", teus: " + teus + ", distance: " + distance + ", originCoordinates: " + originCoordinates
+ ", originAddress: " + originAddress + ", destinationCoordinates: " + destinationCoordinates
+ ", destinationAddress: " + destinationAddress + ", originPort: " + originPort + ", destinationPort: "
+ destinationPort + ", isInland: " + isInland + ", isLcl: " + isLcl + ", isReefer: " + isReefer
+ ", flightType: " + flightType + ", truckingServiceType: " + truckingServiceType + "}";
}
public static TransportationModeStage builder() {
return new Builder();
}
public interface TransportationModeStage {
_FinalStage transportationMode(CreateCarbonCalculationTransportationMode transportationMode);
Builder from(CreateCarbonCalculation other);
}
public interface _FinalStage {
CreateCarbonCalculation build();
_FinalStage weight(Optional weight);
_FinalStage weight(WeightCreate weight);
_FinalStage teus(Optional teus);
_FinalStage teus(String teus);
_FinalStage distance(Optional distance);
_FinalStage distance(DistanceCreate distance);
_FinalStage originCoordinates(Optional originCoordinates);
_FinalStage originCoordinates(CoordinatesCreate originCoordinates);
_FinalStage originAddress(Optional originAddress);
_FinalStage originAddress(AddressForRequestBody originAddress);
_FinalStage destinationCoordinates(Optional destinationCoordinates);
_FinalStage destinationCoordinates(CoordinatesCreate destinationCoordinates);
_FinalStage destinationAddress(Optional destinationAddress);
_FinalStage destinationAddress(AddressForRequestBody destinationAddress);
_FinalStage originPort(Optional originPort);
_FinalStage originPort(String originPort);
_FinalStage destinationPort(Optional destinationPort);
_FinalStage destinationPort(String destinationPort);
_FinalStage isInland(Optional isInland);
_FinalStage isInland(Boolean isInland);
_FinalStage isLcl(Optional isLcl);
_FinalStage isLcl(Boolean isLcl);
_FinalStage isReefer(Optional isReefer);
_FinalStage isReefer(Boolean isReefer);
_FinalStage flightType(Optional flightType);
_FinalStage flightType(CreateCarbonCalculationFlightType flightType);
_FinalStage truckingServiceType(Optional truckingServiceType);
_FinalStage truckingServiceType(CreateCarbonCalculationTruckingServiceType truckingServiceType);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder implements TransportationModeStage, _FinalStage {
private CreateCarbonCalculationTransportationMode transportationMode;
private Optional truckingServiceType = Optional.empty();
private Optional flightType = Optional.empty();
private Optional isReefer = Optional.empty();
private Optional isLcl = Optional.empty();
private Optional isInland = Optional.empty();
private Optional destinationPort = Optional.empty();
private Optional originPort = Optional.empty();
private Optional destinationAddress = Optional.empty();
private Optional destinationCoordinates = Optional.empty();
private Optional originAddress = Optional.empty();
private Optional originCoordinates = Optional.empty();
private Optional distance = Optional.empty();
private Optional teus = Optional.empty();
private Optional weight = Optional.empty();
private Builder() {}
@Override
public Builder from(CreateCarbonCalculation other) {
transportationMode(other.getTransportationMode());
weight(other.getWeight());
teus(other.getTeus());
distance(other.getDistance());
originCoordinates(other.getOriginCoordinates());
originAddress(other.getOriginAddress());
destinationCoordinates(other.getDestinationCoordinates());
destinationAddress(other.getDestinationAddress());
originPort(other.getOriginPort());
destinationPort(other.getDestinationPort());
isInland(other.getIsInland());
isLcl(other.getIsLcl());
isReefer(other.getIsReefer());
flightType(other.getFlightType());
truckingServiceType(other.getTruckingServiceType());
return this;
}
/**
* The mode of transportation for calculation. One of air
, ocean
, truck
, or rail
. If transportation_mode
is truck
, ocean
, or rail
, country_code
in both origin_address
and destination_address
is required.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
@JsonSetter("transportation_mode")
public _FinalStage transportationMode(CreateCarbonCalculationTransportationMode transportationMode) {
this.transportationMode = transportationMode;
return this;
}
/**
* For transportation_mode: truck
, the type of service used. One of ftl
, ltl
, drayage
, cartage
, last_mile
, airport_transfer
, or air_cartage
.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
public _FinalStage truckingServiceType(CreateCarbonCalculationTruckingServiceType truckingServiceType) {
this.truckingServiceType = Optional.of(truckingServiceType);
return this;
}
@Override
@JsonSetter(value = "trucking_service_type", nulls = Nulls.SKIP)
public _FinalStage truckingServiceType(
Optional truckingServiceType) {
this.truckingServiceType = truckingServiceType;
return this;
}
/**
* For transportation_mode: air
, the type of plane used. One of freighter
, belly_freighter
, or unknown
. Defaults to unknown
.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
public _FinalStage flightType(CreateCarbonCalculationFlightType flightType) {
this.flightType = Optional.of(flightType);
return this;
}
@Override
@JsonSetter(value = "flight_type", nulls = Nulls.SKIP)
public _FinalStage flightType(Optional flightType) {
this.flightType = flightType;
return this;
}
/**
* For transportation_mode: ocean
, indicates if the calculation is a reefer shipment. Defaults to false.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
public _FinalStage isReefer(Boolean isReefer) {
this.isReefer = Optional.of(isReefer);
return this;
}
@Override
@JsonSetter(value = "is_reefer", nulls = Nulls.SKIP)
public _FinalStage isReefer(Optional isReefer) {
this.isReefer = isReefer;
return this;
}
/**
* For transportation_mode: ocean
, indicates if the calculation is less than container load or not. Defaults to false.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
public _FinalStage isLcl(Boolean isLcl) {
this.isLcl = Optional.of(isLcl);
return this;
}
@Override
@JsonSetter(value = "is_lcl", nulls = Nulls.SKIP)
public _FinalStage isLcl(Optional isLcl) {
this.isLcl = isLcl;
return this;
}
/**
* For transportation_mode: ocean
, indicates if the calculation was inland or not. Defaults to false.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
public _FinalStage isInland(Boolean isInland) {
this.isInland = Optional.of(isInland);
return this;
}
@Override
@JsonSetter(value = "is_inland", nulls = Nulls.SKIP)
public _FinalStage isInland(Optional isInland) {
this.isInland = isInland;
return this;
}
/**
* Port of destination, used if no more specific destination location is provided.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
public _FinalStage destinationPort(String destinationPort) {
this.destinationPort = Optional.of(destinationPort);
return this;
}
@Override
@JsonSetter(value = "destination_port", nulls = Nulls.SKIP)
public _FinalStage destinationPort(Optional destinationPort) {
this.destinationPort = destinationPort;
return this;
}
/**
* Port of origin, used if no more specific origin location is provided.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
public _FinalStage originPort(String originPort) {
this.originPort = Optional.of(originPort);
return this;
}
@Override
@JsonSetter(value = "origin_port", nulls = Nulls.SKIP)
public _FinalStage originPort(Optional originPort) {
this.originPort = originPort;
return this;
}
@Override
public _FinalStage destinationAddress(AddressForRequestBody destinationAddress) {
this.destinationAddress = Optional.of(destinationAddress);
return this;
}
@Override
@JsonSetter(value = "destination_address", nulls = Nulls.SKIP)
public _FinalStage destinationAddress(Optional destinationAddress) {
this.destinationAddress = destinationAddress;
return this;
}
@Override
public _FinalStage destinationCoordinates(CoordinatesCreate destinationCoordinates) {
this.destinationCoordinates = Optional.of(destinationCoordinates);
return this;
}
@Override
@JsonSetter(value = "destination_coordinates", nulls = Nulls.SKIP)
public _FinalStage destinationCoordinates(Optional destinationCoordinates) {
this.destinationCoordinates = destinationCoordinates;
return this;
}
@Override
public _FinalStage originAddress(AddressForRequestBody originAddress) {
this.originAddress = Optional.of(originAddress);
return this;
}
@Override
@JsonSetter(value = "origin_address", nulls = Nulls.SKIP)
public _FinalStage originAddress(Optional originAddress) {
this.originAddress = originAddress;
return this;
}
@Override
public _FinalStage originCoordinates(CoordinatesCreate originCoordinates) {
this.originCoordinates = Optional.of(originCoordinates);
return this;
}
@Override
@JsonSetter(value = "origin_coordinates", nulls = Nulls.SKIP)
public _FinalStage originCoordinates(Optional originCoordinates) {
this.originCoordinates = originCoordinates;
return this;
}
@Override
public _FinalStage distance(DistanceCreate distance) {
this.distance = Optional.of(distance);
return this;
}
@Override
@JsonSetter(value = "distance", nulls = Nulls.SKIP)
public _FinalStage distance(Optional distance) {
this.distance = distance;
return this;
}
/**
* The number of TEUs (Twenty-foot Equivalent Units) moved in the calculation. Either weight
or teus
is required.
* @return Reference to {@code this} so that method calls can be chained together.
*/
@Override
public _FinalStage teus(String teus) {
this.teus = Optional.of(teus);
return this;
}
@Override
@JsonSetter(value = "teus", nulls = Nulls.SKIP)
public _FinalStage teus(Optional teus) {
this.teus = teus;
return this;
}
@Override
public _FinalStage weight(WeightCreate weight) {
this.weight = Optional.of(weight);
return this;
}
@Override
@JsonSetter(value = "weight", nulls = Nulls.SKIP)
public _FinalStage weight(Optional weight) {
this.weight = weight;
return this;
}
@Override
public CreateCarbonCalculation build() {
return new CreateCarbonCalculation(
transportationMode,
weight,
teus,
distance,
originCoordinates,
originAddress,
destinationCoordinates,
destinationAddress,
originPort,
destinationPort,
isInland,
isLcl,
isReefer,
flightType,
truckingServiceType);
}
}
}