當前位置: 首頁>>代碼示例>>Java>>正文


Java JavaFileInputBuilder類代碼示例

本文整理匯總了Java中org.opendaylight.controller.config.yangjmxgenerator.plugin.java.JavaFileInputBuilder的典型用法代碼示例。如果您正苦於以下問題:Java JavaFileInputBuilder類的具體用法?Java JavaFileInputBuilder怎麽用?Java JavaFileInputBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JavaFileInputBuilder類屬於org.opendaylight.controller.config.yangjmxgenerator.plugin.java包,在下文中一共展示了JavaFileInputBuilder類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toGeneratedObject

import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.JavaFileInputBuilder; //導入依賴的package包/類
GeneratedObject toGeneratedObject(FullyQualifiedName concreteFQN,
                                         FullyQualifiedName abstractFQN,
                                         Optional<String> copyright,
                                         Optional<String> header,
                                         Optional<String> classJavaDoc) {
    // there are two constructors and two methods
    JavaFileInputBuilder builder = new JavaFileInputBuilder();
    builder.setTypeName(TypeName.classType);
    builder.setFqn(concreteFQN);
    builder.addExtendsFQN(abstractFQN);

    builder.setCopyright(copyright);
    builder.setHeader(header);
    builder.setClassJavaDoc(classJavaDoc);

    builder.addToBody(getNewCtor(concreteFQN));
    builder.addToBody(getCopyCtor(concreteFQN));
    builder.addToBody(getCustomValidationStub());
    builder.addToBody(getCreateInstanceStub());

    return new GeneratedObjectBuilder(builder.build()).toGeneratedObject();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:23,代碼來源:ConcreteModuleGeneratedObjectFactory.java

示例2: toGeneratedObject

import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.JavaFileInputBuilder; //導入依賴的package包/類
public GeneratedObject toGeneratedObject(FtlTemplate template, Optional<String> copyright) {
    JavaFileInputBuilder b = new JavaFileInputBuilder();
    b.setHeader(template.getHeaderString());
    b.setFqn(new FullyQualifiedName(template.getPackageName(), template.getTypeDeclaration().getName()));
    b.setClassJavaDoc(template.getMaybeJavadoc());
    for (Annotation annotation : template.getAnnotations()) {
        b.addClassAnnotation(annotation);
    }
    // type declaration
    for (String extended : template.getTypeDeclaration().getExtended()) {
        b.addExtendsFQN(FullyQualifiedName.fromString(extended));
    }
    for (String implemented : template.getTypeDeclaration().getImplemented()) {
        b.addImplementsFQN(FullyQualifiedName.fromString(implemented));
    }
    b.setCopyright(copyright);
    b.setTypeName(template.getTypeDeclaration().toTypeName());
    // fields
    for (Field field : template.getFields()) {
        b.addToBody(field.toString());
    }
    // constructors
    for (Constructor constructor : template.getConstructors()) {
        b.addToBody(constructor.toString());
    }
    // methods
    for (Method method : template.getMethods()) {
        b.addToBody(method.toString());
    }
    return new GeneratedObjectBuilder(b.build()).toGeneratedObject();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:32,代碼來源:GenericGeneratedObjectFactory.java

示例3: toGeneratedObject

import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.JavaFileInputBuilder; //導入依賴的package包/類
public GeneratedObject toGeneratedObject(FullyQualifiedName abstractFQN,
                                         Optional<String> copyright,
                                         Optional<String> header,
                                         Optional<String> classJavaDoc,
                                         Optional<FullyQualifiedName> extended,
                                         List<FullyQualifiedName> implementedInterfaces,
                                         List<ModuleField> moduleFields,
                                         Optional<FullyQualifiedName> maybeRegistratorType,
                                         List<? extends Method> methods,
                                         QName yangModuleQName) {
    JavaFileInputBuilder b = new JavaFileInputBuilder();

    Annotation moduleQNameAnnotation = Annotation.createModuleQNameANnotation(yangModuleQName);
    b.addClassAnnotation(moduleQNameAnnotation);

    b.setFqn(abstractFQN);
    b.setTypeName(TypeName.absClassType);

    b.setCopyright(copyright);
    b.setHeader(header);
    b.setClassJavaDoc(classJavaDoc);
    for(FullyQualifiedName implemented: implementedInterfaces) {
        b.addImplementsFQN(implemented);
    }
    if(extended.isPresent()) {
        b.addExtendsFQN(extended.get());
    }
    if (classJavaDoc.isPresent()) {
        b.addClassAnnotation(format("@%s(value=\"%s\")", Description.class.getCanonicalName(), classJavaDoc.get()));
    }

    // add logger:
    b.addToBody(getLoggerDefinition(abstractFQN));

    b.addToBody("//attributes start");
    for(ModuleField moduleField: moduleFields) {
        b.addToBody(moduleField.toString() +"\n");
    }

    b.addToBody("//attributes end");


    b.addToBody(getNewConstructor(abstractFQN));
    b.addToBody(getCopyFromOldConstructor(abstractFQN));

    b.addToBody(getRuntimeRegistratorCode(maybeRegistratorType));
    b.addToBody(getValidationMethods(moduleFields));

    b.addToBody(getCachesOfResolvedDependencies(moduleFields));
    b.addToBody(getCachesOfResolvedIdentityRefs(moduleFields));
    b.addToBody(getResolveDependencies(moduleFields));
    b.addToBody(getReuseLogic(moduleFields, abstractFQN));
    b.addToBody(getEqualsAndHashCode(abstractFQN));

    b.addToBody(getMethods(methods));
    b.addToBody(getGetLogger());

    return new GeneratedObjectBuilder(b.build()).toGeneratedObject();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:60,代碼來源:AbsModuleGeneratedObjectFactory.java

示例4: toGeneratedObject

import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.JavaFileInputBuilder; //導入依賴的package包/類
public GeneratedObject toGeneratedObject(FullyQualifiedName absFactoryFQN, Optional<String> copyright,
                                         Optional<String> header, Optional<String> classJavaDoc, QName yangModuleQName,
                                         String globallyUniqueName,
                                         List<FullyQualifiedName> providedServices,
                                         FullyQualifiedName moduleFQN,
                                         List<Field> moduleFields) {
    JavaFileInputBuilder b = new JavaFileInputBuilder();

    b.addImportFQN(new FullyQualifiedName(Module.class));
    b.addImportFQN(new FullyQualifiedName(ModuleIdentifier.class));

    Annotation moduleQNameAnnotation = Annotation.createModuleQNameANnotation(yangModuleQName);
    b.addClassAnnotation(moduleQNameAnnotation);

    b.setFqn(absFactoryFQN);
    b.setTypeName(TypeName.absClassType);

    b.setCopyright(copyright);
    b.setHeader(header);
    b.setClassJavaDoc(classJavaDoc);
    b.addImplementsFQN(new FullyQualifiedName(ModuleFactory.class));
    if (classJavaDoc.isPresent()) {
        b.addClassAnnotation(format("@%s(value=\"%s\")", Description.class.getCanonicalName(), classJavaDoc.get()));
    }

    b.addToBody(format("public static final java.lang.String NAME = \"%s\";", globallyUniqueName));
    b.addToBody(format("private static final java.util.Set<Class<? extends %s>> serviceIfcs;",
            AbstractServiceInterface.class.getCanonicalName()));

    b.addToBody("@Override\n public final String getImplementationName() { \n return NAME; \n}");

    b.addToBody(getServiceIfcsInitialization(providedServices));

    // createModule
    b.addToBody(format("\n"+
        "@Override\n"+
        "public %s createModule(String instanceName, %s dependencyResolver, %s bundleContext) {\n"+
            "return instantiateModule(instanceName, dependencyResolver, bundleContext);\n"+
        "}\n",
            Module.class.getCanonicalName(), DependencyResolver.class.getCanonicalName(), BUNDLE_CONTEXT));

    b.addToBody(getCreateModule(moduleFQN, moduleFields));

    b.addToBody(format("\n"+
        "public %s instantiateModule(String instanceName, %s dependencyResolver, %s oldModule, %s oldInstance, %s bundleContext) {\n"+
            "return new %s(new %s(NAME, instanceName), dependencyResolver, oldModule, oldInstance);\n"+
        "}\n",
            moduleFQN, DependencyResolver.class.getCanonicalName(), moduleFQN, AutoCloseable.class.getCanonicalName(),
            BUNDLE_CONTEXT, moduleFQN, ModuleIdentifier.class.getCanonicalName()));

    b.addToBody(format("\n"+
        "public %s instantiateModule(String instanceName, %s dependencyResolver, %s bundleContext) {\n"+
            "return new %s(new %s(NAME, instanceName), dependencyResolver);\n"+
        "}\n", moduleFQN, DependencyResolver.class.getCanonicalName(), BUNDLE_CONTEXT,
            moduleFQN, ModuleIdentifier.class.getCanonicalName()
    ));

    b.addToBody(format("\n"+
            "public %s handleChangedClass(%s dependencyResolver, %s old, %s bundleContext) throws Exception {\n" +
                // "// @Deprecated return handleChangedClass(old);\n" +
                "String instanceName = old.getModule().getIdentifier().getInstanceName();\n" +
                "%1$s newModule = new %1$s(new ModuleIdentifier(NAME, instanceName), dependencyResolver);\n" +
                "Module oldModule = old.getModule();\n" +
                "Class<? extends Module> oldModuleClass = oldModule.getClass();\n" +
                genCodeToCopyAttributes(moduleFields) +
                "return newModule;\n" +
            "}\n", moduleFQN, DependencyResolver.class.getCanonicalName(), DynamicMBeanWithInstance.class.getCanonicalName(), BUNDLE_CONTEXT));

    b.addToBody(format("\[email protected]\n"+
        "public %s handleChangedClass(%s old) throws Exception {\n"+
            "throw new UnsupportedOperationException(\"Class reloading is not supported\");\n"+
        "}\n", moduleFQN, DynamicMBeanWithInstance.class.getCanonicalName()));

    b.addToBody(format("\n"+
        "@Override\n"+
        "public java.util.Set<%s> getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory dependencyResolverFactory, %s bundleContext) {\n"+
            "return new java.util.HashSet<>();\n"+
        "}\n", moduleFQN, BUNDLE_CONTEXT));

    return new GeneratedObjectBuilder(b.build()).toGeneratedObject();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:82,代碼來源:AbsFactoryGeneratedObjectFactory.java


注:本文中的org.opendaylight.controller.config.yangjmxgenerator.plugin.java.JavaFileInputBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。