Search in sources :

Example 1 with TSEnumType

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;
}
Also used : TSEnumLiteral(io.crnk.gen.typescript.model.TSEnumLiteral) TSSource(io.crnk.gen.typescript.model.TSSource) MetaEnumType(io.crnk.meta.model.MetaEnumType) TSEnumType(io.crnk.gen.typescript.model.TSEnumType)

Aggregations

TSEnumLiteral (io.crnk.gen.typescript.model.TSEnumLiteral)1 TSEnumType (io.crnk.gen.typescript.model.TSEnumType)1 TSSource (io.crnk.gen.typescript.model.TSSource)1 MetaEnumType (io.crnk.meta.model.MetaEnumType)1