Created
December 18, 2017 15:02
-
-
Save tamboer/3a6b5e4ae6ce29e2ae7788b6ed0943d3 to your computer and use it in GitHub Desktop.
enum with translations
This file contains hidden or 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
| import com.tvh.assetmanagement.common.SupportedLocales; | |
| import java.util.HashMap; | |
| import java.util.Locale; | |
| import java.util.Map; | |
| public enum EngineType { | |
| THERMAL("Thermal", "Thermisch"), | |
| ELECTRICAL("Electrical", "Elektrisch"), | |
| MANUAL("Manual", "Manueel"); | |
| private Map<Locale,String> descriptions = new HashMap<>(); | |
| EngineType(final String description, final String descriptionNL) { | |
| this.descriptions.put(SupportedLocales.ENGLISH, description); | |
| this.descriptions.put(SupportedLocales.DUTCH, descriptionNL); | |
| } | |
| public String getDescription() { | |
| return descriptions.get(SupportedLocales.getDefault()); | |
| } | |
| public String getDescription(Locale locale) { | |
| return descriptions.get(locale); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment