public JType generate(JCodeModel codeModel, String className, String packageName, String json, URI schemaLocation) throws IOException { JPackage jpackage = codeModel._package(packageName); JsonNode schemaNode = objectMapper().readTree(json); return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(schemaLocation, schemaNode, null)); }
public JType generate(JCodeModel codeModel, String className, String packageName, String json) throws IOException { JPackage jpackage = codeModel._package(packageName); JsonNode schemaNode = null; if (ruleFactory.getGenerationConfig().getSourceType() == SourceType.JSON) { JsonNode jsonNode = objectMapper().readTree(json); schemaNode = schemaGenerator.schemaFromExample(jsonNode); } else { schemaNode = objectMapper().readTree(json); } return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(null, schemaNode, null)); }
/** * Reads a schema and adds generated types to the given code model. * * @param codeModel * the java code-generation context that should be used to * generated new types * @param className * the name of the parent class the represented by this schema * @param packageName * the target package that should be used for generated types * @param schemaUrl * location of the schema to be used as input * @return The top-most type generated from the given file * @throws IOException * if the schema content cannot be read */ public JType generate(JCodeModel codeModel, String className, String packageName, URL schemaUrl) { JPackage jpackage = codeModel._package(packageName); ObjectNode schemaNode = readSchema(schemaUrl); return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(null, schemaNode, null)); }
public JPackage _package() { String name = fullName(); // this type is array if (name.indexOf('[') != -1) return JCodeModel.this._package(""); // other normal case int idx = name.lastIndexOf('.'); if (idx < 0) return JCodeModel.this._package(""); else return JCodeModel.this._package(name.substring(0, idx)); }
/** * Gets the parent package, or null if this class is the root package. */ public JPackage parent() { if(name.length()==0) return null; int idx = name.lastIndexOf('.'); return owner._package(name.substring(0,idx)); }
public JPackage _package() { String name = fullName(); // this type is array if (name.indexOf('[') != -1) return JCodeModel.this._package(""); // other normal case int idx = name.lastIndexOf('.'); if (idx < 0) return JCodeModel.this._package(""); else return JCodeModel.this._package(name.substring(0, idx)); }
public JPackage _package() { String name = fullName(); // this type is array if (name.indexOf('[') != -1) return JCodeModel.this._package(""); // other normal case int idx = name.lastIndexOf('.'); if (idx < 0) return JCodeModel.this._package(""); else return JCodeModel.this._package(name.substring(0, idx)); }
/** * Gets the parent package, or null if this class is the root package. */ public JPackage parent() { if(name.length()==0) return null; int idx = name.lastIndexOf('.'); return owner._package(name.substring(0,idx)); }
/** * Gets the parent package, or null if this class is the root package. */ public JPackage parent() { if(name.length()==0) return null; int idx = name.lastIndexOf('.'); return owner._package(name.substring(0,idx)); }
public JPackage _package() { int i = fullName.lastIndexOf('.'); if(i>=0) return owner()._package(fullName.substring(0,i)); else return owner().rootPackage(); }
public void marshallPersistence(JCodeModel codeModel, Persistence persistence) throws Exception { // final JPackage defaultPackage = codeModel._package(""); final JPackage metaInfPackage = codeModel._package("META-INF"); final JTextFile persistenceXmlFile = new JTextFile("persistence.xml"); metaInfPackage.addResourceFile(persistenceXmlFile); final Writer writer = new StringWriter(); getMarshaller().marshal(persistence, writer); persistenceXmlFile.setContents(writer.toString()); } }
public void marshallPersistence(JCodeModel codeModel, Persistence persistence) throws Exception { // final JPackage defaultPackage = codeModel._package(""); final JPackage metaInfPackage = codeModel._package("META-INF"); final JTextFile persistenceXmlFile = new JTextFile("persistence.xml"); metaInfPackage.addResourceFile(persistenceXmlFile); final Writer writer = new StringWriter(); getMarshaller().marshal(persistence, writer); persistenceXmlFile.setContents(writer.toString()); } }
public JType generate(JCodeModel codeModel, String className, String packageName, String json, URI schemaLocation) throws IOException { JPackage jpackage = codeModel._package(packageName); JsonNode schemaNode = objectMapper().readTree(json); return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(schemaLocation, schemaNode, null)); }
public JType generate(JCodeModel codeModel, String className, String packageName, String json) throws IOException { JPackage jpackage = codeModel._package(packageName); JsonNode schemaNode = null; if (ruleFactory.getGenerationConfig().getSourceType() == SourceType.JSON) { JsonNode jsonNode = objectMapper().readTree(json); schemaNode = schemaGenerator.schemaFromExample(jsonNode); } else { schemaNode = objectMapper().readTree(json); } return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(null, schemaNode, null)); }
@Override public void visit(Service service) throws Exception { String jd = model.getJavaDoc(); if(jd != null){ JPackage pkg = cm._package(options.defaultPackage); pkg.javadoc().add(jd); } for(Port p:service.getPorts()){ visitPort(service, p); } }
@Override public void visit(Service service) throws Exception { String jd = model.getJavaDoc(); if(jd != null){ JPackage pkg = cm._package(options.defaultPackage); pkg.javadoc().add(jd); } for(Port p:service.getPorts()){ visitPort(service, p); } }
public void generate(String packageName, File destDir, PrintStream status) throws Exception { JCodeModel cm = new JCodeModel(); JPackage jpackage = cm._package(packageName); JDefinedClass maduraResourceComponent = jpackage._class("MaduraResourceComponent"); JAnnotationUse annotationUse = maduraResourceComponent.annotate(org.springframework.stereotype.Component.class); annotationUse.param("value", maduraResourceComponent.fullName()); annotationUse = maduraResourceComponent.annotate(MessageResource.class); annotationUse.param("value", "messages"); // JFieldVar serialVersionUIDField = maduraResourceComponent.field(JMod.FINAL|JMod.PRIVATE|JMod.STATIC, long.class, "serialVersionUID"); // serialVersionUIDField.init(JExpr.lit(1L)); cm.build(destDir, status); }