View Javadoc
1   package fr.paris.lutece.plugins.aot.modules.declarationimmat.business;
2   
3   import java.util.Arrays;
4   
5   import fr.paris.lutece.portal.service.i18n.I18nService;
6   import fr.paris.lutece.portal.web.l10n.LocaleService;
7   
8   public enum TypeVehicle
9   {
10      POIDS_LOURD( "PL", "PoidsLourd" ), VEHICULE_LEGER( "VL", null ), AUTOCAR( "AC", "AutoCar" ), MONTEMEUBLE( "MM", null );
11  
12      private static final String PROPERTY_TRANSLATION_LABEL = "declarationimmat.type_vehicle.label.";
13  
14      private String _strCode;
15      private String _strLibelle;
16  
17      private TypeVehicle( String code, String libelle )
18      {
19          this._strCode = code;
20          this._strLibelle = libelle;
21      }
22  
23      public String getLibelle( )
24      {
25          return _strLibelle;
26      }
27  
28      public String getCode( )
29      {
30          return _strCode;
31      }
32  
33      public static TypeVehicle fromCode( String code )
34      {
35          return Arrays.asList( values( ) ).stream( ).filter( type -> type.getCode( ).equals( code ) ).findFirst( ).get( );
36      }
37  
38      public String getTranslation( )
39      {
40          return I18nService.getLocalizedString( PROPERTY_TRANSLATION_LABEL + _strCode, LocaleService.getDefault( ) );
41      }
42  }