View Javadoc
1   package fr.ifremer.quadrige3.ui.core.dto.month;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: UI Core Common
6    * %%
7    * Copyright (C) 2017 - 2022 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Affero General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Affero General Public License
20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  import fr.ifremer.quadrige3.ui.core.dto.MonthDTO;
24  import fr.ifremer.quadrige3.ui.core.dto.QuadrigeBeanFactory;
25  
26  import static org.nuiton.i18n.I18n.n;
27  import static org.nuiton.i18n.I18n.t;
28  
29  public enum MonthValues {
30      JANUARY(n("quadrige.core.enums.month.1")),
31      FEBRUARY(n("quadrige.core.enums.month.2")),
32      MARCH(n("quadrige.core.enums.month.3")),
33      APRIL(n("quadrige.core.enums.month.4")),
34      MAY(n("quadrige.core.enums.month.5")),
35      JUNE(n("quadrige.core.enums.month.6")),
36      JULY(n("quadrige.core.enums.month.7")),
37      AUGUST(n("quadrige.core.enums.month.8")),
38      SEPTEMBER(n("quadrige.core.enums.month.9")),
39      OCTOBER(n("quadrige.core.enums.month.10")),
40      NOVEMBER(n("quadrige.core.enums.month.11")),
41      DECEMBER(n("quadrige.core.enums.month.12")),
42      ;
43  
44      private final String i18nKey;
45  
46      MonthValues(String i18nKey) {
47          this.i18nKey = i18nKey;
48      }
49  
50      public String getLabel() {
51          return t(this.i18nKey);
52      }
53  
54      public MonthDTO toDTO() {
55          MonthDTO monthDTO = QuadrigeBeanFactory.newMonthDTO();
56          monthDTO.setId(ordinal() + 1); // important
57          monthDTO.setName(getLabel());
58          return monthDTO;
59      }
60  }