本文整理汇总了Java中org.jboss.forge.roaster.model.JavaType类的典型用法代码示例。如果您正苦于以下问题:Java JavaType类的具体用法?Java JavaType怎么用?Java JavaType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaType类属于org.jboss.forge.roaster.model包,在下文中一共展示了JavaType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyAccessTransformation
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
/**
* Applies access transformations to a parsed type and all of its nested members.
*
* TODO: Add support for inheritance to reduce the size of AT configs.
*/
@SuppressWarnings("unchecked")
private void applyAccessTransformation(@Nonnull AccessTransformationMap transformationMap, @Nonnull JavaType classSource) {
this.getLog().info("Applying access transformations to " + classSource.getQualifiedName());
transformationMap.getTypeMappings(classSource.getQualifiedName()).ifPresent((t) -> {
if (classSource instanceof VisibilityScopedSource) {
t.getVisibility().ifPresent(((VisibilityScopedSource) classSource)::setVisibility);
}
if (classSource instanceof FieldHolderSource) {
((List<FieldSource>) ((FieldHolderSource) classSource).getFields()).forEach((f) -> t.getFieldVisibility(f.getName()).ifPresent(f::setVisibility));
}
if (classSource instanceof MethodHolderSource) {
((List<MethodSource>) ((MethodHolderSource) classSource).getMethods()).forEach((m) -> t.getMethodVisibility(m.getName()).ifPresent(m::setVisibility));
}
((List<JavaType>) classSource.getNestedClasses()).forEach((c) -> this.applyAccessTransformation(transformationMap, c));
});
}
示例2: write
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
private void write(JavaType javaClass) {
try {
String dir = this.targetDir + File.separator + javaClass.getPackage().replace(".", File.separator);
Files.createDirectories(Paths.get(dir));
Path fileName = Paths.get(dir + File.separator + javaClass.getName() + ".java");
if (Files.exists(fileName)) {
System.err.println("File already exists, will be replaced: " + fileName);
}
Files.write(fileName, javaClass.toString().getBytes());
} catch (IOException e) {
log.log(Level.ERROR, "Failed to persist class", e);
}
}
示例3: create
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
/**
* Base template for a resource representation.
* Covers the resource attributes
*
* @param index
* @param plan
* @return
*/
public JavaType create(ClassIndex index, ClassPlan plan) {
// base class
JavaInterfaceSource type = Roaster.parse(
JavaInterfaceSource.class,
"public interface " + plan.getClassName() + "Supplier<T extends " + plan.getClassName() + "> {}"
);
type.setPackage(plan.getPackageName());
type.addAnnotation(FunctionalInterface.class);
addGet( type, plan );
return type;
}
示例4: create
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
/**
* Base template for a resource representation.
* Covers the resource attributes
*
* @param index
* @param plan
* @return
*/
public JavaType create(ClassIndex index, ClassPlan plan) {
// base class
JavaInterfaceSource type = Roaster.parse(
JavaInterfaceSource.class,
"public interface " + plan.getClassName() + "Consumer<T extends " + plan.getClassName() + "<T>> {}"
);
type.setPackage(plan.getPackageName());
type.addImport(plan.getPackageName() + "." + plan.getClassName());
type.addAnnotation(FunctionalInterface.class);
addAccept(type, plan);
addAndThen(type, plan);
return type;
}
示例5: main
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
public static void main(String[] args) throws CoralConnectionException, FileNotFoundException {
String defaultFile = "src/main/java/edu/utah/nanofab/coralapi/CoralAPI.java";
String filename = "";
if (args.length < 1) {
System.err.println("Please pass file name, using default");
filename = defaultFile;
} else {
filename = args[0];
}
System.err.println("Decorating: " + filename);
File file = new File(filename);
if (!file.exists()) {
System.err.println("No such file");
System.exit(1);
}
JavaType jt = Roaster.parse(file);
JavaClassSource newClass = CoralAPIGenerateSynchronizedDecorator.createDecorator(jt);
System.out.println(newClass.toString());
}
示例6: main
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
public static void main(String[] args) throws CoralConnectionException, FileNotFoundException {
String defaultFile = "src/main/java/edu/utah/nanofab/coralapi/CoralAPI.java";
String filename = "";
if (args.length < 1) {
System.err.println("Please pass file name, using default");
filename = defaultFile;
} else {
filename = args[0];
}
System.err.println("Decorating: " + filename);
File file = new File(filename);
if (!file.exists()) {
System.err.println("No such file");
System.exit(1);
}
JavaType jt = Roaster.parse(file);
JavaClassSource newClass = CoralAPIGenerateRetryDecorator.createDecorator(jt);
System.out.println(newClass.toString());
}
示例7: resolve
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
@Override
public String resolve(JavaType<?> source, String type)
{
GraphContext graphContext = getContext();
if (graphContext == null)
{
return type;
}
Importer<?> importer = (Importer<?>) source;
List<String> wildcardImports = new ArrayList<>();
for (Import importDeclaration : importer.getImports())
{
if (importDeclaration.isWildcard())
{
wildcardImports.add(importDeclaration.getQualifiedName());
}
}
return resolve(wildcardImports, type);
}
示例8: getAllEntities
import org.jboss.forge.roaster.model.JavaType; //导入依赖的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;
}
示例9: apply
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
@Override
public void apply(JavaType<?> type) {
String path = getFilePath(type);
TSFile file = getFile(path);
this.currentFile = file;
TSWritable writable = transform(type);
file.add(writable);
}
示例10: hasAnnotation
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
protected boolean hasAnnotation(JavaType<?> type, String simpleName) {
List<? extends Annotation<?>> annotations = type.getAnnotations();
for (Annotation<?> annotation : annotations) {
if(annotation.getName().equals(simpleName)) return true;
}
return false;
}
示例11: transform
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
@Override
public TSWritable transform(JavaType<?> type) {
if(type instanceof JavaClassSource) {
return createClass((JavaClassSource) type);
} else if(type instanceof JavaInterfaceSource) {
return createInterface((JavaInterfaceSource) type);
} else if(type instanceof JavaEnumSource) {
return createEnum((JavaEnumSource) type);
}
throw new IllegalArgumentException("Unknown type: " + type.getClass().getSimpleName());
}
示例12: createTypeName
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private TypeName createTypeName(JavaType<?> type) {
TypeName result = new CustomType(type.getName());
if(type instanceof GenericCapableSource) {
List<TypeVariableSource<?>> variables = ((GenericCapableSource) type).getTypeVariables();
for (TypeVariableSource<?> variable : variables) {
result.getGenerics().add(variable.getName());
}
}
return result;
}
示例13: createMethods
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
private List<ServiceMethod> createMethods(MethodHolderSource<?> source) {
List<ServiceMethod> results = Lists.newArrayList();
for (MethodSource<?> method : source.getMethods()) {
results.add(new ServiceMethod((JavaType<?>) source, method));
}
return results;
}
示例14: createClass
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
private TSClassDef createClass(ServiceClass clazz) {
JavaType<?> type = clazz.getType();
TSClassDef res = new TSClassDef();
res.name(type.getName());
res.modifier(TSModifier.EXPORT);
return res;
}
示例15: ServiceMethod
import org.jboss.forge.roaster.model.JavaType; //导入依赖的package包/类
public ServiceMethod(JavaType<?> type, MethodSource<?> method) {
this.type = type;
this.method = method;
ServiceRequestProps globalProps = createProps(type);
ServiceRequestProps methodProps = createProps(method);
this.props = methodProps.merged(globalProps);
this.params = createParams(method);
}