public static Orientation fromIndex(int index) { Orientation[] values = Orientation.values(); if (index < 0 || index >= values.length) { throw new IndexOutOfBoundsException(); } return values[index]; }
/** @param name The new name of the units. Defaults to DEFAULT is there is no match. */ public void setOrientation(String name) { for (Orientation orientation : Orientation.values()) { if (orientation.getName().equals(name)) { this.orientation = orientation; return; } } this.orientation = Orientation.DEFAULT; }