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

org.opentripplanner.netex.mapping.OperatorToAgencyMapper Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package org.opentripplanner.netex.mapping;

import org.opentripplanner.model.Operator;
import org.opentripplanner.netex.mapping.support.FeedScopedIdFactory;
import org.rutebanken.netex.model.ContactStructure;


/**
 * Maps a Netex operator to OTP Operator.
 */
class OperatorToAgencyMapper {

    private final FeedScopedIdFactory idFactory;

    OperatorToAgencyMapper(FeedScopedIdFactory idFactory) {
        this.idFactory = idFactory;
    }

    Operator mapOperator(org.rutebanken.netex.model.Operator source){
        Operator target = new Operator(
            idFactory.createId(source.getId())
        );
        target.setName(source.getName().getValue());

        mapContactDetails(source.getContactDetails(), target);

        return target;
    }

    private static void mapContactDetails(ContactStructure contactDetails, Operator target) {
        if(contactDetails == null) {
            return;
        }
        target.setUrl(contactDetails.getUrl());
        target.setPhone(contactDetails.getPhone());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy