I have to get the current instance of an Enum based on the classname. How do i acheive this.
this is what I am trying at the moment
Enum clzz = (Enum) Class.forName(className).cast(Enum.class);
and enum declaration is this
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.ngsmis.demo;
public enum PhaseType implements GenericEnum{
NURSERY( "NY", "Nursery"),
MIDDLE_MP( "MP", "Middle(Deemed Primary)"),
MIDDLE_MS( "MS", "Middle(Deemed secondary)"),
SECONDARY( "SY", "Secondary"),
SPECIAL( "SP", "Special"),
EARLY_YEAR( "EY", "Early Year Setting"),
PR_UNIT( "PR", "People Referral Unit"),
NO_ESTABLISHMENT( "NO", "No Establishment(For children not on any establishment roll)"),
PRIMARY( "PY", "Nursery");
private final String typeId;
private final String name;
private PhaseType(String typeId, String name) {
this.typeId = typeId;
this.name = name;
}
public String getName() {
return name;
}
public String getTypeId() {
return typeId;
}
}
the whole point is to be able to call the getTypeID method based on the Enum found.
any form of help will be gratefully appreciated