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

org.entur.gbfs.mapper.GeofencingZonesAdditionalMapper Maven / Gradle / Ivy

There is a newer version: 2.0.16
Show newest version
package org.entur.gbfs.mapper;

import org.mapstruct.Context;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper
public abstract class GeofencingZonesAdditionalMapper {
    List mapName(String value, @Context String language) {
        if (value == null) {
            return null;
        }
        return List.of(
                new org.mobilitydata.gbfs.v3_0.geofencing_zones.GBFSName()
                        .withText(value)
                        .withLanguage(language)
        );
    }

    String mapNameInverse(List values, @Context String language) {
        if (values == null) {
            return null;
        }

        return values.stream()
                .filter(name -> name.getLanguage().equals(language))
                .map(org.mobilitydata.gbfs.v3_0.geofencing_zones.GBFSName::getText)
                .findFirst().orElse(null);
    }

    @Mapping(target = "rideStartAllowed", source = "rideAllowed")
    @Mapping(target = "rideEndAllowed", source = "rideAllowed")
    @Mapping(target = "vehicleTypeIds", source = "vehicleTypeId")
    abstract org.mobilitydata.gbfs.v3_0.geofencing_zones.GBFSRule mapRule(org.mobilitydata.gbfs.v2_3.geofencing_zones.GBFSRule source);

    @Mapping(target = "rideAllowed", expression = "java(source.getRideStartAllowed() && source.getRideEndAllowed())")
    @Mapping(target = "vehicleTypeId", source = "vehicleTypeIds")
    abstract org.mobilitydata.gbfs.v2_3.geofencing_zones.GBFSRule mapRuleInverse(org.mobilitydata.gbfs.v3_0.geofencing_zones.GBFSRule source);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy