public static Transport fromString(String s) { for (Transport t : Transport.values()) { if (t.toString().equals(s)) { return t; } } return null; }
@Test public void test2() { Transport TransArray[] = Transport.values(); for (Transport tr : TransArray) { System.out.println(tr); } }
public static Transport byName(String value) { for (Transport t : Transport.values()) { if (t.getValue().equals(value)) { return t; } } throw new IllegalArgumentException("Can't find " + value + " transport"); }