org.opentripplanner.api.mapping.StreetNoteMaperMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.api.mapping;
import org.opentripplanner.api.model.ApiAlert;
import org.opentripplanner.model.StreetNote;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
public class StreetNoteMaperMapper {
private final Locale locale;
public StreetNoteMaperMapper(Locale locale) {
this.locale = locale;
}
public List mapToApi(Set newAlerts) {
// Using {@code null} and not an empty set will minimize the JSON removing the
// {@code alerts} from the result.
if (newAlerts == null || newAlerts.isEmpty()) {
return null;
}
return newAlerts.stream().map(this::mapToApi).collect(Collectors.toList());
}
ApiAlert mapToApi(StreetNote domain) {
ApiAlert api = new ApiAlert();
if (domain.note != null) {
api.alertHeaderText = domain.note.toString(locale);
}
if (domain.descriptionText != null) {
api.alertDescriptionText = domain.descriptionText.toString(locale);
}
if (domain.url != null) {
api.alertUrl = domain.url;
}
api.effectiveStartDate = domain.effectiveStartDate;
api.effectiveEndDate = domain.effectiveEndDate;
return api;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy