1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package nl.tudelft.goal.unreal.translators;
21
22 import java.util.Arrays;
23
24 import nl.tudelft.goal.EIS2Java.exception.TranslationException;
25 import nl.tudelft.goal.EIS2Java.translation.Parameter2Java;
26 import nl.tudelft.goal.EIS2Java.translation.Translator;
27 import nl.tudelft.goal.unreal.messages.Skin;
28 import eis.iilang.Parameter;
29
30 public class SkinTranslator implements Parameter2Java<Skin>{
31
32
33 @Override
34 public Skin translate(Parameter parameter) throws TranslationException {
35 String skinString = Translator.getInstance().translate2Java(parameter, String.class);
36
37 try {
38 return Skin.valueOf(skinString);
39 } catch (Exception e) {
40 String message = String.format("%s was not a skin. Expected one of %s.", skinString, Arrays.toString(Skin.values()));
41 throw new TranslationException(message,e);
42 }
43 }
44
45 @Override
46 public Class<Skin> translatesTo() {
47 return Skin.class;
48 }
49
50 }