use of io.crnk.gen.typescript.model.TSEnumType in project crnk-framework by crnk-project.
the class TSMetaEnumTypeTransformation method transform.
@Override
public TSElement transform(MetaElement elementObj, TSMetaTransformationContext context, TSMetaTransformationOptions options) {
MetaEnumType element = (MetaEnumType) elementObj;
TSSource source = new TSSource();
source.setName(TypescriptUtils.toFileName(element.getName()));
source.setNpmPackage(context.getNpmPackage(element));
source.setDirectory(context.getDirectory(element));
Class<?> implementationClass = element.getImplementationClass();
TSEnumType enumType = new TSEnumType();
enumType.setExported(true);
enumType.setParent(source);
enumType.setName(element.getName());
for (Object literal : implementationClass.getEnumConstants()) {
enumType.getLiterals().add(new TSEnumLiteral(literal.toString()));
}
source.getElements().add(enumType);
context.putMapping(element, enumType);
context.addSource(source);
return enumType;
}
Aggregations