JCodeModel cm = new JCodeModel(); JDefinedClass dc = cm._class("foo.Bar"); JMethod m = dc.method(0, int.class, "foo"); m.body()._return(JExpr.lit(5)); File file = new File("./target/classes"); file.mkdirs(); cm.build(file);
JCodeModel codeModel = new JCodeModel();
JCodeModel codeModel = new JCodeModel();
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { cm = new JCodeModel(); for (TypeElement annotation : annotations) { for(javax.lang.model.element.Element d : roundEnv.getElementsAnnotatedWith(annotation)) { d.accept(visitor, null); } try { cm.build(new FilerCodeWriter(processingEnv.getFiler())); } catch (IOException e) { throw new Error(e); } } return true; }
public Kickstartr(AppDetails appDetails) { this.appDetails = appDetails; jCodeModel = new JCodeModel(); fileHelper = new FileHelper(appDetails.getName(), appDetails.getPackageName(), appDetails.isMaven()); extractResources(appDetails); }
private void annotateMetatadataValidator(JDefinedClass clazz) { if (clazz.name().equals("PodTemplateSpec")) { return; } for (Map.Entry<String, JFieldVar> f : clazz.fields().entrySet()) { if (f.getKey().equals("metadata") && f.getValue().type().name().equals("ObjectMeta")) { try { JAnnotationUse annotation = f.getValue().annotate(new JCodeModel()._class("io.fabric8.kubernetes.api.model.validators.CheckObjectMeta")); if (isMinimal(clazz)) { annotation.param("minimal", true); } else { annotation .param("regexp", "^" + getObjectNamePattern(clazz) + "$") .param("max", getObjectNameMaxLength(clazz)); } } catch (JClassAlreadyExistsException e) { e.printStackTrace(); } return; } } }
.param("builderPackage", "io.fabric8.kubernetes.api.builder") .annotationParam("inline", Inline.class) .param("type", new JCodeModel()._class("io.fabric8.kubernetes.api.model.Doneable")) .param("prefix", "Doneable") .param("value", "done");
public WebRepositoryBuilder(ProcessingEnvironment processingEnv, Set<TypeElement> webSiteElements, Set<TypeElement> webPageElements, Set<TypeElement> webRepositoryElements, Set<TypeElement> otherElements) { this.processingEnv = processingEnv; this.webSiteElements = webSiteElements; this.webPageElements = webPageElements; this.webRepositoryElements = webRepositoryElements; this.otherElements = otherElements; this.codeModel = new JCodeModel(); }
@Override protected void processWebService(WebService webService, TypeElement d) { cm = new JCodeModel(); wrapperNames = new HashSet<String>(); processedExceptions = new HashSet<String>(); }
@Override protected void processWebService(WebService webService, TypeElement d) { cm = new JCodeModel(); wrapperNames = new HashSet<String>(); processedExceptions = new HashSet<String>(); }
JCodeModel codeModel = new JCodeModel(); JDefinedClass bull = codeModel._class(JMod.PUBLIC, "com.Bull", ClassType.INTERFACE); System.out.println("is interface " + bull.isInterface()); codeModel.build(new File("/home/user")); System.out.println("done!"); BufferedReader br = new BufferedReader(new FileReader("/home/user/com/Bull.java")); String line = null; while ((line = br.readLine()) != null) { System.out.println(line); }
protected Model loadModel(Options options) throws MojoExecutionException { if (getVerbose()) { getLog().info("Parsing input schema(s)..."); } final Model model = ModelLoader.load(options, new JCodeModel(), new LoggingErrorReceiver("Error while parsing schema(s).", getLog(), getVerbose())); if (model == null) throw new MojoExecutionException( "Unable to parse input schema(s). Error messages should have been provided."); return model; }
protected Model loadModel(Options options) throws MojoExecutionException { if (getVerbose()) { getLog().info("Parsing input schema(s)..."); } final Model model = ModelLoader.load(options, new JCodeModel(), new LoggingErrorReceiver("Error while parsing schema(s).", getLog(), getVerbose())); if (model == null) throw new MojoExecutionException( "Unable to parse input schema(s). Error messages should have been provided."); return model; }
protected Model loadModel(Options options) throws MojoExecutionException { if (getVerbose()) { getLog().info("Parsing input schema(s)..."); } final Model model = ModelLoader.load(options, new JCodeModel(), new LoggingErrorReceiver("Error while parsing schema(s).", getLog(), getVerbose())); if (model == null) throw new MojoExecutionException( "Unable to parse input schema(s). Error messages should have been provided."); return model; }
protected Model loadModel(Options options) throws MojoExecutionException { if (getVerbose()) { getLog().info("Parsing input schema(s)..."); } final Model model = ModelLoader.load(options, new JCodeModel(), new LoggingErrorReceiver("Error while parsing schema(s).", getLog(), getVerbose())); if (model == null) throw new MojoExecutionException( "Unable to parse input schema(s). Error messages should have been provided."); return model; }
protected Model loadModel(Options options) throws MojoExecutionException { if (getVerbose()) { getLog().info("Parsing input schema(s)..."); } final Model model = ModelLoader.load(options, new JCodeModel(), new LoggingErrorReceiver("Error while parsing schema(s).", getLog(), getVerbose())); if (model == null) throw new MojoExecutionException( "Unable to parse input schema(s). Error messages should have been provided."); return model; }
protected Model loadModel(Options options) throws MojoExecutionException { if (getVerbose()) { getLog().info("Parsing input schema(s)..."); } final Model model = ModelLoader.load(options, new JCodeModel(), new LoggingErrorReceiver("Error while parsing schema(s).", getLog(), getVerbose())); if (model == null) throw new MojoExecutionException( "Unable to parse input schema(s). Error messages should have been provided."); return model; }
private void generateControllerSource(JCodeModel codeModel, ApiResourceMetadata met, File dir) { boolean build = false; if (codeModel == null) { codeModel = new JCodeModel(); build = true; } loadRule().apply(met, codeModel); if (build) { buildCodeModelToDisk(codeModel, met.getName(), dir); } }
JCodeModel model = new JCodeModel(); JClass mapper = model.directClass("com.another.Mapper"); JClass factory = model.directClass("com.another.MapperSingleton"); JDefinedClass dc = model._class("com.example.Something"); JMethod method = dc.method(JMod.PUBLIC | JMod.STATIC, mapper, "testMethod"); method.body()._return(factory.staticInvoke("getMapperInstance")); model.build(destinationDirectory);
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); }