vTemplates.MetaEnumTemplate.vm Maven / Gradle / Ivy
package ${context.pack}.meta;
public class Meta${context.getName()} implements org.kevoree.modeling.KType {
private static Meta${context.getName()} INSTANCE;
public static Meta${context.getName()} getInstance() {
if(INSTANCE == null) {
INSTANCE = new Meta${context.getName()}();
}
return INSTANCE;
}
#set($i = 0)
#foreach($enumAtt in ${context.litterals})
public static final org.kevoree.modeling.meta.KLiteral $enumAtt.toUpperCase() = new org.kevoree.modeling.meta.impl.MetaLiteral("$enumAtt.toUpperCase()",$i,"${context.getFqn()}");
#set($i = $i +1)
#end
#set($i = 1)
public static final org.kevoree.modeling.meta.KLiteral[] values = new org.kevoree.modeling.meta.KLiteral[]{#foreach($enumAtt in ${context.litterals})$enumAtt.toUpperCase()#if($i<${context.litterals.size()}), #end#set($i = $i +1)#end};
public static org.kevoree.modeling.meta.KLiteral valueOf(String s) {
for(int i = 0; i < values.length; i++) {
if(s.equals(values[i].metaName())){
return values[i];
}
}
return null;
}
@Override
public String name() {
return "${context.getFqn()}";
}
@Override
public boolean isEnum() {
return true;
}
@Override
public int id() {
return ${context.index};
}
}
#* @vtlvariable name="context" type="org.kevoree.modeling.ast.MModelEnum" *#