當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。