private static boolean isInnerType(final LeafSchemaNode leaf, final TypeDefinition<?> type) { // New parser with encapsulated type if (leaf.getPath().equals(type.getPath())) { return true; } // Embedded type definition with new parser. Also takes care of the old parser with bits if (leaf.getPath().equals(type.getPath().getParent())) { return true; } return false; }
private static AugmentationSchema findCorrespondingAugment(final DataSchemaNode parent, final DataSchemaNode child) { if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) { for (final AugmentationSchema augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) { final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName()); if (childInAugmentation != null) { return augmentation; } } } return null; } }
private static boolean isFromAugment(final DataNodeContainer schema, final DataSchemaNode childSchema) { if (!(schema instanceof AugmentationTarget)) { return false; } for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) { if (augmentation.getDataChildByName(childSchema.getQName()) != null) { return true; } } return false; }
private Module findModuleFromImports(final Set<ModuleImport> imports, final String prefix) { for (final ModuleImport imp : imports) { if (imp.getPrefix().equals(prefix)) { return schemaContext.findModuleByName(imp.getModuleName(), imp.getRevision()); } } return null; }
public static String getGetterMethodName(final TypedDataSchemaNode node) { // Bug 8903: If it is a derived type of boolean or empty, not an inner type, then the return type // of method would be the generated type of typedef not build-in types, so here it should be 'get'. final TypeDefinition<?> type = node.getType(); return BindingMapping.getGetterMethodName(node.getQName(), (type instanceof BooleanTypeDefinition || type instanceof EmptyTypeDefinition) && (type.getPath().equals(node.getPath()) || type.getBaseType() == null)); } }
@Override protected String prefixForNamespace(final URI namespace) { final Module module = context.findModuleByNamespaceAndRevision(namespace, null); return module == null ? null : module.getName(); }
private static int getChildNodeSizeWithoutUses(final DataNodeContainer csn) { int result = 0; for (DataSchemaNode dsn : csn.getChildNodes()) { if (dsn.isAddedByUses() == false) { result++; } } return result; }
@Override public QName apply(final DataSchemaNode input) { return input.getQName(); } });
/** * Extracts the base type of leaf schema node until it reach concrete type of TypeDefinition. * * @param node * a node representing LeafSchemaNode * @return concrete type definition of node value */ private static TypeDefinition<?> typeDefinition(final LeafSchemaNode node) { TypeDefinition<?> baseType = node.getType(); while (baseType.getBaseType() != null) { baseType = baseType.getBaseType(); } return baseType; }
/** * Extracts the base type of leaf schema node until it reach concrete type of TypeDefinition. * * @param node * a node representing LeafListSchemaNode * @return concrete type definition of node value */ private static TypeDefinition<?> typeDefinition(final LeafListSchemaNode node) { TypeDefinition<?> baseType = node.getType(); while (baseType.getBaseType() != null) { baseType = baseType.getBaseType(); } return baseType; }
private static DataSchemaNode searchInCases(final ChoiceSchemaNode choiceNode, final QName arg) { Set<ChoiceCaseNode> cases = choiceNode.getCases(); for (ChoiceCaseNode caseNode : cases) { DataSchemaNode node = caseNode.getDataChildByName(arg); if (node != null) { return node; } } return null; }
@Override public Set<ChoiceCaseNode> apply(final ChoiceSchemaNode node) { return node.getCases(); } };
@Override public String toString() { return xpath.toString(); } }
private void processUsesAugments(final DataNodeContainer node, final ModuleContext context) { for (final UsesNode usesNode : node.getUses()) { for (final AugmentationSchemaNode augment : usesNode.getAugmentations()) { usesAugmentationToGenTypes(context, augment, usesNode, node); processUsesAugments(augment, context); } } }
/** * Checks if supplied schema node belong to specified Data Tree type. All nodes belong to the operational tree, * nodes in configuration tree are marked as such. * * @param treeType Tree Type * @param node Schema node * @return {@code true} if the node matches the tree type, {@code false} otherwise. */ static boolean belongsToTree(final TreeType treeType, final DataSchemaNode node) { return treeType == TreeType.OPERATIONAL || node.isConfiguration(); } }
/** * Returns the list of nodes which need to be traversed to get from the * starting point (root for absolute SchemaPaths) to the node represented * by this object. * * @return list of <code>qname</code> instances which represents * path from the root to the schema node. */ public Iterable<QName> getPathFromRoot() { return getLegacyPath(); }
private static boolean isFromAugment(final DataNodeContainer schema, final DataSchemaNode childSchema) { if (!(schema instanceof AugmentationTarget)) { return false; } for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) { if (augmentation.getDataChildByName(childSchema.getQName()) != null) { return true; } } return false; }
/** * Extracts the base type of leaf schema node until it reach concrete type of TypeDefinition. * * @param node * a node representing LeafSchemaNode * @return concrete type definition of node value */ private static TypeDefinition<?> typeDefinition(final LeafSchemaNode node) { TypeDefinition<?> baseType = node.getType(); while (baseType.getBaseType() != null) { baseType = baseType.getBaseType(); } return baseType; }
/** * Extracts the base type of leaf schema node until it reach concrete type of TypeDefinition. * * @param node * a node representing LeafListSchemaNode * @return concrete type definition of node value */ private static TypeDefinition<?> typeDefinition(final LeafListSchemaNode node) { TypeDefinition<?> baseType = node.getType(); while (baseType.getBaseType() != null) { baseType = baseType.getBaseType(); } return baseType; }