[LIB-9] Separate chesshog-uci module
[chesshog.git] / chesshog-uci / src / main / java / org / hedgecode / chess / uci / command / OptionType.java
1 /*
2  * Copyright (c) 2018. Developed by Hedgecode.
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.hedgecode.chess.uci.command;
18
19 /**
20  * Types of options that UCI Engine can send/receive.
21  *
22  * @author Dmitry Samoshin aka gotty
23  */
24 public enum OptionType {
25
26     /**
27      * Checkbox that can either be true or false.
28      */
29     CHECK ("check"),
30
31     /**
32      * Spin wheel that can be an integer in a certain range.
33      */
34     SPIN ("spin"),
35
36     /**
37      * Combo box that can have different predefined strings as a value.
38      */
39     COMBO ("combo"),
40
41     /**
42      * Button that can be pressed to send a command to the engine.
43      */
44     BUTTON ("button"),
45
46     /**
47      * Text field that has a string as a value, an empty string has the value "<empty>".
48      */
49     STRING ("string");
50
51     private String type;
52
53     OptionType(String type) {
54         this.type = type;
55     }
56
57     public String type() {
58         return type;
59     }
60
61     public static OptionType get(String type) {
62         for (OptionType optionType : OptionType.values()) {
63             if (optionType.type().equals(type))
64                 return optionType;
65         }
66         return null;
67     }
68
69 }