import { JavaObject, cast_java_lang_Object } from '../../java/lang/JavaObject';
import { JavaString, cast_java_lang_String } from '../../java/lang/JavaString';
import { IllegalArgumentException, cast_java_lang_IllegalArgumentException } from '../../java/lang/IllegalArgumentException';

export class Abschluss extends JavaObject {

	/** the name of the enumeration value */
	private readonly __name : String;

	/** the ordinal value for the enumeration value */
	private readonly __ordinal : number;

	/** an array containing all values of this enumeration */
	private static readonly all_values_by_ordinal : Array<Abschluss> = [];

	/** an array containing all values of this enumeration indexed by their name*/
	private static readonly all_values_by_name : Map<String, Abschluss> = new Map<String, Abschluss>();

	public static readonly OHNE_ABSCHLUSS : Abschluss = new Abschluss("OHNE_ABSCHLUSS", 0, );

	public static readonly HA9 : Abschluss = new Abschluss("HA9", 1, );

	public static readonly HA10 : Abschluss = new Abschluss("HA10", 2, );

	public static readonly MSA : Abschluss = new Abschluss("MSA", 3, );

	public static readonly MSA_Q : Abschluss = new Abschluss("MSA_Q", 4, );

	private constructor(name : string, ordinal : number) {
		super();
		this.__name = name;
		this.__ordinal = ordinal;
		Abschluss.all_values_by_ordinal.push(this);
		Abschluss.all_values_by_name.set(name, this);
	}

	/**
	 * Prüft, ob dieser Abschluss dem im String-Parameter str übergebenen 
	 * Abschluss entspricht.
	 *  
	 * @param str   der Name des Abschlusses für den Vergleich als String
	 * 
	 * @return true, falls beide Abschlüsse übereinstimmen und ansonsten false
	 */
	public is(str : String | null) : boolean {
		if (str === null) 
			return false;
		try {
			let other : Abschluss | null = Abschluss.valueOf(str);
			return JavaObject.equalsTranspiler(this, (other));
		} catch(e) {
			return false;
		}
	}

	/**
	 * Returns the name of this enumeration value.
	 *
	 * @returns the name
	 */
	private name() : String {
		return this.__name;
	}

	/**
	 * Returns the ordinal value of this enumeration value.
	 *
	 * @returns the ordinal value
	 */
	private ordinal() : number {
		return this.__ordinal;
	}

	/**
	 * Returns the name of this enumeration value.
	 *
	 * @returns the name
	 */
	public toString() : String {
		return this.__name;
	}

	/**
	 * Returns true if this and the other enumeration values are equal.
	 *
	 * @param other   the other enumeration value
	 *
	 * @returns true if they are equal and false otherwise
	 */
	public equals(other : JavaObject) : boolean {
		if (!(other instanceof Abschluss))
			return false;
		return this === other;
	}

	/**
	 * Returns the ordinal value as hashcode, since the ordinal value is unique.
	 *
	 * @returns the ordinal value as hashcode
	 */
	public hashCode() : number {
		return this.__ordinal;
	}

	/**
	 * Compares this enumeration value with the other enumeration value by their ordinal value.
	 *
	 * @param other   the other enumeration value
	 *
	 * @returns a negative, zero or postive value as this enumeration value is less than, equal to
	 *          or greater than the other enumeration value
	 */
	public compareTo(other : Abschluss) : number {
		return this.__ordinal - other.__ordinal;
	}

	/**
	 * Returns an array with enumeration values.
	 *
	 * @returns the array with enumeration values
	 */
	public static values() : Array<Abschluss> {
		return [...this.all_values_by_ordinal];
	}

	/**
	 * Returns the enumeration value with the specified name.
	 *
	 * @param name   the name of the enumeration value
	 *
	 * @returns the enumeration values or null
	 */
	public static valueOf(name : String) : Abschluss | null {
		let tmp : Abschluss | undefined = this.all_values_by_name.get(name);
		return (!tmp) ? null : tmp;
	}

	isTranspiledInstanceOf(name : string): boolean {
		return ['de.nrw.schule.svws.core.types.Abschluss'].includes(name);
	}

}

export function cast_de_nrw_schule_svws_core_types_Abschluss(obj : unknown) : Abschluss {
	return obj as Abschluss;
}
