本文整理汇总了Java中org.jboss.forge.roaster.model.source.JavaClassSource.addNestedType方法的典型用法代码示例。如果您正苦于以下问题:Java JavaClassSource.addNestedType方法的具体用法?Java JavaClassSource.addNestedType怎么用?Java JavaClassSource.addNestedType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.forge.roaster.model.source.JavaClassSource
的用法示例。
在下文中一共展示了JavaClassSource.addNestedType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addComponentFactories
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
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());
}
}
示例2: create
import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
/**
* Base template for a resource representation.
* Covers the resource attributes
*
* @param index
* @param plan
* @return
*/
public JavaClassSource create(ClassIndex index, ClassPlan plan) {
this.names.clear();
// base class
JavaClassSource type = Roaster.parse(
JavaClassSource.class,
"public class " + plan.getClassName() + "<T extends " + plan.getClassName() + "<T>> implements " + Keyed.class.getName() + "{}"
);
type.setPackage(plan.getPackageName());
type.addImport(AttributeDocumentation.class);
type.addImport(ResourceDocumentation.class);
type.addImport(SingletonResource.class);
JavaDocSource javaDoc = type.getJavaDoc();
ResourceDescription desc = plan.getDescription();
javaDoc.setText(desc.getText());
addAddressAnnotations(type, plan);
addConstructor(type, plan);
addResourceTypeAnnotation(type, plan);
addPropertyChangeSupport(type, plan);
addChildResources(index, type, plan);
addSingletonResources(index, type, plan);
if (plan.getSubresourceClass() != null) {
type.addNestedType(plan.getSubresourceClass());
}
for (EnumPlan enumPlan : plan.getEnumPlans()) {
EnumFactory factory = new EnumFactory();
JavaEnumSource enumType = factory.create(index, enumPlan);
enumType.setStatic(true);
type.addNestedType(enumType);
}
addAttribtues(index, type, plan);
return type;
}