samedi 4 mars 2017

invoke a method using the name of an other Enumeration

It is possible to invoke a method using the name of an other Enumeration.

I did this with switch case statement :

public static String getSnowmizLabel(SnowmizEnum snowmizEnum, SnowmizI18n snowmizI18n) {
    switch (snowmizEnum) {
        case MIZ1_SUBTYPE:/**/
            return snowmizI18n.MIZ1_SUBTYPE();

        /*100 other cases*/ 

        case MIZ2_SUBTYPE:
            return snowmizI18n.MIZ2_SUBTYPE(MyContext.getProjectCode());
        default:
            return snowmizEnum.name();
    }
}

but i need to use java reflection.





Aucun commentaire:

Enregistrer un commentaire