View Javadoc
1   package net.sumaris.core.model.referential.location;
2   
3   /*-
4    * #%L
5    * SUMARiS:: Core
6    * %%
7    * Copyright (C) 2018 - 2019 SUMARiS Consortium
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (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 General Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import java.io.Serializable;
26  import java.util.Arrays;
27  
28  public enum LocationLevelEnum implements Serializable {
29  
30  
31      COUNTRY(1, "Country"),
32      HARBOUR(2, "Port"),
33      AUCTION(3, "Auction"),
34      RECTANGLE_ICES(4,"ICES_RECTANGLE"),
35      RECTANGLE_CGPM_GFCM(5,"CGPM_GFCM_RECTANGLE"),
36      SQUARE_10(6, "SQUARE_10"), // 10' x 10'
37      SQUARE_3(7, "SQUARE_3") // 3' x 3'
38      ;
39  
40      public static LocationLevelEnum valueOf(final int id) {
41          return Arrays.stream(values())
42                  .filter(level -> level.id == id)
43                  .findFirst()
44                  .orElseThrow(() -> new IllegalArgumentException("Unknown LocationLevelEnum: " + id));
45      }
46  
47      public static LocationLevelEnum byLabel(final String label) {
48          return Arrays.stream(values())
49                  .filter(level -> label.equals(level.label))
50                  .findFirst()
51                  .orElseThrow(() -> new IllegalArgumentException("Unknown LocationLevelEnum: " + label));
52      }
53  
54      private int id;
55      private String label;
56  
57      LocationLevelEnum(int id, String label) {
58          this.id = id;
59          this.label = label;
60      }
61  
62      public int getId() {
63          return id;
64      }
65  
66      public void setId(int id) {
67          this.id = id;
68      }
69  
70      public String getLabel() {
71          return label;
72      }
73  
74      public void setLabel(String label) {
75          this.label = label;
76      }
77  
78  }