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


Java ModuleField类代码示例

本文整理汇总了Java中org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField的典型用法代码示例。如果您正苦于以下问题:Java ModuleField类的具体用法?Java ModuleField怎么用?Java ModuleField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ModuleField类属于org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model包,在下文中一共展示了ModuleField类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCachesOfResolvedDependencies

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
private static String getCachesOfResolvedDependencies(List<ModuleField> moduleFields) {
    StringBuilder result = new StringBuilder();
    for (ModuleField moduleField: moduleFields) {
        if (moduleField.isDependent()) {
            String osgi = moduleField.getDependency().getSie().getExportedOsgiClassName();
            if (moduleField.isList()) {
                result
                        .append(format("private java.util.List<%s> %sDependency = new java.util.ArrayList<%s>();", osgi, moduleField.getName(), osgi))
                        .append(format("protected final java.util.List<%s> get%sDependency(){\n", osgi, moduleField.getAttributeName()))
                        .append(format("return %sDependency;\n", moduleField.getName()))
                        .append("}\n");
            } else {
                result.append(format(
                    "private %s %sDependency;\n"+
                    "protected final %s get%sDependency(){\n"+
                        "return %sDependency;\n"+
                    "}",
                    osgi, moduleField.getName(), osgi, moduleField.getAttributeName(), moduleField.getName()));
            }
        }
    }
    return result.toString();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:AbsModuleGeneratedObjectFactory.java

示例2: getCachesOfResolvedIdentityRefs

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
private static String getCachesOfResolvedIdentityRefs(List<ModuleField> moduleFields) {
    StringBuilder result = new StringBuilder();
    for (ModuleField moduleField : moduleFields) {
        if (moduleField.isIdentityRef()) {
            IdentityRefModuleField field = (IdentityRefModuleField) moduleField;
            result.append(format("private %s %s;\n", field.getIdentityClassType(), field.getIdentityClassName()));
        }
    }
    return result.toString();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:AbsModuleGeneratedObjectFactory.java

示例3: getValidationMethods

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
private static String getValidationMethods(List<ModuleField> moduleFields) {
    StringBuilder result = new StringBuilder("\n" +
            "@Override\n" +
            "public void validate() {\n");
    // validate each mandatory dependency
    for (ModuleField moduleField : moduleFields) {
        if (moduleField.isDependent()) {
            if (moduleField.isList()) {
                result.append(format("for(javax.management.ObjectName dep : %s) {\n", moduleField.getName()))
                        .append(format("    dependencyResolver.validateDependency(%s.class, dep, %sJmxAttribute);" +
                                                "\n",
                                        moduleField.getDependency().getSie().getFullyQualifiedName(),
                                        moduleField.getName()))
                        .append("}\n");
            } else {
                if (!moduleField.getDependency().isMandatory()) {
                    result.append(format("if(%s != null) {\n", moduleField.getName()));
                }
                result.append(format("dependencyResolver.validateDependency(%s.class, %s, %sJmxAttribute);\n",
                        moduleField.getDependency().getSie().getFullyQualifiedName(), moduleField.getName(),
                        moduleField.getName()));
                if (!moduleField.getDependency().isMandatory()) {
                    result.append("}\n");
                }
            }
        }
    }
    result.append("\n" +
            "customValidation();\n" +
            "}\n" +
            "\n" +
            "protected void customValidation() {\n" +
            "}\n");
    return result.toString();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:36,代码来源:AbsModuleGeneratedObjectFactory.java

示例4: AbstractModuleTemplate

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
public AbstractModuleTemplate(Header header, String packageName,
        String abstractModuleName, List<String> extendedClasses,
        List<String> implementedIfcs, List<ModuleField> moduleFields, List<MethodDefinition> methods,
        boolean isRuntime, String registratorType) {
    super(header, packageName, abstractModuleName, extendedClasses,
            implementedIfcs, Collections.<Field> emptyList(), methods,
            true, false, Collections.<Constructor> emptyList());
    this.moduleFields = moduleFields;
    this.runtime = isRuntime;
    this.registratorType = registratorType;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:12,代码来源:AbstractModuleTemplate.java

示例5: toGeneratedObject

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的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

示例6: getReuseLogic

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
private static String getReuseLogic(List<ModuleField> moduleFields, FullyQualifiedName abstractFQN) {
    StringBuilder result = new StringBuilder("\n" +
            format("public boolean canReuseInstance(%s oldModule){\n", abstractFQN.getTypeName()) +
            "// allow reusing of old instance if no parameters was changed\n" +
            "return isSame(oldModule);\n" +
            "}\n" +
            "\n" +
            format("public %s reuseInstance(%1$s oldInstance){\n", AutoCloseable.class.getCanonicalName()) +
            "// implement if instance reuse should be supported." +
            "Override canReuseInstance to change the criteria.\n" +
            "return oldInstance;\n" +
            "}\n");
    // isSame method that detects changed fields
    result.append("\n")
            .append(format("public boolean isSame(%s other) {\n", abstractFQN.getTypeName()))
            .append("if (other == null) {\n")
            .append("throw new IllegalArgumentException(\"Parameter 'other' is null\");\n")
            .append("}\n");

    // loop through fields, do deep equals on each field
    for (ModuleField moduleField : moduleFields) {
        result.append(format(
                "if (!java.util.Objects.deepEquals(%s, other.%1$s)) {\n" +
                        "return false;\n" +
                        "}\n", moduleField.getName()));

        if (moduleField.isListOfDependencies()) {
            result.append(format(
                    "for (int idx = 0; idx < %1$s.size(); idx++) {\n" +
                            "if (!dependencyResolver.canReuseDependency(%1$s.get(idx), %1$sJmxAttribute)) {\n" +
                            "return false;\n" +
                            "}\n" +
                            "}\n", moduleField.getName()));
        } else if (moduleField.isDependent()) {
            result.append(format(
                    // If a reference is null (ie optional reference) it makes no sens to call canReuse on it
                    // In such case we continue in the isSame method because if we have null here, the previous
                    // value was null as well
                    // If the previous value was not null and current is or vice verse, the deepEquals comparison
                    // would return false
                    "if(%1$s!= null) {\n" +
                            "// reference to dependency must be reusable as well\n" +
                            "if (!dependencyResolver.canReuseDependency(%1$s, %1$sJmxAttribute)) {\n" +
                            "return false;\n" +
                            "}\n" +
                            "}\n", moduleField.getName()));
        }
    }

    result.append("\n" +
            "return true;\n" +
            "}\n");

    return result.toString();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:56,代码来源:AbsModuleGeneratedObjectFactory.java

示例7: abstractModuleTemplateFromMbe

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
public static AbstractModuleTemplate abstractModuleTemplateFromMbe(
        final ModuleMXBeanEntry mbe) {
    final AbstractModuleAttributesProcessor attrProcessor = new AbstractModuleAttributesProcessor(mbe.getAttributes());

    final List<ModuleField> moduleFields = attrProcessor.getModuleFields();
    final List<String> implementedIfcs = Lists.newArrayList(
            mbe.getFullyQualifiedName(mbe.getMXBeanInterfaceName()));

    for (final String implementedService : mbe.getProvidedServices().keySet()) {
        implementedIfcs.add(implementedService);
    }

    boolean generateRuntime = false;
    String registratorFullyQualifiedName = null;
    if ((mbe.getRuntimeBeans() != null)
            && !mbe.getRuntimeBeans().isEmpty()) {
        generateRuntime = true;
        final RuntimeBeanEntry rootEntry = RuntimeRegistratorFtlTemplate
                .findRoot(mbe.getRuntimeBeans());
        registratorFullyQualifiedName = rootEntry
                .getPackageName()
                .concat(".")
                .concat(RuntimeRegistratorFtlTemplate.getJavaNameOfRuntimeRegistrator(rootEntry));
        implementedIfcs.add(RuntimeBeanRegistratorAwareModule.class
                .getCanonicalName());
    }

    final List<String> extendedClasses = Collections.singletonList(AbstractModule.class.getCanonicalName() + "<" + mbe.getAbstractModuleName() + ">");

    final AbstractModuleTemplate abstractModuleTemplate = new AbstractModuleTemplate(
            getHeaderFromEntry(mbe), mbe.getPackageName(),
            mbe.getAbstractModuleName(), extendedClasses, implementedIfcs, moduleFields,
            attrProcessor.getMethods(), generateRuntime,
            registratorFullyQualifiedName);

    if (mbe.getNullableDescription() != null) {
        abstractModuleTemplate.getAnnotations().add(
                Annotation.createDescriptionAnnotation(mbe
                        .getNullableDescription()));
    }
    return abstractModuleTemplate;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:43,代码来源:TemplateFactory.java

示例8: Holder

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
private Holder(final List<ModuleField> moduleFields, final List<MethodDefinition> methods) {
    this.moduleFields = Collections.unmodifiableList(moduleFields);
    this.methods = Collections.unmodifiableList(methods);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:TemplateFactory.java

示例9: getModuleFields

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
List<ModuleField> getModuleFields() {
    return this.holder.moduleFields;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:4,代码来源:TemplateFactory.java

示例10: getModuleFields

import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField; //导入依赖的package包/类
public List<ModuleField> getModuleFields() {
    return moduleFields;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:4,代码来源:AbstractModuleTemplate.java


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