Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TranslatedAlert to help serializing of alert translations
- Loading branch information
Showing
8 changed files
with
106 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/org/opentripplanner/api/model/alertpatch/LocalizedAlert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.opentripplanner.api.model.alertpatch; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import org.opentripplanner.routing.alertpatch.Alert; | ||
|
||
import javax.xml.bind.annotation.XmlAttribute; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import javax.xml.bind.annotation.XmlTransient; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
|
||
@XmlRootElement(name = "Alert") | ||
public class LocalizedAlert { | ||
|
||
@XmlTransient | ||
@JsonIgnore | ||
public Alert alert; | ||
|
||
@XmlTransient | ||
@JsonIgnore | ||
private Locale locale; | ||
|
||
public LocalizedAlert(Alert alert, Locale locale) { | ||
this.alert = alert; | ||
this.locale = locale; | ||
} | ||
|
||
public LocalizedAlert(){ | ||
} | ||
|
||
@XmlAttribute | ||
@JsonSerialize | ||
public String getAlertHeaderText() { | ||
if (alert.alertHeaderText == null) { | ||
return null; | ||
} | ||
return alert.alertHeaderText.toString(locale); | ||
} | ||
|
||
@XmlAttribute | ||
@JsonSerialize | ||
public String getAlertDescriptionText() { | ||
if (alert.alertDescriptionText == null) { | ||
return null; | ||
} | ||
return alert.alertDescriptionText.toString(locale); | ||
} | ||
|
||
@XmlAttribute | ||
@JsonSerialize | ||
public String getAlertUrl() { | ||
if (alert.alertUrl == null) { | ||
return null; | ||
} | ||
return alert.alertUrl.toString(locale); | ||
} | ||
|
||
//null means unknown | ||
@XmlElement | ||
@JsonSerialize | ||
public Date getEffectiveStartDate() { | ||
return alert.effectiveStartDate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters