package demoEnum;

import java.lang.Enum;

public class SwitchUTC /* extends Enum */ {
	private final int index;

	private static String[] names = { "ON", "OFF" };
	private static final SwitchUTC[] values = { new SwitchUTC(0), new SwitchUTC(1) };

	public static final SwitchUTC ON = values[0];
	public static final SwitchUTC OFF = values[1];

	public SwitchUTC(int index) { this.index=index; }

	static public SwitchUTC[] values() { return values; }

	static public SwitchUTC valueOf(Class enumType,String name) {
		if (enumType==null) throw new NullPointerException("enumType argument of valueOf method is null");
		if (name==null) throw new NullPointerException("name argument of valueOf method is null");
		if (enumType != SwitchUTC.class) throw new IllegalArgumentException("enumType argument of valueOf method is not Switch");
		for(int i=0;i<names.length;i++) {
			if (names[i].compareTo(name)==0) return values[i];
		}
		throw new IllegalArgumentException("name not a valid enumeration value for the Swith enumeration");
	}

	public final String name() { return names[index]; }
	public final int ordinal() { return index; }
	@Override public String toString() { return name(); }
	@Override public final boolean equals(Object other) {
		if (other instanceof SwitchUTC && index==((SwitchUTC)other).ordinal()) return true;
		return false;
	}
	@Override public final int hashCode() { return Integer.hashCode(index); }
	public final int compareTo(SwitchUTC o) { return index - o.ordinal(); }

};
