Java Code Examples for org.jboss.forge.roaster.model.source.JavaClassSource#getImport()

The following examples show how to use org.jboss.forge.roaster.model.source.JavaClassSource#getImport() . 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: ContextGenerator.java    From Entitas-Java with MIT License 5 votes vote down vote up
private void addImports(List<FieldSource<JavaClassSource>> memberInfos, JavaClassSource source) {
    for (FieldSource<JavaClassSource> info : memberInfos) {
        if (info.getOrigin().getImport(info.getType().toString()) != null) {
            if (source.getImport(info.getType().toString()) == null) {
                source.addImport(info.getType());
            }
        }
    }
}
 
Example 2
Source File: ComponentContextGenerator.java    From Entitas-Java with MIT License 5 votes vote down vote up
private void addImports(List<FieldSource<JavaClassSource>> memberInfos, JavaClassSource source) {
    for (FieldSource<JavaClassSource> info : memberInfos) {
        if (info.getOrigin().getImport(info.getType().toString()) != null) {
            if (source.getImport(info.getType().toString()) == null) {
                source.addImport(info.getType());
            }
        }
    }
}
 
Example 3
Source File: ComponentEntityGenerator.java    From Entitas-Java with MIT License 5 votes vote down vote up
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");
    }

}
 
Example 4
Source File: ContextGenerator.java    From Entitas-Java with MIT License 5 votes vote down vote up
private void addImports(List<FieldSource<JavaClassSource>> memberInfos, JavaClassSource source) {
    for (FieldSource<JavaClassSource> info : memberInfos) {
        if (info.getOrigin().getImport(info.getType().toString()) != null) {
            if (source.getImport(info.getType().toString()) == null) {
                source.addImport(info.getType());
            }
        }
    }
}