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


Java ModuleField.isDependent方法代码示例

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


在下文中一共展示了ModuleField.isDependent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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


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