org.entur.gbfs.mapper.VehicleStatusAdditionalMapperImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gbfs-mapper-java Show documentation
Show all versions of gbfs-mapper-java Show documentation
Enables mapping between different versions of GBFS (bidirectional)
package org.entur.gbfs.mapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.processing.Generated;
import org.mapstruct.factory.Mappers;
import org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSBike;
import org.mobilitydata.gbfs.v2_3.free_bike_status.VehicleEquipment;
import org.mobilitydata.gbfs.v3_0.vehicle_status.GBFSData;
import org.mobilitydata.gbfs.v3_0.vehicle_status.GBFSRentalUris;
import org.mobilitydata.gbfs.v3_0.vehicle_status.GBFSVehicle;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-08-26T04:58:57+0000",
comments = "version: 1.6.0, compiler: javac, environment: Java 17.0.11 (Eclipse Adoptium)"
)
public class VehicleStatusAdditionalMapperImpl extends VehicleStatusAdditionalMapper {
private final DateMapper dateMapper = Mappers.getMapper( DateMapper.class );
@Override
org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSData mapData(GBFSData source) {
if ( source == null ) {
return null;
}
org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSData gBFSData = new org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSData();
gBFSData.setBikes( gBFSVehicleListToGBFSBikeList( source.getVehicles() ) );
if ( gBFSData.getAdditionalProperties() != null ) {
Map map = source.getAdditionalProperties();
if ( map != null ) {
gBFSData.getAdditionalProperties().putAll( map );
}
}
return gBFSData;
}
@Override
GBFSData mapDataInverse(org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSData source) {
if ( source == null ) {
return null;
}
GBFSData gBFSData = new GBFSData();
gBFSData.setVehicles( gBFSBikeListToGBFSVehicleList( source.getBikes() ) );
if ( gBFSData.getAdditionalProperties() != null ) {
Map map = source.getAdditionalProperties();
if ( map != null ) {
gBFSData.getAdditionalProperties().putAll( map );
}
}
return gBFSData;
}
@Override
GBFSBike mapVehicle(GBFSVehicle source) {
if ( source == null ) {
return null;
}
GBFSBike gBFSBike = new GBFSBike();
gBFSBike.setBikeId( source.getVehicleId() );
gBFSBike.setLat( source.getLat() );
gBFSBike.setLon( source.getLon() );
gBFSBike.setIsReserved( source.getIsReserved() );
gBFSBike.setIsDisabled( source.getIsDisabled() );
gBFSBike.setRentalUris( gBFSRentalUrisToGBFSRentalUris( source.getRentalUris() ) );
gBFSBike.setVehicleTypeId( source.getVehicleTypeId() );
gBFSBike.setLastReported( dateMapper.mapDateToDouble( source.getLastReported() ) );
gBFSBike.setCurrentRangeMeters( source.getCurrentRangeMeters() );
gBFSBike.setCurrentFuelPercent( source.getCurrentFuelPercent() );
gBFSBike.setStationId( source.getStationId() );
gBFSBike.setHomeStationId( source.getHomeStationId() );
gBFSBike.setPricingPlanId( source.getPricingPlanId() );
gBFSBike.setVehicleEquipment( vehicleEquipmentListToVehicleEquipmentList( source.getVehicleEquipment() ) );
gBFSBike.setAvailableUntil( source.getAvailableUntil() );
if ( gBFSBike.getAdditionalProperties() != null ) {
Map map = source.getAdditionalProperties();
if ( map != null ) {
gBFSBike.getAdditionalProperties().putAll( map );
}
}
return gBFSBike;
}
@Override
GBFSVehicle mapVehicleInverse(GBFSBike source) {
if ( source == null ) {
return null;
}
GBFSVehicle gBFSVehicle = new GBFSVehicle();
gBFSVehicle.setVehicleId( source.getBikeId() );
gBFSVehicle.setLat( source.getLat() );
gBFSVehicle.setLon( source.getLon() );
gBFSVehicle.setIsReserved( source.getIsReserved() );
gBFSVehicle.setIsDisabled( source.getIsDisabled() );
gBFSVehicle.setRentalUris( gBFSRentalUrisToGBFSRentalUris1( source.getRentalUris() ) );
gBFSVehicle.setVehicleTypeId( source.getVehicleTypeId() );
gBFSVehicle.setLastReported( dateMapper.mapDoubleToDate( source.getLastReported() ) );
gBFSVehicle.setCurrentRangeMeters( source.getCurrentRangeMeters() );
gBFSVehicle.setCurrentFuelPercent( source.getCurrentFuelPercent() );
gBFSVehicle.setStationId( source.getStationId() );
gBFSVehicle.setHomeStationId( source.getHomeStationId() );
gBFSVehicle.setPricingPlanId( source.getPricingPlanId() );
gBFSVehicle.setVehicleEquipment( vehicleEquipmentListToVehicleEquipmentList1( source.getVehicleEquipment() ) );
gBFSVehicle.setAvailableUntil( source.getAvailableUntil() );
if ( gBFSVehicle.getAdditionalProperties() != null ) {
Map map = source.getAdditionalProperties();
if ( map != null ) {
gBFSVehicle.getAdditionalProperties().putAll( map );
}
}
return gBFSVehicle;
}
protected List gBFSVehicleListToGBFSBikeList(List list) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( GBFSVehicle gBFSVehicle : list ) {
list1.add( mapVehicle( gBFSVehicle ) );
}
return list1;
}
protected List gBFSBikeListToGBFSVehicleList(List list) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( GBFSBike gBFSBike : list ) {
list1.add( mapVehicleInverse( gBFSBike ) );
}
return list1;
}
protected org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSRentalUris gBFSRentalUrisToGBFSRentalUris(GBFSRentalUris gBFSRentalUris) {
if ( gBFSRentalUris == null ) {
return null;
}
org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSRentalUris gBFSRentalUris1 = new org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSRentalUris();
gBFSRentalUris1.setAndroid( gBFSRentalUris.getAndroid() );
gBFSRentalUris1.setIos( gBFSRentalUris.getIos() );
gBFSRentalUris1.setWeb( gBFSRentalUris.getWeb() );
if ( gBFSRentalUris1.getAdditionalProperties() != null ) {
Map map = gBFSRentalUris.getAdditionalProperties();
if ( map != null ) {
gBFSRentalUris1.getAdditionalProperties().putAll( map );
}
}
return gBFSRentalUris1;
}
protected VehicleEquipment vehicleEquipmentToVehicleEquipment(org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment vehicleEquipment) {
if ( vehicleEquipment == null ) {
return null;
}
VehicleEquipment vehicleEquipment1;
switch ( vehicleEquipment ) {
case CHILD_SEAT_A: vehicleEquipment1 = VehicleEquipment.CHILD_SEAT_A;
break;
case CHILD_SEAT_B: vehicleEquipment1 = VehicleEquipment.CHILD_SEAT_B;
break;
case CHILD_SEAT_C: vehicleEquipment1 = VehicleEquipment.CHILD_SEAT_C;
break;
case WINTER_TIRES: vehicleEquipment1 = VehicleEquipment.WINTER_TIRES;
break;
case SNOW_CHAINS: vehicleEquipment1 = VehicleEquipment.SNOW_CHAINS;
break;
default: throw new IllegalArgumentException( "Unexpected enum constant: " + vehicleEquipment );
}
return vehicleEquipment1;
}
protected List vehicleEquipmentListToVehicleEquipmentList(List list) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment vehicleEquipment : list ) {
list1.add( vehicleEquipmentToVehicleEquipment( vehicleEquipment ) );
}
return list1;
}
protected GBFSRentalUris gBFSRentalUrisToGBFSRentalUris1(org.mobilitydata.gbfs.v2_3.free_bike_status.GBFSRentalUris gBFSRentalUris) {
if ( gBFSRentalUris == null ) {
return null;
}
GBFSRentalUris gBFSRentalUris1 = new GBFSRentalUris();
gBFSRentalUris1.setAndroid( gBFSRentalUris.getAndroid() );
gBFSRentalUris1.setIos( gBFSRentalUris.getIos() );
gBFSRentalUris1.setWeb( gBFSRentalUris.getWeb() );
if ( gBFSRentalUris1.getAdditionalProperties() != null ) {
Map map = gBFSRentalUris.getAdditionalProperties();
if ( map != null ) {
gBFSRentalUris1.getAdditionalProperties().putAll( map );
}
}
return gBFSRentalUris1;
}
protected org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment vehicleEquipmentToVehicleEquipment1(VehicleEquipment vehicleEquipment) {
if ( vehicleEquipment == null ) {
return null;
}
org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment vehicleEquipment1;
switch ( vehicleEquipment ) {
case CHILD_SEAT_A: vehicleEquipment1 = org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment.CHILD_SEAT_A;
break;
case CHILD_SEAT_B: vehicleEquipment1 = org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment.CHILD_SEAT_B;
break;
case CHILD_SEAT_C: vehicleEquipment1 = org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment.CHILD_SEAT_C;
break;
case WINTER_TIRES: vehicleEquipment1 = org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment.WINTER_TIRES;
break;
case SNOW_CHAINS: vehicleEquipment1 = org.mobilitydata.gbfs.v3_0.vehicle_status.VehicleEquipment.SNOW_CHAINS;
break;
default: throw new IllegalArgumentException( "Unexpected enum constant: " + vehicleEquipment );
}
return vehicleEquipment1;
}
protected List vehicleEquipmentListToVehicleEquipmentList1(List list) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( VehicleEquipment vehicleEquipment : list ) {
list1.add( vehicleEquipmentToVehicleEquipment1( vehicleEquipment ) );
}
return list1;
}
}