当前位置: 首页>>代码示例>>Java>>正文


Java JavaClassSource.setPackage方法代码示例

本文整理汇总了Java中org.jboss.forge.roaster.model.source.JavaClassSource.setPackage方法的典型用法代码示例。如果您正苦于以下问题:Java JavaClassSource.setPackage方法的具体用法?Java JavaClassSource.setPackage怎么用?Java JavaClassSource.setPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.forge.roaster.model.source.JavaClassSource的用法示例。


在下文中一共展示了JavaClassSource.setPackage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createJavaSourceForComponent

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的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

示例2: generateIndicesLookup

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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;
    }
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:21,代码来源:ComponentIndicesGenerator.java

示例3: generateMatchers

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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;
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:20,代码来源:MatcherGenerator.java

示例4: createFile

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
public File createFile(String className, String subDir, JavaClassSource content) {
    String targetPackage = targetPackageConfig.getTargetPackage();
    String finalPackage = subDir.equals("") || className.contains("Shared")?
            String.format("%s", targetPackage) :
            String.format("%s.%s", targetPackage, subDir);
    content.setPackage(finalPackage);

    String pathPackage = targetPackage.replace(".", "/");
    String pathFile = subDir.equals("") || className.contains("Shared")?
            String.format("%s/%s/%s.java", projectConfig.getSrcDirs().get(0), pathPackage, className) :
            String.format("%s/%s/%s/%s.java", projectConfig.getSrcDirs().get(0), pathPackage, subDir, className);

    File file = new File(pathFile);
    CodeGeneratorUtil.writeFile(file, content.toString());
    return file;
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:17,代码来源:WriteToDiskPostProcessor.java

示例5: generateIndicesLookup

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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;
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:19,代码来源:ComponentLookupGenerator.java

示例6: generateMatcher

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
private void generateMatcher(String contextName, ComponentData data) {
    String pkgDestiny = targetPackageConfig.getTargetPackage();
    CodeGenFile<JavaClassSource> genFile = getCodeGenFile(contextName, data);
    JavaClassSource codeGenerated = genFile.getFileContent();

    if (!pkgDestiny.endsWith(data.getSubDir())) {
        pkgDestiny += "." + data.getSubDir();

    }

    codeGenerated.setPackage(pkgDestiny);
    codeGenerated.addImport(Matcher.class);

    addMatcher(contextName, data, codeGenerated);
    addMatcherMethods(contextName, data, codeGenerated);

}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:18,代码来源:ComponentMatcherGenerator.java

示例7: generateMatchers

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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;
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:20,代码来源:MatcherGenerator.java

示例8: probe

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
/**
 * Creates an implementation of the network probe. The created class extends
 * {@link ExternalProbe}, setting the queuing server's connection data.
 * 
 * @param modified
 *            The modified service interface
 * @return The created source code
 */
public JavaClassSource probe(final JavaInterfaceSource modified) {

	File file = new File(this.interfacePath);
	String className = new NameProposal("NetworkLatencyProbe.java",
			file.getParentFile()).getNewName();

	JavaClassSource javaClass = Roaster.create(JavaClassSource.class);

	// Set general properties
	javaClass.setName(className);
	javaClass.setPackage(modified.getPackage());
	javaClass.setSuperType(ExternalProbe.class);

	// Add imports
	javaClass.addImport(ExternalProbe.class);
	javaClass.addImport(PascaniRuntime.Context.class);

	Context context = Context.PROBE;
	String body = NetworkLatencyTemplates.getProbeInitialization(
			this.routingKey, context);
	javaClass.addMethod().setConstructor(true).setBody(body)
			.addThrows(Exception.class);

	return javaClass;
}
 
开发者ID:unicesi,项目名称:pascani,代码行数:34,代码来源:LatencyProbeGenerator.java

示例9: generateFrom

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的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

示例10: getOrCreateSubresourceClass

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
private JavaClassSource getOrCreateSubresourceClass(ClassPlan plan, JavaClassSource javaClass) {

        JavaClassSource subresourceClass = plan.getSubresourceClass();

        if (subresourceClass != null) {
            return subresourceClass;
        }

        subresourceClass = Roaster.parse(
                JavaClassSource.class,
                "class " + javaClass.getName() + "Resources" + " {}"
        );
        subresourceClass.setPackage(plan.getPackageName());
        subresourceClass.getJavaDoc().setText("Child mutators for " + javaClass.getName());
        subresourceClass.setPublic();
        subresourceClass.setStatic(true);

        javaClass.addField()
                .setPrivate()
                .setType(subresourceClass.getName())
                .setName("subresources")
                .setLiteralInitializer("new " + subresourceClass.getName() + "();");

        final MethodSource<JavaClassSource> subresourcesMethod = javaClass.addMethod()
                .setName("subresources")
                .setPublic();
        subresourcesMethod.setReturnType(subresourceClass.getName());
        subresourcesMethod.setBody("return this.subresources;");

        javaClass.addImport("java.util.List");
        javaClass.addImport(Subresource.class);
        plan.setSubresourceClass(subresourceClass);
        return subresourceClass;
    }
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:35,代码来源:ResourceFactory.java

示例11: generateEntitas

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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;

}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:12,代码来源:EntitasGenerator.java

示例12: generateContext

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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;
    }
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:32,代码来源:ContextGenerator.java

示例13: generateContext

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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);
        }
    }
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:31,代码来源:ComponentContextGenerator.java

示例14: generateEntitas

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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;

}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:14,代码来源:EntitasGenerator.java

示例15: generateEntity

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
private void generateEntity(String contextName, ComponentData data) {
    String pkgDestiny = targetPackageConfig.getTargetPackage();
    CodeGenFile<JavaClassSource> genFile = getCodeGenFile(contextName, data);
    JavaClassSource codeGenerated = genFile.getFileContent();

    if (!pkgDestiny.endsWith(data.getSubDir())) {
        pkgDestiny += "." + data.getSubDir();

    }
    if (codeGenerated.getPackage() == null) {
        codeGenerated.setPackage(pkgDestiny);
        codeGenerated.addMethod()
                .setName(contextName + "Entity")
                .setPublic()
                .setConstructor(true)
                .setBody("");
        codeGenerated.addImport("ilargia.entitas.Entity");

    }

    if (shouldGenerateMethods(data)) {
        addImporEnums(data, codeGenerated);
        addEntityMethods(contextName, data, codeGenerated);
    }
    if (isSharedContext(data) && codeGenerated.getImport(targetPackageConfig.getTargetPackage()) == null) {
        codeGenerated.addImport(targetPackageConfig.getTargetPackage() + ".SharedComponentsLookup");
    }

}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:30,代码来源:ComponentEntityGenerator.java


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