2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.yangjmxgenerator;
10 import static com.google.common.base.Preconditions.checkNotNull;
11 import static com.google.common.base.Preconditions.checkState;
12 import static java.lang.String.format;
13 import static org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName;
15 import java.util.Arrays;
16 import java.util.Collection;
17 import java.util.Collections;
18 import java.util.HashMap;
20 import java.util.Map.Entry;
22 import java.util.regex.Matcher;
23 import java.util.regex.Pattern;
25 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
26 import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
27 import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
28 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
29 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
30 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.FullyQualifiedNameHelper;
31 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException;
32 import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
33 import org.opendaylight.yangtools.yang.common.QName;
34 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
35 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
36 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
37 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
38 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
39 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
40 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
41 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
42 import org.opendaylight.yangtools.yang.model.api.Module;
43 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
44 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
45 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
46 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
47 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
48 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
49 import org.opendaylight.yangtools.yang.model.api.UsesNode;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
53 import com.google.common.annotations.VisibleForTesting;
54 import com.google.common.collect.Sets;
57 * Represents part of yang model that describes a module.
64 * identity threadpool-dynamic {
65 * base config:module-type;
66 * description "threadpool-dynamic description";
67 * config:provided-service "th2:threadpool";
68 * config:provided-service "th2:scheduled-threadpool";
69 * config:java-name-prefix DynamicThreadPool
71 * augment "/config:modules/config:module/config:module-type" {
72 * case threadpool-dynamic {
73 * when "/config:modules/config:module/config:module-type = 'threadpool-dynamic'";
75 * container "configuration" {
76 * // regular java attribute
83 * container threadfactory {
84 * uses config:service-ref {
86 * config:required-identity th:threadfactory;
97 public class ModuleMXBeanEntry extends AbstractEntry {
98 private static final Logger logger = LoggerFactory
99 .getLogger(ModuleMXBeanEntry.class);
101 // TODO: the XPath should be parsed by code generator IMO
102 private static final String MAGIC_STRING = "MAGIC_STRING";
103 private static final String MODULE_CONDITION_XPATH_TEMPLATE = "^/MAGIC_STRING:modules/MAGIC_STRING:module/MAGIC_STRING:type\\s*=\\s*['\"](.+)['\"]$";
104 private static final SchemaPath expectedConfigurationAugmentationSchemaPath = new SchemaPath(
105 Arrays.asList(createConfigQName("modules"),
106 createConfigQName("module"),
107 createConfigQName("configuration")), true);
108 private static final SchemaPath expectedStateAugmentationSchemaPath = new SchemaPath(
109 Arrays.asList(createConfigQName("modules"),
110 createConfigQName("module"), createConfigQName("state")),
113 private static final Pattern PREFIX_COLON_LOCAL_NAME = Pattern
114 .compile("^(.+):(.+)$");
116 private static final String MODULE_SUFFIX = "Module";
117 private static final String FACTORY_SUFFIX = MODULE_SUFFIX + "Factory";
118 private static final String CLASS_NAME_SUFFIX = MODULE_SUFFIX + "MXBean";
119 private static final String ABSTRACT_PREFIX = "Abstract";
122 * threadpool-dynamic from the example above, taken from when condition, not
125 private final String globallyUniqueName;
127 private Map<String, AttributeIfc> yangToAttributes;
129 private final String nullableDescription, packageName, javaNamePrefix,
132 private final Map<String, String> providedServices;
134 private Collection<RuntimeBeanEntry> runtimeBeans;
136 public ModuleMXBeanEntry(IdentitySchemaNode id,
137 Map<String, AttributeIfc> yangToAttributes, String packageName,
138 Map<String, String> providedServices2, String javaNamePrefix,
139 String namespace, Collection<RuntimeBeanEntry> runtimeBeans) {
140 this.globallyUniqueName = id.getQName().getLocalName();
141 this.yangToAttributes = yangToAttributes;
142 this.nullableDescription = id.getDescription();
143 this.packageName = packageName;
144 this.javaNamePrefix = checkNotNull(javaNamePrefix);
145 this.namespace = checkNotNull(namespace);
146 this.providedServices = Collections.unmodifiableMap(providedServices2);
147 this.runtimeBeans = runtimeBeans;
150 public String getMXBeanInterfaceName() {
151 return javaNamePrefix + CLASS_NAME_SUFFIX;
154 public String getStubFactoryName() {
155 return javaNamePrefix + FACTORY_SUFFIX;
158 public String getAbstractFactoryName() {
159 return ABSTRACT_PREFIX + getStubFactoryName();
162 public String getStubModuleName() {
163 return javaNamePrefix + MODULE_SUFFIX;
166 public String getAbstractModuleName() {
167 return ABSTRACT_PREFIX + getStubModuleName();
170 public String getFullyQualifiedName(String typeName) {
171 return FullyQualifiedNameHelper.getFullyQualifiedName(packageName,
175 public String getGloballyUniqueName() {
176 return globallyUniqueName;
179 public String getPackageName() {
183 public Map<String, String> getProvidedServices() {
184 return providedServices;
187 public void setRuntimeBeans(Collection<RuntimeBeanEntry> newRuntimeBeans) {
188 runtimeBeans = newRuntimeBeans;
191 public Collection<RuntimeBeanEntry> getRuntimeBeans() {
195 public String getJavaNamePrefix() {
196 return javaNamePrefix;
199 public String getNamespace() {
204 static Matcher getWhenConditionMatcher(String prefix,
205 RevisionAwareXPath whenConstraint) {
206 String xpathRegex = MODULE_CONDITION_XPATH_TEMPLATE.replace(
207 MAGIC_STRING, prefix);
208 Pattern pattern = Pattern.compile(xpathRegex);
209 return pattern.matcher(whenConstraint.toString());
212 static String getConfigModulePrefixFromImport(Module currentModule) {
213 for (ModuleImport currentImport : currentModule.getImports()) {
214 if (currentImport.getModuleName().equals(
215 ConfigConstants.CONFIG_MODULE)) {
216 return currentImport.getPrefix();
219 throw new IllegalArgumentException("Cannot find import "
220 + ConfigConstants.CONFIG_MODULE + " in " + currentModule);
224 * Transform module to zero or more ModuleMXBeanEntry instances. Each
225 * instance must have a globally unique local name.
227 * @return Map of identity local names as keys, and ModuleMXBeanEntry
228 * instances as values
230 public static Map<String/* identity local name */, ModuleMXBeanEntry> create(
231 Module currentModule,
232 Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
233 SchemaContext schemaContext,
234 TypeProviderWrapper typeProviderWrapper, String packageName) {
235 Map<String, QName> uniqueGeneratedClassesNames = new HashMap<>();
236 logger.debug("Generating ModuleMXBeans of {} to package {}",
237 currentModule.getNamespace(), packageName);
238 String configModulePrefix;
240 configModulePrefix = getConfigModulePrefixFromImport(currentModule);
241 } catch (IllegalArgumentException e) {
242 // this module does not import config module
243 return Collections.emptyMap();
246 // get identities of base config:module-type
247 Map<String, IdentitySchemaNode> moduleIdentities = new HashMap<>();
249 for (IdentitySchemaNode id : currentModule.getIdentities()) {
250 if (id.getBaseIdentity() != null
251 && ConfigConstants.MODULE_TYPE_Q_NAME.equals(id
252 .getBaseIdentity().getQName())) {
253 String identityLocalName = id.getQName().getLocalName();
254 if (moduleIdentities.containsKey(identityLocalName)) {
255 throw new IllegalStateException(
256 "Module name already defined in this module: "
257 + identityLocalName);
259 moduleIdentities.put(identityLocalName, id);
260 logger.debug("Found identity {}", identityLocalName);
262 // validation check on unknown schema nodes
263 boolean providedServiceWasSet = false;
264 for (UnknownSchemaNode unknownNode : id.getUnknownSchemaNodes()) {
266 if (ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME
267 .equals(unknownNode.getNodeType())) {
268 // no op: 0 or more provided identities are allowed
269 } else if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME
270 .equals(unknownNode.getNodeType())) {
273 providedServiceWasSet == false,
274 format("More than one language extension %s is not allowed here: %s",
275 ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME,
277 providedServiceWasSet = true;
279 throw new IllegalStateException(
280 "Unexpected language extension "
281 + unknownNode.getNodeType());
286 Map<String, ModuleMXBeanEntry> result = new HashMap<>();
287 // each module name should have an augmentation defined
288 Map<String, IdentitySchemaNode> unaugmentedModuleIdentities = new HashMap<>(
290 for (AugmentationSchema augmentation : currentModule.getAugmentations()) {
291 Set<DataSchemaNode> childNodes = augmentation.getChildNodes();
292 if (childNodes.size() == 1) {
293 DataSchemaNode when = childNodes.iterator().next();
294 if (when instanceof ChoiceCaseNode) {
295 ChoiceCaseNode choiceCaseNode = (ChoiceCaseNode) when;
296 if (choiceCaseNode.getConstraints() == null
297 || choiceCaseNode.getConstraints()
298 .getWhenCondition() == null) {
301 RevisionAwareXPath xPath = choiceCaseNode.getConstraints()
303 Matcher matcher = getWhenConditionMatcher(
304 configModulePrefix, xPath);
305 if (matcher.matches() == false) {
308 String moduleLocalNameFromXPath = matcher.group(1);
309 IdentitySchemaNode moduleIdentity = moduleIdentities
310 .get(moduleLocalNameFromXPath);
311 unaugmentedModuleIdentities
312 .remove(moduleLocalNameFromXPath);
313 checkState(moduleIdentity != null, "Cannot find identity "
314 + moduleLocalNameFromXPath
315 + " matching augmentation " + augmentation);
316 Map<String, String> providedServices = findProvidedServices(
317 moduleIdentity, currentModule, qNamesToSIEs,
320 if (moduleIdentity == null) {
321 throw new IllegalStateException(
322 "Cannot find identity specified by augmentation xpath constraint: "
323 + moduleLocalNameFromXPath + " of "
326 String javaNamePrefix = findJavaNamePrefix(moduleIdentity);
328 Map<String, AttributeIfc> yangToAttributes = null;
330 Collection<RuntimeBeanEntry> runtimeBeans = null;
332 if (expectedConfigurationAugmentationSchemaPath
333 .equals(augmentation.getTargetPath())) {
334 logger.debug("Parsing configuration of {}",
335 moduleLocalNameFromXPath);
336 yangToAttributes = fillConfiguration(choiceCaseNode,
337 currentModule, typeProviderWrapper,
338 qNamesToSIEs, schemaContext);
339 checkUniqueAttributesWithGeneratedClass(
340 uniqueGeneratedClassesNames, when.getQName(),
342 } else if (expectedStateAugmentationSchemaPath
343 .equals(augmentation.getTargetPath())) {
344 logger.debug("Parsing state of {}",
345 moduleLocalNameFromXPath);
347 runtimeBeans = fillRuntimeBeans(choiceCaseNode,
348 currentModule, typeProviderWrapper,
349 packageName, moduleLocalNameFromXPath,
351 } catch (NameConflictException e) {
352 throw new NameConflictException(
353 e.getConflictingName(), when.getQName(),
357 checkUniqueRuntimeBeansGeneratedClasses(
358 uniqueGeneratedClassesNames, when, runtimeBeans);
359 Set<RuntimeBeanEntry> runtimeBeanEntryValues = Sets
360 .newHashSet(runtimeBeans);
361 for (RuntimeBeanEntry entry : runtimeBeanEntryValues) {
362 checkUniqueAttributesWithGeneratedClass(
363 uniqueGeneratedClassesNames,
365 entry.getYangPropertiesToTypesMap());
369 throw new IllegalArgumentException(
370 "Cannot parse augmentation " + augmentation);
372 if (result.containsKey(moduleLocalNameFromXPath)) {
373 // either fill runtimeBeans or yangToAttributes
374 ModuleMXBeanEntry moduleMXBeanEntry = result
375 .get(moduleLocalNameFromXPath);
376 if (yangToAttributes != null
377 && moduleMXBeanEntry.getAttributes() == null) {
379 .setYangToAttributes(yangToAttributes);
380 } else if (runtimeBeans != null
381 && moduleMXBeanEntry.getRuntimeBeans() == null) {
382 moduleMXBeanEntry.setRuntimeBeans(runtimeBeans);
385 // construct ModuleMXBeanEntry
386 ModuleMXBeanEntry moduleMXBeanEntry = new ModuleMXBeanEntry(
387 moduleIdentity, yangToAttributes, packageName,
388 providedServices, javaNamePrefix, currentModule
389 .getNamespace().toString(),
391 moduleMXBeanEntry.setYangModuleName(currentModule
394 .setYangModuleLocalname(moduleLocalNameFromXPath);
395 result.put(moduleLocalNameFromXPath, moduleMXBeanEntry);
397 } // skip if child node is not ChoiceCaseNode
398 } // skip if childNodes != 1
401 for (Entry<String, ModuleMXBeanEntry> entry : result.entrySet()) {
402 ModuleMXBeanEntry module = entry.getValue();
403 if (module.getAttributes() == null) {
404 module.setYangToAttributes(Collections
405 .<String, AttributeIfc> emptyMap());
406 } else if (module.getRuntimeBeans() == null) {
407 module.setRuntimeBeans(Collections
408 .<RuntimeBeanEntry> emptyList());
411 if (unaugmentedModuleIdentities.size() > 0) {
412 logger.warn("Augmentation not found for all module identities: {}",
413 unaugmentedModuleIdentities.keySet());
416 logger.debug("Number of ModuleMXBeans to be generated: {}",
421 private static void checkUniqueRuntimeBeansGeneratedClasses(
422 Map<String, QName> uniqueGeneratedClassesNames,
423 DataSchemaNode when, Collection<RuntimeBeanEntry> runtimeBeans) {
424 for (RuntimeBeanEntry runtimeBean : runtimeBeans) {
425 final String javaNameOfRuntimeMXBean = runtimeBean
426 .getJavaNameOfRuntimeMXBean();
427 if (uniqueGeneratedClassesNames
428 .containsKey(javaNameOfRuntimeMXBean)) {
429 QName firstDefinedQName = uniqueGeneratedClassesNames
430 .get(javaNameOfRuntimeMXBean);
431 throw new NameConflictException(javaNameOfRuntimeMXBean,
432 firstDefinedQName, when.getQName());
434 uniqueGeneratedClassesNames.put(javaNameOfRuntimeMXBean,
439 private static void checkUniqueAttributesWithGeneratedClass(
440 Map<String, QName> uniqueGeneratedClassNames, QName parentQName,
441 Map<String, AttributeIfc> yangToAttributes) {
442 for (Entry<String, AttributeIfc> attr : yangToAttributes.entrySet()) {
443 if (attr.getValue() instanceof TOAttribute) {
444 checkUniqueTOAttr(uniqueGeneratedClassNames, parentQName,
445 (TOAttribute) attr.getValue());
446 } else if (attr.getValue() instanceof ListAttribute
447 && ((ListAttribute) attr.getValue()).getInnerAttribute() instanceof TOAttribute) {
448 checkUniqueTOAttr(uniqueGeneratedClassNames, parentQName,
449 (TOAttribute) ((ListAttribute) attr.getValue())
450 .getInnerAttribute());
455 private static void checkUniqueTOAttr(
456 Map<String, QName> uniqueGeneratedClassNames, QName parentQName,
458 final String upperCaseCammelCase = attr.getUpperCaseCammelCase();
459 if (uniqueGeneratedClassNames.containsKey(upperCaseCammelCase)) {
460 QName firstDefinedQName = uniqueGeneratedClassNames
461 .get(upperCaseCammelCase);
462 throw new NameConflictException(upperCaseCammelCase,
463 firstDefinedQName, parentQName);
465 uniqueGeneratedClassNames.put(upperCaseCammelCase, parentQName);
469 private static Collection<RuntimeBeanEntry> fillRuntimeBeans(
470 ChoiceCaseNode choiceCaseNode, Module currentModule,
471 TypeProviderWrapper typeProviderWrapper, String packageName,
472 String moduleLocalNameFromXPath, String javaNamePrefix) {
474 return RuntimeBeanEntry.extractClassNameToRuntimeBeanMap(packageName,
475 choiceCaseNode, moduleLocalNameFromXPath, typeProviderWrapper,
476 javaNamePrefix, currentModule).values();
480 private static Map<String, AttributeIfc> fillConfiguration(
481 ChoiceCaseNode choiceCaseNode, Module currentModule,
482 TypeProviderWrapper typeProviderWrapper,
483 Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
484 SchemaContext schemaContext) {
485 Map<String, AttributeIfc> yangToAttributes = new HashMap<>();
486 for (DataSchemaNode attrNode : choiceCaseNode.getChildNodes()) {
487 AttributeIfc attributeValue = getAttributeValue(attrNode,
488 currentModule, qNamesToSIEs, typeProviderWrapper,
490 yangToAttributes.put(attributeValue.getAttributeYangName(),
493 return yangToAttributes;
496 private static Map<String, String> findProvidedServices(
497 IdentitySchemaNode moduleIdentity, Module currentModule,
498 Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
499 SchemaContext schemaContext) {
500 Map<String, String> result = new HashMap<>();
501 for (UnknownSchemaNode unknownNode : moduleIdentity
502 .getUnknownSchemaNodes()) {
503 if (ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME
504 .equals(unknownNode.getNodeType())) {
505 String prefixAndIdentityLocalName = unknownNode
507 ServiceInterfaceEntry sie = findSIE(prefixAndIdentityLocalName,
508 currentModule, qNamesToSIEs, schemaContext);
509 result.put(sie.getFullyQualifiedName(), sie.getQName()
517 * For input node, find if it contains config:java-name-prefix extension. If
518 * not found, convert local name of node converted to cammel case.
520 public static String findJavaNamePrefix(SchemaNode schemaNode) {
521 return convertToJavaName(schemaNode, true);
524 public static String findJavaParameter(SchemaNode schemaNode) {
525 return convertToJavaName(schemaNode, false);
528 public static String convertToJavaName(SchemaNode schemaNode,
529 boolean capitalizeFirstLetter) {
530 for (UnknownSchemaNode unknownNode : schemaNode.getUnknownSchemaNodes()) {
531 if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME
532 .equals(unknownNode.getNodeType())) {
533 String value = unknownNode.getNodeParameter();
534 return convertToJavaName(value, capitalizeFirstLetter);
537 return convertToJavaName(schemaNode.getQName().getLocalName(),
538 capitalizeFirstLetter);
541 public static String convertToJavaName(String localName,
542 boolean capitalizeFirstLetter) {
543 if (capitalizeFirstLetter) {
544 return BindingGeneratorUtil.parseToClassName(localName);
546 return BindingGeneratorUtil.parseToValidParamName(localName);
550 private static int getChildNodeSizeWithoutUses(ContainerSchemaNode csn) {
552 for (DataSchemaNode dsn : csn.getChildNodes()) {
553 if (dsn.isAddedByUses() == false)
559 private static AttributeIfc getAttributeValue(DataSchemaNode attrNode,
560 Module currentModule,
561 Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
562 TypeProviderWrapper typeProviderWrapper, SchemaContext schemaContext) {
564 if (attrNode instanceof LeafSchemaNode) {
566 LeafSchemaNode leaf = (LeafSchemaNode) attrNode;
567 return new JavaAttribute(leaf, typeProviderWrapper);
568 } else if (attrNode instanceof ContainerSchemaNode) {
570 ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) attrNode;
571 if (containerSchemaNode.getUses().size() == 1
572 && getChildNodeSizeWithoutUses(containerSchemaNode) == 0) {
574 UsesNode usesNode = containerSchemaNode.getUses().iterator()
576 checkState(usesNode.getRefines().size() == 1,
577 "Unexpected 'refine' child node size of "
578 + containerSchemaNode);
579 LeafSchemaNode refine = (LeafSchemaNode) usesNode.getRefines()
580 .values().iterator().next();
581 checkState(refine.getUnknownSchemaNodes().size() == 1,
582 "Unexpected unknown schema node size of " + refine);
583 UnknownSchemaNode requiredIdentity = refine
584 .getUnknownSchemaNodes().iterator().next();
586 ConfigConstants.REQUIRED_IDENTITY_EXTENSION_QNAME.equals(requiredIdentity
588 "Unexpected language extension " + requiredIdentity);
589 String prefixAndIdentityLocalName = requiredIdentity
591 // import should point to a module
592 ServiceInterfaceEntry serviceInterfaceEntry = findSIE(
593 prefixAndIdentityLocalName, currentModule,
594 qNamesToSIEs, schemaContext);
595 boolean mandatory = refine.getConstraints().isMandatory();
596 return new DependencyAttribute(attrNode, serviceInterfaceEntry,
597 mandatory, attrNode.getDescription());
599 return TOAttribute.create(containerSchemaNode,
600 typeProviderWrapper);
602 } else if (attrNode instanceof LeafListSchemaNode) {
603 return ListAttribute.create((LeafListSchemaNode) attrNode,
604 typeProviderWrapper);
605 } else if (attrNode instanceof ListSchemaNode) {
606 return ListAttribute.create((ListSchemaNode) attrNode,
607 typeProviderWrapper);
609 throw new UnsupportedOperationException(
610 "Unknown configuration node " + attrNode.toString());
614 private static ServiceInterfaceEntry findSIE(
615 String prefixAndIdentityLocalName, Module currentModule,
616 Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
617 SchemaContext schemaContext) {
619 Matcher m = PREFIX_COLON_LOCAL_NAME.matcher(prefixAndIdentityLocalName);
623 // if there is a prefix, look for ModuleImport with this prefix. Get
624 // Module from SchemaContext
625 String prefix = m.group(1);
626 ModuleImport moduleImport = findModuleImport(currentModule, prefix);
627 foundModule = schemaContext.findModuleByName(
628 moduleImport.getModuleName(), moduleImport.getRevision());
631 format("Module not found in SchemaContext by %s",
633 localSIName = m.group(2);
635 foundModule = currentModule; // no prefix => SIE is in currentModule
636 localSIName = prefixAndIdentityLocalName;
638 QName siQName = new QName(foundModule.getNamespace(),
639 foundModule.getRevision(), localSIName);
640 ServiceInterfaceEntry sie = qNamesToSIEs.get(siQName);
641 checkState(sie != null, "Cannot find referenced Service Interface by "
642 + prefixAndIdentityLocalName);
646 private static ModuleImport findModuleImport(Module module, String prefix) {
647 for (ModuleImport moduleImport : module.getImports()) {
648 if (moduleImport.getPrefix().equals(prefix)) {
652 throw new IllegalStateException(format(
653 "Import not found with prefix %s in %s", prefix, module));
656 public Map<String, AttributeIfc> getAttributes() {
657 return yangToAttributes;
660 private void setYangToAttributes(Map<String, AttributeIfc> newAttributes) {
661 this.yangToAttributes = newAttributes;
665 public String getNullableDescription() {
666 return nullableDescription;
670 public String toString() {
671 return "ModuleMXBeanEntry{" + "globallyUniqueName='"
672 + globallyUniqueName + '\'' + ", packageName='" + packageName