I want to improve my use of JDK 1.5 and stop using private static final String instead of enum. This is what seems to be recommended.
But now my constant class looks like this :
public class CEnum{
/**
* @author JJA
* date : 20/10/2010
*/
public enum ListTypeAffichage {
DEP("DEPOT_TVA"), PAD("PAS_DEPOT_TVA"), NORM("CAT_NORMALE"), CAP("CAT_PARTICULIERE"), CAA("CAT_AUTRE_CAS");
private final String sName;
/**
* @param name String
*/
ListTypeAffichage(String name) {
this.sName = name;
}
/**
* @return String
*/
public String getType() {
return sName;
}
}
/**
* @author JJA
* date : 20/10/2010
*/
public enum ListTypeCategorie {
DEDUIRE("SOMME_A_DEDUIRE"), AJOUTER("SOMME_A_AJOUTER");
private final String sName;
/**
* @param name String
*/
ListTypeCategorie(String name) {
this.sName = name;
}
/**
* @return String
*/
public String getType() {
return sName;
}
}
/**
* @author JJA
* date : 26/10/2010
*/
public enum ListInterval {
POS("POSITIF"), NS("NON_SIGNE");
private final String sName;
/**
* @param name String
*/
ListInterval(String name) {
this.sName = name;
}
/**
* @return String
*/
public String getInterval() {
return sName;
}
}
}
instead of
public class ConstantesADMD {
public static final List<String> typeAffich = new ArrayList<String>();
...
ConstantesADMD(){
typeAffich.add("DEPOT_TVA");
typeAffich.add("PAS_DEPOT_TVA");
typeAffich.add("CAT_NORMALE");
...
}
}
My code seems to be really bad, but at least works. For each enum I have to add the redundant code :
private final String sName;
/**
* @param name String
*/
ListTypeAffichage(String name) {
this.sName = name;
}
/**
* @return String
*/
public String getType() {
return sName;
}
What improvment do you advise me? Note : forget the last sentences of my first question, I need the index. Tell me if I have to post another question, editing my fisrt seems easier.