1 /*
2  * Copyright @ 2018 - present 8x8, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package org.jitsi.videobridge.rest.root.colibri.debug;
18 
19 public enum FeatureState {
20     ENABLE(true),
21     DISABLE(false);
22 
23     boolean value;
24 
FeatureState(boolean value)25     FeatureState(boolean value) {
26         this.value = value;
27     }
28 
getValue()29     public boolean getValue() {
30         return value;
31     }
32 
33 
34     /**
35      * A custom 'fromString' implementation which allows creating an instance of
36      * this enum from its value.  This assumes that the String values are derived using
37      * the following transformation of the 'keys':
38      * 1) lower case
39      * 2) underscores are replaced with hyphens
40      *
41      * @param value the String value of the enum
42      * @return an instance of the enum, if one can be derived by reversing the transformation
43      * detailed above
44      */
fromString(String value)45     public static FeatureState fromString(String value)
46     {
47         if ("enable".equalsIgnoreCase(value))
48         {
49             return ENABLE;
50         }
51         else if ("disable".equalsIgnoreCase(value))
52         {
53             return DISABLE;
54         }
55         else
56         {
57             throw new IllegalArgumentException("feature state is either enabled or disabled.");
58         }
59     }
60 }
61