templates.Enums.xpt Maven / Gradle / Ivy
?IMPORT core?
?EXTENSION extensions::Enums?
?EXTENSION extensions::Names?
?EXTENSION org::openxma::dsl::common::extensions::LogUtil?
?DEFINE main FOR Model?
?EXPAND genClass FOREACH eAllContents.typeSelect(EnumType).select(e|e.typeDefinition==null)?
?EXPAND genResourceBundle FOREACH eAllContents.typeSelect(EnumType).select(e|e.typeDefinition==null)?
?ENDDEFINE?
?DEFINE genClass FOR EnumType?
?info("Write "+getGenClassFileName())?
?FILE getGenClassFileName()-?
package ?getPackageName(true)?;
import java.util.Locale;
import org.openxma.dsl.platform.enums.I18nEnum;
import org.openxma.dsl.platform.enums.I18nEnums;
?EXPAND Documentation::documentation FOR this-?
public enum ?getGenClassName()? implements I18nEnum {
?FOREACH literals AS literal ITERATOR iter-?
?literal.name?("?literal.getKey()?")?IF !iter.lastIteration?,?ELSE?;?ENDIF?
?ENDFOREACH-?
private String key;
private ?getGenClassName()?(String key) {
this.key = key;
}
public String getKey() {
return this.key;
}
public String getLongValue(Locale locale) {
return I18nEnums.longValueFromProvider(this, locale);
}
public String getShortValue(Locale locale) {
return I18nEnums.shortValueFromProvider(this, locale);
}
public static ?getGenClassName()? valueOfKey(String key) {
return I18nEnums.valueOfKey(?getGenClassName()?.class,key);
}
}
?ENDFILE?
?ENDDEFINE?
?DEFINE genResourceBundle FOR EnumType?
?info("Write "+getGenResourceBundleFileName())?
?FILE getGenResourceBundleFileName() OUTLET_GENERATED_RESOURCES-?
COLS = COD_KEY,SHORT_VALUE,LONG_VALUE,VALID_FROM,VALID_TO
?FOREACH literals AS literal ITERATOR iter-?
?iter.counter1*10? = "?literal.getKey()?", "?literal.getShortValue()?", "?literal.getLongValue()?", D19700101, D99991231
?ENDFOREACH-?
?ENDFILE?
?ENDDEFINE?