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

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

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

import org.opentripplanner.netex.mapping.support.FeedScopedIdFactory;
import org.opentripplanner.transit.model.basic.Notice;
import org.opentripplanner.transit.model.framework.EntityById;
import org.opentripplanner.transit.model.framework.FeedScopedId;

/**
 * Maps NeTEx notice to OTP notice.
 * 

* This Mapper is stateful, it caches objects it already have mapped. Because of this just one * instance of the mapper should be used in a context where the same Notice may appear more than * once. */ class NoticeMapper { private final FeedScopedIdFactory idFactory; private final EntityById cache = new EntityById<>(); NoticeMapper(FeedScopedIdFactory idFactory) { this.idFactory = idFactory; } Notice map(org.rutebanken.netex.model.Notice netexNotice) { FeedScopedId id = idFactory.createId(netexNotice.getId()); Notice otpNotice = cache.get(id); if (otpNotice == null) { otpNotice = Notice .of(id) .withPublicCode(netexNotice.getPublicCode()) .withText(netexNotice.getText().getValue()) .build(); cache.add(otpNotice); } return otpNotice; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy