Search in sources :

Example 1 with TsModelTransformer

use of cz.habarta.typescript.generator.compiler.TsModelTransformer in project openremote by openremote.

the class CustomExtension method getTransformers.

@Override
public List<TransformerDefinition> getTransformers() {
    return Arrays.asList(new TransformerDefinition(ModelCompiler.TransformationPhase.BeforeEnums, (TsModelTransformer) (context, model) -> {
        // Special processing for AssetModelInfo meta item value descriptors as JsonSerialize extension doesn't support
        // @JsonSerialize(contentConverter=...)
        TsBeanModel assetTypeInfoBean = model.getBean(AssetTypeInfo.class);
        if (assetTypeInfoBean != null) {
            assetTypeInfoBean.getProperties().replaceAll(p -> p.getName().equals("metaItemDescriptors") || p.getName().equals("valueDescriptors") ? new TsPropertyModel(p.getName(), new TsType.BasicArrayType(TsType.String), p.modifiers, p.ownProperty, p.comments) : p);
        }
        Constants.IGNORE_TYPE_PARAMS_ON_CLASSES.forEach(beanClass -> {
            TsBeanModel bean = model.getBean(beanClass);
            if (bean != null && bean.getTypeParameters() != null) {
                // Remove the type parameter - this works in conjunction with the CustomTypeProcessor which replaces
                // field references
                bean.getTypeParameters().clear();
            }
        });
        return model;
    }));
}
Also used : TsPropertyModel(cz.habarta.typescript.generator.emitter.TsPropertyModel) TsType(cz.habarta.typescript.generator.TsType) TsBeanModel(cz.habarta.typescript.generator.emitter.TsBeanModel) TsModelTransformer(cz.habarta.typescript.generator.compiler.TsModelTransformer)

Aggregations

TsType (cz.habarta.typescript.generator.TsType)1 TsModelTransformer (cz.habarta.typescript.generator.compiler.TsModelTransformer)1 TsBeanModel (cz.habarta.typescript.generator.emitter.TsBeanModel)1 TsPropertyModel (cz.habarta.typescript.generator.emitter.TsPropertyModel)1