]> git.basschouten.com Git - openhab-addons.git/blob
18391d54bb6d85473b2abd4281fc7b7fe30a8ef9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.mikrotik.internal.model;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * The {@link RouterosInterfaceType} enum wraps RouterOS network interface type strings.
20  *
21  * @author Oleg Vivtash - Initial contribution
22  */
23
24 @NonNullByDefault
25 public enum RouterosInterfaceType {
26     ETHERNET("ether"),
27     BRIDGE("bridge"),
28     WLAN("wlan"),
29     CAP("cap"),
30     PPP_CLIENT("ppp-out"),
31     PPPOE_CLIENT("pppoe-out"),
32     L2TP_SERVER("l2tp-in"),
33     L2TP_CLIENT("l2tp-out"),
34     LTE("lte");
35
36     private final String typeName;
37
38     RouterosInterfaceType(String routerosType) {
39         this.typeName = routerosType;
40     }
41
42     public boolean equalsName(String otherType) {
43         // (otherName == null) check is not needed because name.equals(null) returns false
44         return typeName.equals(otherType);
45     }
46
47     @Override
48     public String toString() {
49         return this.typeName;
50     }
51
52     public @Nullable static RouterosInterfaceType resolve(@Nullable String routerosType) {
53         for (RouterosInterfaceType current : RouterosInterfaceType.values()) {
54             if (current.typeName.equals(routerosType)) {
55                 return current;
56             }
57         }
58         return null;
59     }
60 }