@Test public void basicTest() throws Exception { final StringBuilder data = new StringBuilder(); final EmitterExtension.Writer writer = new EmitterExtension.Writer() { @Override public void writeIndentedLine(String line) { data.append(line + "\n"); } }; final Settings settings = new Settings(); settings.sortDeclarations = true; final TypeProcessor typeProcessor = new DefaultTypeProcessor(); final Model model = new Jackson2Parser(settings, typeProcessor).parseModel(ClassA.class); final TsModel tsModel = new ModelCompiler(settings, typeProcessor).javaToTypeScript(model); new BeanPropertyPathExtension().emitElements(writer, settings, false, tsModel); String dataStr = data.toString(); final String expected = Utils.readString(getClass().getResourceAsStream("/ext/expected.ts"), "\n"); Assert.assertEquals(expected.trim(), dataStr.trim()); }
@Override public void emitElements(Writer writer, Settings settings, boolean exportKeyword, TsModel model) { emitFieldsClass(writer, settings); Set<TsBeanModel> emittedBeans = new HashSet<>(); for (TsBeanModel bean : model.getBeans()) { emittedBeans.addAll( writeBeanAndParentsFieldSpecs(writer, settings, model, emittedBeans, bean)); } for (TsBeanModel bean : model.getBeans()) { createBeanFieldConstant(writer, exportKeyword, bean); } }
BeanPropertyPathExtension extends EmitterExtension { @Override public void emitElements(Writer writer, Settings settings, boolean exportKeyword, TsModel model) { emitFieldsClass(writer, settings); Set<TsBeanModel> emittedBeans = new HashSet<>(); for (TsBeanModel bean : model.getBeans()) { emittedBeans.addAll( writeBeanAndParentsFieldSpecs(writer, settings, model, emittedBeans, bean)); } for (TsBeanModel bean : model.getBeans()) { createBeanFieldConstant(writer, exportKeyword, bean); } } }
BeanPropertyPathExtension extends EmitterExtension { @Override public void emitElements(Writer writer, Settings settings, boolean exportKeyword, TsModel model) { emitFieldsClass(writer, settings); Set<TsBeanModel> emittedBeans = new HashSet<>(); for (TsBeanModel bean : model.getBeans()) { emittedBeans.addAll( writeBeanAndParentsFieldSpecs(writer, settings, model, emittedBeans, bean)); } for (TsBeanModel bean : model.getBeans()) { createBeanFieldConstant(writer, exportKeyword, bean); } }  }
BeanPropertyPathExtension extends EmitterExtension { @Override public void emitElements(Writer writer, Settings settings, boolean exportKeyword, TsModel model) { emitFieldsClass(writer, settings); Set<TsBeanModel> emittedBeans = new HashSet<>(); for (TsBeanModel bean : model.getBeans()) { emittedBeans.addAll( writeBeanAndParentsFieldSpecs(writer, settings, model, emittedBeans, bean)); } for (TsBeanModel bean : model.getBeans()) { createBeanFieldConstant(writer, exportKeyword, bean); } }  @Override EmitterExtensionFeatures getFeatures(); @Override void emitElements(Writer writer, Settings settings, boolean exportKeyword, TsModel model); }
BeanPropertyPathExtension extends EmitterExtension { @Override public void emitElements(Writer writer, Settings settings, boolean exportKeyword, TsModel model) { emitFieldsClass(writer, settings); Set<TsBeanModel> emittedBeans = new HashSet<>(); for (TsBeanModel bean : model.getBeans()) { emittedBeans.addAll( writeBeanAndParentsFieldSpecs(writer, settings, model, emittedBeans, bean)); } for (TsBeanModel bean : model.getBeans()) { createBeanFieldConstant(writer, exportKeyword, bean); } }  @Override EmitterExtensionFeatures getFeatures(); @Override void emitElements(Writer writer, Settings settings, boolean exportKeyword, TsModel model);  }