Coverage Summary for Class: FuncCommand (it.polimi.ingsw.controller)
Class | Class, % | Method, % | Line, % |
---|---|---|---|
FuncCommand | 100% (1/ 1) | 100% (5/ 5) | 100% (9/ 9) |
1 package it.polimi.ingsw.controller;
2
3 import java.util.Arrays;
4
5 /**
6 * Class used to map functions launched (to be launched) on server's side and a client function naming
7 */
8 enum FuncCommand {
9 SET_GOD_LIST("setGodList"), SET_GOD("setGod"), SET_WORKERS("setWorkers"), SET_COLOR("setColor"),
10 CHOOSE_WORKER("chooseWorker"), CHOOSE_ACTION("chooseAction"), SET_START_PLAYER("setStartPlayer"),
11 QUIT_PLAYER("quitPlayer");
12
13 /**
14 * value on client side
15 */
16 private final String value;
17
18 /**
19 * Constructor
20 *
21 * @param value client side's value
22 */
23 private FuncCommand(String value) {
24 this.value = value;
25 }
26
27 /**
28 * Get client side's value
29 *
30 * @return client side value
31 */
32 public String getValue() {
33 return value;
34 }
35
36 /**
37 * Convert a client side's into a server side's value, otherwise null
38 *
39 * @param toGet client side's value to convert
40 * @return client side's value's name
41 */
42 public static FuncCommand getFromValue(String toGet) {
43 return Arrays.asList(FuncCommand.values()).stream().filter(e -> e.value.equals(toGet)).findFirst().orElse(null);
44 }
45 }