org.jboss.forge.roaster.Roaster Java Examples
The following examples show how to use
org.jboss.forge.roaster.Roaster.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeReflectionProvider.java From Entitas-Java with MIT License | 6 votes |
@Override public List<ComponentInfo> componentInfos() { if (_componentInfos == null || _componentInfos.size() == 0) { Map<String, List<File>> mapFiles = readFileComponents(path); mapFiles.forEach((subDir, files) -> { _componentInfos.addAll(files.stream() .map((file) -> { try { return Roaster.parse(JavaClassSource.class, file); } catch (FileNotFoundException e) { return null; } }).filter((source) -> source != null) .filter((source) -> source.getInterfaces().toString().matches(".*\\bIComponent\\b.*")) .map((source) -> createComponentInfo(source, subDir)) .filter(info -> info != null) .collect(Collectors.toList())); }); } return _componentInfos; }
Example #2
Source File: ComponentLookupGenerator.java From Entitas-Java with MIT License | 6 votes |
private JavaClassSource generateIndicesLookup(String contextName, List<ComponentData> dataList) { String pkgDestiny = targetPackageConfig.getTargetPackage(); JavaClassSource codeGen = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", WordUtils.capitalize(contextName) + DEFAULT_COMPONENT_LOOKUP_TAG)); if (dataList.size() > 0 && !pkgDestiny.endsWith(dataList.get(0).getSubDir()) ) { // pkgDestiny += "." + dataList.get(0).getSubDir(); } codeGen.setPackage(pkgDestiny); addIndices(dataList, codeGen); addComponentNames(dataList, codeGen); addComponentTypes(dataList, codeGen); System.out.println(codeGen); return codeGen; }
Example #3
Source File: MatcherGenerator.java From Entitas-Java with MIT License | 6 votes |
private JavaClassSource generateMatchers(String contextName, List<ComponentInfo> componentInfos, String pkgDestiny) { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", CodeGeneratorOld.capitalize(contextName) + "Matcher")); if (componentInfos.size() > 0 && !pkgDestiny.endsWith(componentInfos.get(0).subDir)) { pkgDestiny += "." + componentInfos.get(0).subDir; } javaClass.setPackage(pkgDestiny); //javaClass.addImport("com.ilargia.games.entitas.interfaces.IMatcher"); javaClass.addImport("Matcher"); for (ComponentInfo info : componentInfos) { addMatcher(contextName, info, javaClass); addMatcherMethods(contextName, info, javaClass); } System.out.println(javaClass); return javaClass; }
Example #4
Source File: TypeReflectionProvider.java From Entitas-Java with MIT License | 6 votes |
@Override public List<ComponentInfo> componentInfos() { if (_componentInfos == null || _componentInfos.size() == 0) { Map<String, List<File>> mapFiles = readFileComponents(path); mapFiles.forEach((subDir, files) -> { _componentInfos.addAll(files.stream() .map((file) -> { try { return Roaster.parse(JavaClassSource.class, file); } catch (FileNotFoundException e) { return null; } }).filter((source) -> source != null) .filter((source) -> source.getInterfaces().toString().matches(".*\\bIComponent\\b.*")) .map((source) -> createComponentInfo(source, subDir)) .filter(info -> info != null) .collect(Collectors.toList())); }); } return _componentInfos; }
Example #5
Source File: ComponentIndicesGenerator.java From Entitas-Java with MIT License | 6 votes |
private JavaClassSource generateIndicesLookup(String poolName, List<ComponentInfo> componentInfos, String pkgDestiny) { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", CodeGeneratorOld.capitalize(poolName) + CodeGeneratorOld.DEFAULT_COMPONENT_LOOKUP_TAG)); // if(componentInfos.size() > 0 && componentInfos.get(0).directory !=null) { // pkgDestiny+= "."+componentInfos.get(0).directory; // // } if (componentInfos.size() > 0 && !pkgDestiny.endsWith(componentInfos.get(0).subDir)) { pkgDestiny += "." + componentInfos.get(0).subDir; } javaClass.setPackage(pkgDestiny); addIndices(componentInfos, javaClass); addComponentNames(componentInfos, javaClass); addComponentTypes(componentInfos, javaClass); System.out.println(javaClass); return javaClass; }
Example #6
Source File: ComponentIndicesGenerator.java From Entitas-Java with MIT License | 6 votes |
public void addComponentFactories(ComponentInfo[] componentInfos, JavaClassSource javaClass) { String format = " %1$s.class,\n"; String code = "return new FactoryComponent[] {"; for (int i = 0; i < componentInfos.length; i++) { ComponentInfo info = componentInfos[i]; JavaInterfaceSource interfaceSource = Roaster.parse(JavaInterfaceSource.class, String.format("public interface Factory%1$s extends FactoryComponent {}", info.typeName)); interfaceSource.addMethod() .setName(String.format("create%1$s", info.typeName)) .setReturnType(info.typeName) .setPublic(); javaClass.addNestedType(interfaceSource.toString()); } }
Example #7
Source File: ComponentIndicesGenerator.java From Entitas-Java with MIT License | 6 votes |
public void addComponentFactories(ComponentInfo[] componentInfos, JavaClassSource javaClass) { String format = " %1$s.class,\n"; String code = "return new FactoryComponent[] {"; for (int i = 0; i < componentInfos.length; i++) { ComponentInfo info = componentInfos[i]; JavaInterfaceSource interfaceSource = Roaster.parse(JavaInterfaceSource.class, String.format("public interface Factory%1$s extends FactoryComponent {}", info.typeName)); interfaceSource.addMethod() .setName(String.format("create%1$s", info.typeName)) .setReturnType(info.typeName) .setPublic(); javaClass.addNestedType(interfaceSource.toString()); } }
Example #8
Source File: ComponentIndicesGenerator.java From Entitas-Java with MIT License | 6 votes |
private JavaClassSource generateIndicesLookup(String poolName, List<ComponentInfo> componentInfos, String pkgDestiny) { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", CodeGeneratorOld.capitalize(poolName) + CodeGeneratorOld.DEFAULT_COMPONENT_LOOKUP_TAG)); // if(componentInfos.size() > 0 && componentInfos.get(0).directory !=null) { // pkgDestiny+= "."+componentInfos.get(0).directory; // // } if (componentInfos.size() > 0 && !pkgDestiny.endsWith(componentInfos.get(0).subDir)) { pkgDestiny += "." + componentInfos.get(0).subDir; } javaClass.setPackage(pkgDestiny); addIndices(componentInfos, javaClass); addComponentNames(componentInfos, javaClass); addComponentTypes(componentInfos, javaClass); System.out.println(javaClass); return javaClass; }
Example #9
Source File: EhDaoGenerator.java From EhViewer with Apache License 2.0 | 6 votes |
private static void adjustQuickSearch() throws Exception { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(QUICK_SEARCH_PATH)); // Set all field public javaClass.getField("id").setPublic(); javaClass.getField("name").setPublic(); javaClass.getField("mode").setPublic(); javaClass.getField("category").setPublic(); javaClass.getField("keyword").setPublic(); javaClass.getField("advanceSearch").setPublic(); javaClass.getField("minRating").setPublic(); javaClass.getField("pageFrom").setPublic(); javaClass.getField("pageTo").setPublic(); javaClass.getField("time").setPublic(); javaClass.addMethod("\t@Override\n" + "\tpublic String toString() {\n" + "\t\treturn name;\n" + "\t}"); FileWriter fileWriter = new FileWriter(QUICK_SEARCH_PATH); fileWriter.write(javaClass.toString()); fileWriter.close(); }
Example #10
Source File: MatcherGenerator.java From Entitas-Java with MIT License | 6 votes |
private JavaClassSource generateMatchers(String contextName, List<ComponentInfo> componentInfos, String pkgDestiny) { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", CodeGeneratorOld.capitalize(contextName) + "Matcher")); if (componentInfos.size() > 0 && !pkgDestiny.endsWith(componentInfos.get(0).subDir)) { pkgDestiny += "." + componentInfos.get(0).subDir; } javaClass.setPackage(pkgDestiny); //javaClass.addImport("ilargia.entitas.interfaces.IMatcher"); javaClass.addImport("Matcher"); for (ComponentInfo info : componentInfos) { addMatcher(contextName, info, javaClass); addMatcherMethods(contextName, info, javaClass); } System.out.println(javaClass); return javaClass; }
Example #11
Source File: EhDaoGenerator.java From MHViewer with Apache License 2.0 | 6 votes |
private static void adjustQuickSearch() throws Exception { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(QUICK_SEARCH_PATH)); // Set all field public javaClass.getField("id").setPublic(); javaClass.getField("name").setPublic(); javaClass.getField("mode").setPublic(); javaClass.getField("category").setPublic(); javaClass.getField("keyword").setPublic(); javaClass.getField("advanceSearch").setPublic(); javaClass.getField("minRating").setPublic(); javaClass.getField("pageFrom").setPublic(); javaClass.getField("pageTo").setPublic(); javaClass.getField("time").setPublic(); javaClass.addMethod("\t@Override\n" + "\tpublic String toString() {\n" + "\t\treturn name;\n" + "\t}"); FileWriter fileWriter = new FileWriter(QUICK_SEARCH_PATH); fileWriter.write(javaClass.toString()); fileWriter.close(); }
Example #12
Source File: CreateTestClassCommand.java From thorntail-addon with Eclipse Public License 1.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); final DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class); if (!isArquillianWildflySwarmDependencyInstalled(dependencyFacet)) { installArquillianWildflySwarmDependency(dependencyFacet); } JavaClassSource test = Roaster.create(JavaClassSource.class) .setPackage(targetPackage.getValue()) .setName(named.getValue()); addArquillianRunner(test); addDefaultDeploymentAnnotation(test, project); addArquillianResourceEnricher(test); addTestMethod(test); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); facet.saveTestJavaSource(test); return Results.success(String.format("Test Class %s.%s was created", targetPackage.getValue(), named.getValue())); }
Example #13
Source File: EntitasGenerator.java From Entitas-Java with MIT License | 5 votes |
public JavaClassSource generateEntitas(Set<String> contextNames, String pkgDestiny) { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, "public class Entitas implements IContexts{}"); javaClass.setPackage(pkgDestiny); createMethodConstructor(javaClass, contextNames); createContextsMethod(javaClass, contextNames); createMethodAllContexts(javaClass, contextNames); createContextFields(javaClass, contextNames); return javaClass; }
Example #14
Source File: SetupFractionsStep.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) { Project project = getSelectedProject(context); ThorntailFacet thorntail = project.getFacet(ThorntailFacet.class); List<FractionDescriptor> installedFractions = thorntail.getInstalledFractions(); if (enableJAXRS(installedFractions)) { JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); JavaClassSource restEndpoint = Roaster.create(JavaClassSource.class) .setPackage(facet.getBasePackage() + ".rest") .setName("HelloWorldEndpoint"); if (hasCDI(installedFractions)) { restEndpoint.addAnnotation(ApplicationScoped.class); } restEndpoint.addAnnotation(Path.class).setStringValue("/hello"); MethodSource<JavaClassSource> method = restEndpoint.addMethod().setPublic().setReturnType(Response.class) .setName("doGet") .setBody("return Response.ok(\"Hello from Thorntail!\").build();"); method.addAnnotation(GET.class); method.addAnnotation(javax.ws.rs.Produces.class).setStringArrayValue(new String[] { MediaType.TEXT_PLAIN }); facet.saveJavaSource(restEndpoint); } if (hasTopologyJgroups(installedFractions)) { ThorntailConfiguration config = thorntail.getConfiguration(); Map<String, String> props = new TreeMap<>(config.getProperties()); props.put("swarm.bind.address", "127.0.0.1"); props.put("java.net.preferIPv4Stack", "true"); props.put("jboss.node.name", "${project.artifactId}"); thorntail.setConfiguration(ThorntailConfigurationBuilder.create(config).properties(props)); } return Results.success(); }
Example #15
Source File: EntityGenerator.java From Entitas-Java with MIT License | 5 votes |
private JavaClassSource generateEntity(String contextName, List<ComponentInfo> infos, String pkgDestiny) { JavaClassSource entityClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$sEntity extends Entity {}", contextName)); if (infos.size() > 0 && !pkgDestiny.endsWith(infos.get(0).subDir)) { pkgDestiny += "." + infos.get(0).subDir; } entityClass.setPackage(pkgDestiny); entityClass.addMethod() .setName(contextName + "Entity") .setPublic() .setConstructor(true) .setBody(""); entityClass.addImport("ilargia.entitas.api.*"); entityClass.addImport("Entity"); entityClass.addImport("java.util.Stack"); for (ComponentInfo info : infos) { if (info.generateMethods) { addImporEnums(info, entityClass); addEntityMethods(contextName, info, entityClass); } } System.out.println(Roaster.format(entityClass.toString())); return entityClass; }
Example #16
Source File: EntityGenerator.java From Entitas-Java with MIT License | 5 votes |
private JavaClassSource generateMatchers(String contextName, List<ComponentInfo> componentInfos, String pkgDestiny) { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", CodeGeneratorOld.capitalize(contextName) + "Matcher")); javaClass.setPackage(pkgDestiny); //javaClass.addImport("ilargia.entitas.interfaces.IMatcher"); javaClass.addImport("Matcher"); for (ComponentInfo info : componentInfos) { addMatcher(contextName, info, javaClass); addMatcherMethods(contextName, info, javaClass); } System.out.println(javaClass); return javaClass; }
Example #17
Source File: ContextGenerator.java From Entitas-Java with MIT License | 5 votes |
private JavaClassSource generateContext(String contextName, List<ComponentInfo> infos, String pkgDestiny) { JavaClassSource contextClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$sContext extends Context<%1$sEntity> {}", contextName)); // if(infos.size() > 0 && infos.get(0).directory !=null) { // pkgDestiny+= "."+infos.get(0).directory; // // } if (infos.size() > 0 && !pkgDestiny.endsWith(infos.get(0).subDir)) { pkgDestiny += "." + infos.get(0).subDir; } contextClass.setPackage(pkgDestiny); contextClass.addMethod() .setName(contextName + "Context") .setPublic() .setConstructor(true) .setParameters(String.format("int totalComponents, int startCreationIndex, ContextInfo contextInfo, EntityBaseFactory<%1$sEntity> factoryMethod", contextName)) .setBody("super(totalComponents, startCreationIndex, contextInfo, factoryMethod);"); contextClass.addImport("ilargia.entitas.api.*"); for (ComponentInfo info : infos) { if (info.isSingleEntity) { addContextMethods(contextName, info, contextClass); } } return contextClass; }
Example #18
Source File: ProviderUtils.java From Entitas-Java with MIT License | 5 votes |
public static List<ComponentData> getComponentDatas(IAppDomain appDomain, List<String> packages) { List<ComponentData> datas = new ArrayList<>(); appDomain.getSrcDirs().forEach(path -> { packages.forEach(p -> { String pkg= ""; if(System.getProperty("os.name").toLowerCase().contains("win")) { pkg = p.replace(".", "\\"); } else { pkg = p.replace(".", "/"); } String finalPkg = pkg; Map<String, List<File>> mapFiles = CodeGeneratorUtil.readFileComponents(path, finalPkg); mapFiles.forEach((subDir, files) -> { datas.addAll(files.stream() .filter(f -> { return f.getAbsolutePath().contains(finalPkg); }) .map((file) -> { try { return Roaster.parse(JavaClassSource.class, file); } catch (FileNotFoundException e) { return null; } }).filter((source) -> source != null) .map((source) -> new ComponentData(source, subDir)) .filter(info -> info != null) .collect(Collectors.toList())); }); }); }); return datas.stream().sorted((a, b)-> a.getSource().getName().compareTo(b.getSource().getName())).collect(Collectors.toList()); }
Example #19
Source File: ComponentMatcherGenerator.java From Entitas-Java with MIT License | 5 votes |
private CodeGenFile<JavaClassSource> getCodeGenFile(String contextName, ComponentData data) { if (contexts.containsKey(contextName)) { return contexts.get(contextName); } else { JavaClassSource sourceGen = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", WordUtils.capitalize(contextName) + "Matcher")); CodeGenFile<JavaClassSource> genFile = new CodeGenFile<JavaClassSource>(contextName + "Matcher", sourceGen, data.getSubDir()); contexts.put(contextName, genFile); return genFile; } }
Example #20
Source File: ComponentEntityGenerator.java From Entitas-Java with MIT License | 5 votes |
private CodeGenFile<JavaClassSource> getCodeGenFile(String contextName, ComponentData data) { if (entities.containsKey(contextName)) { return entities.get(contextName); } else { JavaClassSource sourceGen = Roaster.parse(JavaClassSource.class, String.format("public class %1$sEntity extends Entity {}", contextName)); CodeGenFile<JavaClassSource> genFile = new CodeGenFile<JavaClassSource>(contextName + "Entity", sourceGen, data.getSubDir()); entities.put(contextName, genFile); return genFile; } }
Example #21
Source File: EntitasGenerator.java From Entitas-Java with MIT License | 5 votes |
private CodeGenFile<JavaClassSource> generateEntitas(Set<String> contextNames, String pkgDestiny) { JavaClassSource sourceGen = Roaster.parse(JavaClassSource.class, "public class Entitas implements IContexts{}"); CodeGenFile<JavaClassSource> genFile = new CodeGenFile<JavaClassSource>( "Entitas", sourceGen, ""); sourceGen.setPackage(pkgDestiny); createMethodConstructor(sourceGen, contextNames); createContextsMethod(sourceGen, contextNames); createMethodAllContexts(sourceGen, contextNames); createContextFields(sourceGen, contextNames); System.out.println(genFile.getFileContent()); return genFile; }
Example #22
Source File: ComponentContextGenerator.java From Entitas-Java with MIT License | 5 votes |
private void generateContext(String contextName, ComponentData data) { String pkgDestiny = targetPackageConfig.getTargetPackage(); if (!contexts.containsKey(contextName)) { JavaClassSource sourceGen = Roaster.parse(JavaClassSource.class, String.format("public class %1$sContext extends Context<%1$sEntity> {}", contextName)); CodeGenFile<JavaClassSource> genFile = new CodeGenFile<JavaClassSource>(contextName + "Context", sourceGen, data.getSubDir()); contexts.put(contextName, genFile); JavaClassSource codeGenerated = genFile.getFileContent(); if (!pkgDestiny.endsWith(data.getSubDir())) { pkgDestiny += "." + data.getSubDir(); } codeGenerated.setPackage(pkgDestiny); codeGenerated.addMethod() .setName(contextName + "Context") .setPublic() .setConstructor(true) .setParameters(String.format("int totalComponents, int startCreationIndex, ContextInfo contextInfo, EntityBaseFactory<%1$sEntity> factoryMethod", contextName)) .setBody("super(totalComponents, startCreationIndex, contextInfo, factoryMethod, null);"); codeGenerated.addImport("ilargia.entitas.Context"); codeGenerated.addImport("ilargia.entitas.api.*"); codeGenerated.addImport("ilargia.entitas.api.entitas.EntityBaseFactory"); if (isUnique(data)) { addContextMethods(contextName, data, codeGenerated); } } }
Example #23
Source File: ContextGenerator.java From Entitas-Java with MIT License | 5 votes |
private JavaClassSource generateContext(String contextName, List<ComponentInfo> infos, String pkgDestiny) { JavaClassSource contextClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$sContext extends Context<%1$sEntity> {}", contextName)); // if(infos.size() > 0 && infos.get(0).directory !=null) { // pkgDestiny+= "."+infos.get(0).directory; // // } if (infos.size() > 0 && !pkgDestiny.endsWith(infos.get(0).subDir)) { pkgDestiny += "." + infos.get(0).subDir; } contextClass.setPackage(pkgDestiny); contextClass.addMethod() .setName(contextName + "Context") .setPublic() .setConstructor(true) .setParameters(String.format("int totalComponents, int startCreationIndex, ContextInfo contextInfo, EntityBaseFactory<%1$sEntity> factoryMethod", contextName)) .setBody("super(totalComponents, startCreationIndex, contextInfo, factoryMethod);"); contextClass.addImport("com.ilargia.games.entitas.api.*"); for (ComponentInfo info : infos) { if (info.isSingleEntity) { addContextMethods(contextName, info, contextClass); } } return contextClass; }
Example #24
Source File: EntityGenerator.java From Entitas-Java with MIT License | 5 votes |
private JavaClassSource generateMatchers(String contextName, List<ComponentInfo> componentInfos, String pkgDestiny) { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", CodeGeneratorOld.capitalize(contextName) + "Matcher")); javaClass.setPackage(pkgDestiny); //javaClass.addImport("com.ilargia.games.entitas.interfaces.IMatcher"); javaClass.addImport("Matcher"); for (ComponentInfo info : componentInfos) { addMatcher(contextName, info, javaClass); addMatcherMethods(contextName, info, javaClass); } System.out.println(javaClass); return javaClass; }
Example #25
Source File: EntityGenerator.java From Entitas-Java with MIT License | 5 votes |
private JavaClassSource generateEntity(String contextName, List<ComponentInfo> infos, String pkgDestiny) { JavaClassSource entityClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$sEntity extends Entity {}", contextName)); if (infos.size() > 0 && !pkgDestiny.endsWith(infos.get(0).subDir)) { pkgDestiny += "." + infos.get(0).subDir; } entityClass.setPackage(pkgDestiny); entityClass.addMethod() .setName(contextName + "Entity") .setPublic() .setConstructor(true) .setBody(""); entityClass.addImport("com.ilargia.games.entitas.api.*"); entityClass.addImport("Entity"); entityClass.addImport("java.util.Stack"); for (ComponentInfo info : infos) { if (info.generateMethods) { addImporEnums(info, entityClass); addEntityMethods(contextName, info, entityClass); } } System.out.println(Roaster.format(entityClass.toString())); return entityClass; }
Example #26
Source File: EntitasGenerator.java From Entitas-Java with MIT License | 5 votes |
public JavaClassSource generateEntitas(Set<String> contextNames, String pkgDestiny) { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, "public class Entitas implements IContexts{}"); javaClass.setPackage(pkgDestiny); createMethodConstructor(javaClass, contextNames); createContextsMethod(javaClass, contextNames); createMethodAllContexts(javaClass, contextNames); createContextFields(javaClass, contextNames); return javaClass; }
Example #27
Source File: RoasterSimpleRouteBuilderConfigureTest.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Test public void parse() throws Exception { JavaClassSource clazz = (JavaClassSource) Roaster.parse(new File("src/test/java/io/fabric8/forge/camel/java/MySimpleRouteBuilder.java")); MethodSource<JavaClassSource> method = clazz.getMethod("configure"); List<ParserResult> list = CamelJavaParserHelper.parseCamelSimpleExpressions(method); for (ParserResult simple : list) { System.out.println("Simple: " + simple.getElement()); System.out.println(" Line: " + findLineNumber(simple.getPosition())); } Assert.assertEquals("${body} > 100", list.get(0).getElement()); Assert.assertEquals(26, findLineNumber(list.get(0).getPosition())); Assert.assertEquals("${body} > 200", list.get(1).getElement()); Assert.assertEquals(29, findLineNumber(list.get(1).getPosition())); }
Example #28
Source File: EndpointDiagnosticService.java From camel-language-server with Apache License 2.0 | 5 votes |
private List<CamelEndpointDetails> retrieveEndpoints(String uri, String camelText) { List<CamelEndpointDetails> endpoints = new ArrayList<>(); if (uri.endsWith(".xml")) { try { XmlRouteParser.parseXmlRouteEndpoints(new ByteArrayInputStream(camelText.getBytes(StandardCharsets.UTF_8)), "", "/"+uri, endpoints); } catch (Exception e) { logExceptionValidatingDocument(uri, e); } } else if(uri.endsWith(".java")) { JavaClassSource clazz = (JavaClassSource) Roaster.parse(camelText); RouteBuilderParser.parseRouteBuilderEndpoints(clazz, "", "/"+uri, endpoints); } return endpoints; }
Example #29
Source File: EhDaoGenerator.java From MHViewer with Apache License 2.0 | 5 votes |
private static void adjustFilter() throws Exception { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(FILTER_PATH)); // Set field public javaClass.getField("mode").setPublic(); javaClass.getField("text").setPublic(); javaClass.getField("enable").setPublic(); // Add hashCode method and equals method javaClass.addImport("com.hippo.util.HashCodeUtils"); javaClass.addMethod("\t@Override\n" + "\tpublic int hashCode() {\n" + "\t\treturn HashCodeUtils.hashCode(mode, text);\n" + "\t}"); javaClass.addImport("com.hippo.yorozuya.ObjectUtils"); javaClass.addMethod("\t@Override\n" + "\tpublic boolean equals(Object o) {\n" + "\t\tif (!(o instanceof Filter)) {\n" + "\t\t\treturn false;\n" + "\t\t}\n" + "\n" + "\t\tFilter filter = (Filter) o;\n" + "\t\treturn filter.mode == mode && ObjectUtils.equal(filter.text, text);\n" + "\t}"); FileWriter fileWriter = new FileWriter(FILTER_PATH); fileWriter.write(javaClass.toString()); fileWriter.close(); }
Example #30
Source File: EhDaoGenerator.java From EhViewer with Apache License 2.0 | 5 votes |
private static void adjustFilter() throws Exception { JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(FILTER_PATH)); // Set field public javaClass.getField("mode").setPublic(); javaClass.getField("text").setPublic(); javaClass.getField("enable").setPublic(); // Add hashCode method and equals method javaClass.addImport("com.hippo.util.HashCodeUtils"); javaClass.addMethod("\t@Override\n" + "\tpublic int hashCode() {\n" + "\t\treturn HashCodeUtils.hashCode(mode, text);\n" + "\t}"); javaClass.addImport("com.hippo.yorozuya.ObjectUtils"); javaClass.addMethod("\t@Override\n" + "\tpublic boolean equals(Object o) {\n" + "\t\tif (!(o instanceof Filter)) {\n" + "\t\t\treturn false;\n" + "\t\t}\n" + "\n" + "\t\tFilter filter = (Filter) o;\n" + "\t\treturn filter.mode == mode && ObjectUtils.equal(filter.text, text);\n" + "\t}"); FileWriter fileWriter = new FileWriter(FILTER_PATH); fileWriter.write(javaClass.toString()); fileWriter.close(); }