All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.lang.Enum Maven / Gradle / Ivy

There is a newer version: 0.96-beta4
Show newest version
package java.lang;

import com.dragome.commons.javascript.ScriptHelper;

/**
 * This is the common base class of all Java language enumeration types.
 */
public abstract class Enum
{

	private String desc;
	private int ordinal;

	/**
	 * Sole constructor.
	 */
	protected Enum(String theDesc, int theOrdinal)
	{
		desc= theDesc;
		ordinal= theOrdinal;
	}

	/**
	 * Returns the enum constant of the specified enum type with the specified name.
	 *
	 * Note: This method (signature only) is required by the JDK compiler!
	 */
	public static > T valueOf(Class enumType, String name)
	{
		ScriptHelper.put("enumType", enumType, null);
		ScriptHelper.put("name", name, null);
		return (T) ScriptHelper.eval("enumType.$$$nativeClass.$$clinit_()[\"$$$\"+name]", null);
	}

	/**
	 * Returns the ordinal of this enumeration constant.
	 */
	public int ordinal()
	{
		return ordinal;
	}

	/**
	 * Returns the name of this enum constant.
	 */
	public String toString()
	{
		return desc;
	}

	public String name()
	{
		//TODO revisar
		return null;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy