• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JavaSourceFacet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.forge.addon.parser.java.facets.JavaSourceFacet的典型用法代码示例。如果您正苦于以下问题:Java JavaSourceFacet类的具体用法?Java JavaSourceFacet怎么用?Java JavaSourceFacet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JavaSourceFacet类属于org.jboss.forge.addon.parser.java.facets包,在下文中一共展示了JavaSourceFacet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createCRUDRepository

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
private void createCRUDRepository(JavaClassSource entitySource, Project project) {
   // build interface declaration
   final String name = entitySource.getName();
   final String idFieldType = entitySource.getFields().stream()
         .filter(field -> field.hasAnnotation(Id.class))
         .findFirst()
         .orElseThrow(IllegalArgumentException::new)
         .getType()
         .getSimpleName();
   final String repoInterfaceDeclaration = "public interface " + name
            + "Repository extends PagingAndSortingRepository<"
         + name + "," + idFieldType + "> {}";

   JavaInterfaceSource repoSource = Roaster.parse(JavaInterfaceSource.class, repoInterfaceDeclaration)
         .setPackage(entitySource.getPackage());
   repoSource.addImport("org.springframework.data.repository.PagingAndSortingRepository");
   Roaster.format(repoSource.toString());

   // Create Java Classes Greeting and GreetingProperties
   JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
   facet.saveJavaSource(repoSource);
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:23,代码来源:CreateSpringBootJPASupportDecorator.java


示例2: modifyJavaClass

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
public static void modifyJavaClass(Project project, String className, Optional<String> packageName,
                                   JavaClassSourceDecorator decorator) {

   final String packageLocation = packageName.orElseGet(() -> project.getFacet(MetadataFacet.class).getProjectGroupName());
   final JavaSourceFacet sourceFacet = project.getFacet(JavaSourceFacet.class);
   final DirectoryResource targetPackage = sourceFacet.getPackage(packageLocation);

   final JavaResource sbAppResource = targetPackage.getChild(className).as(JavaResource.class);
   if (sbAppResource.exists()) {
      JavaClassSource sbApp = Roaster.parse(JavaClassSource.class, sbAppResource.getResourceInputStream());

      decorator.modify(sbApp);

      sourceFacet.saveJavaSource(sbApp);
   }
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:17,代码来源:SpringBootHelper.java


示例3: initializeUI

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public void initializeUI(final UIBuilder builder) throws Exception {
    super.initializeUI(builder);

    Project project = getCurrentSelectedProject(builder.getUIContext());
    if (project.hasFacet(JavaSourceFacet.class)) {
        JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
        targetPackage.setCompleter(new TestPackageNameCompleter(facet));
    }
    targetPackage.addValidator(new PackageNameValidator());
    targetPackage.setDefaultValue("io.fabric8.itests");

    className.addValidator(new ClassNameValidator(false));
    className.setDefaultValue(new Callable<String>() {
        @Override
        public String call() throws Exception {
            return "IntegrationTestKT";
        }
    });

    builder.add(targetPackage).add(className).add(profile).add(integrationTestWildcard).add(itestPlugin);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:23,代码来源:NewIntegrationTestClassCommand.java


示例4: TestPackageNameCompleter

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
public TestPackageNameCompleter(JavaSourceFacet facet) {
    // find package names in the source code
    facet.visitJavaTestSources(new JavaResourceVisitor() {
        @Override
        public void visit(VisitContext context, JavaResource javaResource) {
            try {
                // avoid package-info.java files
                if (!javaResource.getName().contains("package-info")) {
                    JavaClass clazz = javaResource.getJavaType();
                    String packageName = clazz.getPackage();
                    if (packageName != null && !packageNames.contains(packageName)) {
                        packageNames.add(packageName);
                    }
                }
            } catch (FileNotFoundException e) {
                // ignore
            }
        }
    });
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:21,代码来源:TestPackageNameCompleter.java


示例5: PackageNameCompleter

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
public PackageNameCompleter(JavaSourceFacet facet) {
    // find package names in the source code
    facet.visitJavaSources(new JavaResourceVisitor() {
        @Override
        public void visit(VisitContext context, JavaResource javaResource) {
            try {
                // avoid package-info.java files
                if (!javaResource.getName().contains("package-info")) {
                    JavaClass clazz = javaResource.getJavaType();
                    String packageName = clazz.getPackage();
                    if (packageName != null && !packageNames.contains(packageName)) {
                        packageNames.add(packageName);
                    }
                }
            } catch (FileNotFoundException e) {
                // ignore
            }
        }
    });
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:21,代码来源:PackageNameCompleter.java


示例6: createCurrentLineCompleter

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
protected CurrentLineCompleter createCurrentLineCompleter(int lineNumber, String file, UIContext context) throws Exception {
    Project project = getSelectedProject(context);

    JavaSourceFacet sourceFacet = null;
    ResourcesFacet resourcesFacet = null;
    WebResourcesFacet webResourcesFacet = null;
    if (project.hasFacet(JavaSourceFacet.class)) {
        sourceFacet = project.getFacet(JavaSourceFacet.class);
    }
    if (project.hasFacet(ResourcesFacet.class)) {
        resourcesFacet = project.getFacet(ResourcesFacet.class);
    }
    if (project.hasFacet(WebResourcesFacet.class)) {
        webResourcesFacet = project.getFacet(WebResourcesFacet.class);
    }

    String relativeFile = asRelativeFile(context, file);
    return new CurrentLineCompleter(lineNumber, relativeFile, sourceFacet, resourcesFacet, webResourcesFacet);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:20,代码来源:AbstractCamelProjectCommand.java


示例7: asRelativeFile

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
protected String asRelativeFile(UIContext context, String currentFile) {
    Project project = getSelectedProject(context);

    JavaSourceFacet javaSourceFacet = null;
    ResourcesFacet resourcesFacet = null;
    WebResourcesFacet webResourcesFacet = null;
    if (project.hasFacet(JavaSourceFacet.class)) {
        javaSourceFacet = project.getFacet(JavaSourceFacet.class);
    }
    if (project.hasFacet(ResourcesFacet.class)) {
        resourcesFacet = project.getFacet(ResourcesFacet.class);
    }
    if (project.hasFacet(WebResourcesFacet.class)) {
        webResourcesFacet = project.getFacet(WebResourcesFacet.class);
    }
    return asRelativeFile(currentFile, javaSourceFacet, resourcesFacet, webResourcesFacet);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:18,代码来源:AbstractCamelProjectCommand.java


示例8: RouteBuilderCompleter

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
public RouteBuilderCompleter(JavaSourceFacet facet) {
    // find package names in the source code
    facet.visitJavaSources(new JavaResourceVisitor() {
        @Override
        public void visit(VisitContext context, JavaResource javaResource) {
            try {
                // avoid package-info.java files
                if (!javaResource.getName().contains("package-info")) {
                    JavaClass clazz = javaResource.getJavaType();
                    String superType = clazz.getSuperType();
                    if (superType != null && isRouteBuilder(superType)) {
                        routeBuilders.add(clazz.getQualifiedName());
                        packages.add(clazz.getPackage());
                    }
                }
            } catch (FileNotFoundException e) {
                // ignore
            }
        }
    });
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:22,代码来源:RouteBuilderCompleter.java


示例9: initializeUI

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    Project project = getSelectedProject(builder.getUIContext());
    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);

    targetPackage.setCompleter(new PackageNameCompleter(facet));
    targetPackage.addValidator(new PackageNameValidator());
    targetPackage.getFacet(HintsFacet.class).setInputType(InputType.JAVA_PACKAGE_PICKER);
    // if there is only one package then use that as default
    Set<String> packages = new RouteBuilderCompleter(facet).getPackages();
    if (packages.size() == 1) {
        targetPackage.setDefaultValue(first(packages));
    }

    name.addValidator(new ClassNameValidator(false));
    name.getFacet(HintsFacet.class).setInputType(InputType.JAVA_CLASS_PICKER);

    builder.add(targetPackage).add(name);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:20,代码来源:CamelNewRouteBuilderCommand.java


示例10: initializeUI

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    Project project = getSelectedProject(builder.getUIContext());
    final JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);

    // filter the list of components based on consumer and producer only
    configureComponentName(project, componentName, false, false);

    targetPackage.setCompleter(new PackageNameCompleter(facet));
    targetPackage.addValidator(new PackageNameValidator());
    targetPackage.getFacet(HintsFacet.class).setInputType(InputType.JAVA_PACKAGE_PICKER);
    // if there is only one package then use that as default
    Set<String> packages = new RouteBuilderCompleter(facet).getPackages();
    if (packages.size() == 1) {
        targetPackage.setDefaultValue(first(packages));
    }

    className.addValidator(new ClassNameValidator(false));
    className.getFacet(HintsFacet.class).setInputType(InputType.JAVA_CLASS_PICKER);

    builder.add(componentName).add(instanceName).add(targetPackage).add(className);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:23,代码来源:CamelNewComponentCommand.java


示例11: addVertxPlugin

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
private void addVertxPlugin() {
    MavenPluginFacet pluginFacet = getFaceted().getFacet(MavenPluginFacet.class);
    MavenPluginBuilder builder = MavenPluginBuilder.create().setCoordinate(VERTX_MAVEN_PLUGIN);
    if (pluginFacet.hasPlugin(VERTX_MAVEN_PLUGIN)) {
        report("vertx-maven-plugin is already configured in the `pom.xml` file - skipping its configuration");
    } else {
        report("Configuring the vertx-maven-plugin...");

        builder.addExecution(ExecutionBuilder.create().addGoal("initialize").addGoal("package").setId("vertx"));
        builder.createConfiguration().addConfigurationElement(
            ConfigurationElementBuilder.create().setName("redeploy").setText("true")
        );

        pluginFacet.addPlugin(builder);

        JavaSourceFacet facet = getJavaSourceFacet();
        String topLevelPackage = facet.getBasePackage();
        ForgeUtils.addPropertyToProject(this.getFaceted(), "vertx.verticle",
            topLevelPackage + ".MainVerticle");
    }
}
 
开发者ID:cescoffier,项目名称:vertx-forge-addon,代码行数:22,代码来源:VertxMavenFacet.java


示例12: createJavaSourceForComponent

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
private void createJavaSourceForComponent(Project project, String schemeName, String packageName, String className) {
    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
    String fqn = packageName + "." + className;

    JavaResource existing = facet.getJavaResource(fqn);
    if (existing != null && existing.exists()) {
        // override existing
        existing.delete();
    }

    // need to parse to be able to extends another class
    final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
    javaClass.setName(className);
    javaClass.setPackage(packageName);
    javaClass.setSuperType("DjangoComponent");
    javaClass.addImport("io.fabric8.django.component.connector.DjangoComponent");

    // add public no-arg constructor
    javaClass.addMethod().setPublic().setConstructor(true).setBody("super(\"" + schemeName + "\", \"" + fqn + "\");");

    facet.saveJavaSource(javaClass);
}
 
开发者ID:fabric8io,项目名称:django,代码行数:23,代码来源:ConnectorSelectComponentStep.java


示例13: execute

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@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()));
}
 
开发者ID:forge,项目名称:wildfly-swarm-addon,代码行数:24,代码来源:CreateTestClassCommand.java


示例14: addSizeConstraint

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
public void addSizeConstraint(Project project, JavaClassSource klass, String propertyName, boolean onAccessor,
         String message,
         String min, String max) throws FileNotFoundException
{
   PropertySource<JavaClassSource> property = klass.getProperty(propertyName);
   final AnnotationSource<JavaClassSource> constraintAnnotation = addConstraintOnProperty(property, onAccessor,
            Size.class,
            message);

   if (min != null)
   {
      constraintAnnotation.setLiteralValue("min", min);
   }

   if (max != null)
   {
      constraintAnnotation.setLiteralValue("max", max);
   }

   JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class);
   javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin());
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:23,代码来源:ProjectHelper.java


示例15: validate

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
	Project selectedProject = getSelectedProject(context);
	JavaSourceFacet javaFacet = selectedProject.getFacet(JavaSourceFacet.class);
	try {
		if (null == context.getCurrentInputComponent().getValue())
			return;
		JavaResource javaResource = javaFacet.getJavaResource((String)context.getCurrentInputComponent().getValue());
		if (javaResource.exists()) {
			if (!javaResource.getJavaType().hasAnnotation(Named.class)) {
				context.addValidationError(context.getCurrentInputComponent(), javaResource.getFullyQualifiedName() + " must be annotated with @Named");
			}
		}
	} catch (FileNotFoundException e) {
		context.addValidationError(context.getCurrentInputComponent(), e.getMessage());
	}				
}
 
开发者ID:javaee-samples,项目名称:forge-addons,代码行数:18,代码来源:BatchNewJobXmlCommand.java


示例16: getEntityPackageDir

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public DirectoryResource getEntityPackageDir()
{
   JavaSourceFacet sourceFacet = getFaceted().getFacet(JavaSourceFacet.class);

   DirectoryResource entityRoot = sourceFacet.getBasePackageDirectory().getChildDirectory(
            JavaEEPackageConstants.DEFAULT_ENTITY_PACKAGE);
   if (!entityRoot.exists())
   {
      entityRoot.mkdirs();
   }

   return entityRoot;
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:15,代码来源:SpringBootJPAFacet.java


示例17: getAllEntities

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public List<JavaClassSource> getAllEntities()
{
   final List<JavaClassSource> result = new ArrayList<>();
   JavaSourceFacet javaSourceFacet = getFaceted().getFacet(JavaSourceFacet.class);
   javaSourceFacet.visitJavaSources(new JavaResourceVisitor()
   {
      @Override
      public void visit(VisitContext context, JavaResource resource)
      {
         try
         {
            JavaType<?> type = resource.getJavaType();
            if (type.hasAnnotation(Entity.class) && type.isClass())
            {
               result.add((JavaClassSource) type);
            }
         }
         catch (FileNotFoundException e)
         {
            throw new IllegalStateException(e);
         }
      }
   });

   return result;
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:28,代码来源:SpringBootJPAFacet.java


示例18: generateFrom

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public List<JavaClassSource> generateFrom(RestGenerationContext context) throws Exception
{
   JavaClassSource entity = context.getEntity();
   Project project = context.getProject();
   if (!entity.hasAnnotation(XmlRootElement.class))
   {
      entity.addAnnotation(XmlRootElement.class);
      project.getFacet(JavaSourceFacet.class).saveJavaSource(entity);
   }

   String idType = JPAEntityUtil.resolveIdType(entity);
   String idGetterName = JPAEntityUtil.resolveIdGetterName(entity);
   String entityTable = JPAEntityUtil.getEntityTable(entity);
   String selectExpression = JPAEntityUtil.getSelectExpression(entity, entityTable);
   String idClause = JPAEntityUtil.getIdClause(entity, entityTable);
   String orderClause = JPAEntityUtil.getOrderClause(entity,
            JPAEntityUtil.getJpqlEntityVariable(entityTable));
   String resourcePath = getResourcePath(context);

   Map<Object, Object> map = new HashMap<>();
   map.put("entity", entity);
   map.put("idType", idType);
   map.put("getIdStatement", idGetterName);
   map.put("contentType", "\"application/json\""); // fixme: hardcoded JSON representation
   map.put("entityTable", entityTable);
   map.put("selectExpression", selectExpression);
   map.put("idClause", idClause);
   map.put("orderClause", orderClause);
   map.put("resourcePath", resourcePath);
   map.put("idIsPrimitive", Types.isPrimitive(idType));

   Resource<URL> templateResource = resourceFactory.create(getClass().getResource("Endpoint.jv"));
   Template processor = templateFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(map);
   JavaClassSource resource = Roaster.parse(JavaClassSource.class, output);
   resource.addImport(entity.getQualifiedName());
   resource.setPackage(context.getTargetPackageName());
   return Arrays.asList(resource);
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:41,代码来源:SpringRestResourceGenerator.java


示例19: getRequiredFacets

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public Iterable<Class<? extends ProjectFacet>> getRequiredFacets() {
    List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>(7);
    result.add(MetadataFacet.class);
    result.add(PackagingFacet.class);
    result.add(DependencyFacet.class);
    result.add(ResourcesFacet.class);
    result.add(WebResourcesFacet.class);
    result.add(JavaSourceFacet.class);
    result.add(JavaCompilerFacet.class);
    return result;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:13,代码来源:FunktionProjectType.java


示例20: execute

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    Project project = (Project) uiContext.getAttributeMap().get(Project.class);
    Archetype chosenArchetype = archetype.getValue();
    String coordinate = chosenArchetype.getGroupId() + ":" + chosenArchetype.getArtifactId() + ":"
            + chosenArchetype.getVersion();
    DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate);
    String repository = chosenArchetype.getRepository();
    if (!Strings.isNullOrEmpty(repository)) {
        if (repository.endsWith(".xml")) {
            int lastRepositoryPath = repository.lastIndexOf('/');
            if (lastRepositoryPath > -1)
                repository = repository.substring(0, lastRepositoryPath);
        }
        if (!repository.isEmpty()) {
            depQuery.setRepositories(new DependencyRepository("archetype", repository));
        }
    }
    Dependency resolvedArtifact = dependencyResolver.resolveArtifact(depQuery);
    FileResource<?> artifact = resolvedArtifact.getArtifact();
    MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
    File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject();
    ArchetypeHelper archetypeHelper = new ArchetypeHelper(artifact.getResourceInputStream(), fileRoot,
            metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion());
    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
    archetypeHelper.setPackageName(facet.getBasePackage());
    archetypeHelper.execute();
    return Results.success();
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:31,代码来源:FunktionArchetypeSelectionWizardStep.java



注:本文中的org.jboss.forge.addon.parser.java.facets.JavaSourceFacet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JobExecutionConfiguration类代码示例发布时间:2022-05-23
下一篇:
Java DetailLevel类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap