public static FigureType getTypeByIntVal(int val) { for (FigureType type : FigureType.values()) { if (type.getValue() == val) { return type; } } return null; }
public static FigureType randomType() { return getTypeByIntVal(new Random().nextInt(FigureType.values().length) + 1); }