]> git.basschouten.com Git - openhab-addons.git/blob
d1a93bb7edd938b2d7cd1d853ad85b4e66b4310d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.windcentrale.internal.dto;
14
15 import java.util.Arrays;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21  * Enumerates the Windcentrale windmills. The project codes are used in API requests and responses.
22  * The other details are used as Thing properties.
23  *
24  * @author Wouter Born - Initial contribution
25  */
26 @NonNullByDefault
27 public enum Windmill {
28
29     DE_GROTE_GEERT(1, "WND-GG", "De Grote Geert", 9910, "Enercon E-70", 2008, "Delfzijl", "Groningen",
30             "53.280605, 6.955141", "https://www.windcentrale.nl/molens/de-grote-geert-2/"),
31     DE_JONGE_HELD(2, "WND-JH", "De Jonge Held", 10154, "Enercon E-70", 2008, "Delfzijl", "Groningen",
32             "53.277648, 6.954906", "https://www.windcentrale.nl/molens/de-jonge-held/"),
33     HET_RODE_HERT(31, "WND-RH", "Het Rode Hert", 6648, "Vestas V80", 2005, "Culemborg", "Gelderland",
34             "51.935831, 5.192109", "https://www.windcentrale.nl/molens/het-rode-hert/"),
35     DE_RANKE_ZWAAN(41, "WND-RZ", "De Ranke Zwaan", 6164, "Vestas V80", 2005, "Culemborg", "Gelderland",
36             "51.934915, 5.19989", "https://www.windcentrale.nl/molens/de-ranke-zwaan-2/"),
37     DE_WITTE_JUFFER(51, "WND-WJ", "De Witte Juffer", 5721, "Vestas V80", 2005, "Culemborg", "Gelderland",
38             "51.935178, 5.195860", "https://www.windcentrale.nl/molens/de-witte-juffer/"),
39     DE_BONTE_HEN(111, "WND-BH", "De Bonte Hen", 5579, "Vestas V52", 2009, "Burgerbrug", "Noord-Holland",
40             "52.757051, 4.684678", "https://www.windcentrale.nl/molens/de-bonte-hen-2/"),
41     DE_TROUWE_WACHTER(121, "WND-TW", "De Trouwe Wachter", 5602, "Vestas V52", 2009, "Burgerbrug", "Noord-Holland",
42             "52.758745, 4.686041", "https://www.windcentrale.nl/molens/de-trouwe-wachter-2/"),
43     DE_BLAUWE_REIGER(131, "WND-BR", "De Blauwe Reiger", 5534, "Vestas V52", 2009, "Burgerbrug", "Noord-Holland",
44             "52.760482, 4.687438", "https://www.windcentrale.nl/molens/de-blauwe-reiger/"),
45     DE_VIER_WINDEN(141, "WND-VW", "De Vier Winden", 5512, "Vestas V52", 2009, "Burgerbrug", "Noord-Holland",
46             "52.762219, 4.688837", "https://www.windcentrale.nl/molens/de-vier-winden-2/"),
47     DE_BOERENZWALUW(201, "WND-BZ", "De Boerenzwaluw", 3000, "Enercon E-44", 2015, "Burum", "Friesland",
48             "53.265572, 6.213929", "https://www.windcentrale.nl/molens/de-boerenzwaluw/"),
49     HET_VLIEGENDE_HERT(211, "WND-VH", "Het Vliegend Hert", 10000, "Lagerwey L82", 2019, "Rouveen", "Overijssel",
50             "52.595422, 6.223335", "https://www.windcentrale.nl/molens/het-vliegend-hert/");
51
52     private final int id;
53     private final String projectCode;
54     private final String name;
55     private final int totalShares;
56     private final String type;
57     private final int buildYear;
58     private final String municipality;
59     private final String province;
60     private final String coordinates;
61     private final String detailsUrl;
62
63     Windmill(int id, String projectCode, String name, int totalShares, String type, int buildYear, String municipality,
64             String province, String coordinates, String detailsUrl) {
65         this.id = id;
66         this.projectCode = projectCode;
67         this.name = name;
68         this.totalShares = totalShares;
69         this.type = type;
70         this.buildYear = buildYear;
71         this.municipality = municipality;
72         this.province = province;
73         this.coordinates = coordinates;
74         this.detailsUrl = detailsUrl;
75     }
76
77     public int getId() {
78         return id;
79     }
80
81     public String getProjectCode() {
82         return projectCode;
83     }
84
85     public String getName() {
86         return name;
87     }
88
89     public int getTotalShares() {
90         return totalShares;
91     }
92
93     public String getType() {
94         return type;
95     }
96
97     public int getBuildYear() {
98         return buildYear;
99     }
100
101     public String getMunicipality() {
102         return municipality;
103     }
104
105     public String getProvince() {
106         return province;
107     }
108
109     public String getCoordinates() {
110         return coordinates;
111     }
112
113     public String getDetailsUrl() {
114         return detailsUrl;
115     }
116
117     @Override
118     public String toString() {
119         return name;
120     }
121
122     public static @Nullable Windmill fromName(String name) {
123         return Arrays.stream(values()) //
124                 .filter(windmill -> windmill.name.equals(name)) //
125                 .findFirst().orElse(null);
126     }
127
128     public static @Nullable Windmill fromProjectCode(String projectCode) {
129         return Arrays.stream(values()) //
130                 .filter(windmill -> windmill.projectCode.equals(projectCode)) //
131                 .findFirst().orElse(null);
132     }
133 }