/** * Checks if <code>dataNode</code> is <code>LeafSchemaNode</code> and if it * so then checks if it is of type <code>EnumTypeDefinition</code>. * * @param dataNode * data schema node for which is checked if it is leaf and if it * is of enum type * @return boolean value * <ul> * <li>true - if <code>dataNode</code> is leaf of type enumeration</li> * <li>false - other cases</li> * </ul> */ private static boolean leafContainsEnumDefinition(final SchemaNode dataNode) { if (dataNode instanceof LeafSchemaNode) { final LeafSchemaNode leaf = (LeafSchemaNode) dataNode; if (leaf.getType() instanceof EnumTypeDefinition) { return true; } } return false; }
private void emitLeaf(final LeafSchemaNode child) { super.writer.startLeafNode(child.getQName()); child.getWhenCondition().ifPresent(this::emitWhen); // FIXME: BUG-2444: *(ifFeatureNode ) emitTypeNode(child.getPath(), child.getType()); child.getType().getUnits().ifPresent(this::emitUnitsNode); child.getMustConstraints().forEach(this::emitMust); child.getType().getDefaultValue().ifPresent(this::emitDefaultNode); emitConfigNode(child.isConfiguration()); emitMandatoryNode(child.isMandatory()); emitDocumentedNode(child); emitUnknownStatementNodes(child.getUnknownSchemaNodes()); super.writer.endNode(); }
private JSONObject processLeafNode(final LeafSchemaNode leafNode) throws JSONException { JSONObject property = new JSONObject(); String leafDescription = leafNode.getDescription(); property.put(DESCRIPTION_KEY, leafDescription); processConstraints(leafNode.getConstraints(), property); processTypeDef(leafNode.getType(), property); return property; }
public JavaAttribute(final LeafSchemaNode leaf, final TypeProviderWrapper typeProviderWrapper) { super(leaf); this.type = typeProviderWrapper.getType(leaf); this.typeDefinition = CompatUtils.compatLeafType(leaf); this.typeProviderWrapper = typeProviderWrapper; this.nullableDefault = leaf.getDefault(); this.nullableDefaultWrappedForCode = leaf.getDefault() == null ? null : typeProviderWrapper.getDefault(leaf); this.nullableDescription = leaf.getDescription(); }
protected LeafNormalization(final LeafSchemaNode potential) { super(new NodeIdentifier(potential.getQName()),potential); }
className = basePackageName + "." + BindingMapping.getClassName(typeQName); } else { final Iterator<QName> path = node.getPath().getPathFromRoot().iterator(); final QName first = path.next(); final Module parent = schemaContext.findModule(first.getModule()).orElse(null); if (!path.hasNext()) { parentName = BindingMapping.getClassName(parent.getName()) + "Data"; className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName()); } else { final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, UNION_PATH); className = packageName + "." + BindingMapping.getClassName(node.getQName()); return union(className, (String) node.getType().getDefaultValue().orElse(null), node);
Type returnType = null; if ((leaf != null) && (typeBuilder != null)) { final String leafName = leaf.getQName().getLocalName(); String leafDesc = leaf.getDescription(); if (leafDesc == null) { leafDesc = ""; if (leafName != null && !leaf.isAddedByUses()) { final TypeDefinition<?> typeDef = leaf.getType(); returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf); final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) typeDef; final EnumBuilder enumBuilder = resolveInnerEnumFromTypeDefinition(enumTypeDef, leaf.getQName(), typeBuilder,module); returnType = enumBuilder.toInstance(typeBuilder); ((TypeProviderImpl) typeProvider).putReferencedType(leaf.getPath(), returnType); } else if (typeDef instanceof UnionType) { genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leaf, parentModule);
String className; if (node.getType() instanceof ExtendedType) { ExtendedType type = (ExtendedType) node.getType(); QName typeQName = type.getQName(); Module module = null; className = basePackageName + "." + BindingMapping.getClassName(typeQName); } else { Iterator<QName> path = node.getPath().getPathFromRoot().iterator(); QName first = path.next(); if (!(path.hasNext())) { parentName = BindingMapping.getClassName((parent).getName()) + "Data"; String basePackageName = BindingMapping.getRootPackageName(parent.getQNameModule()); className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName()); } else { URI namespace = first.getNamespace(); Module parentModule = schemaContext.findModuleByNamespaceAndRevision(namespace, revision); String basePackageName = BindingMapping.getRootPackageName(parentModule.getQNameModule()); String packageName = packageNameForGeneratedType(basePackageName, node.getType().getPath()); className = packageName + "." + BindingMapping.getClassName(node.getQName()); return union(className, node.getDefault(), node);
public static CharSequence writeLeafSchemaNode(final LeafSchemaNode leafSchemaNode) { StringConcatenation _builder = new StringConcatenation(); _builder.append("leaf "); QName _qName = leafSchemaNode.getQName(); String _localName = _qName.getLocalName(); _builder.append(_localName, ""); _builder.append(" {"); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append("type "); TypeDefinition<?> _type = leafSchemaNode.getType(); QName _qName_1 = _type.getQName(); String _localName_1 = _qName_1.getLocalName(); _builder.append(_localName_1, " "); _builder.append(";"); _builder.newLineIfNotEmpty(); _builder.append("}"); _builder.newLine(); return _builder; }
private boolean resolveLeafSchemaNodeAsProperty(final GeneratedTOBuilder toBuilder, final LeafSchemaNode leaf, final boolean isReadOnly, final Module module) { if ((leaf != null) && (toBuilder != null)) { final String leafName = leaf.getQName().getLocalName(); String leafDesc = leaf.getDescription(); if (leafDesc == null) { leafDesc = ""; final TypeDefinition<?> typeDef = leaf.getType(); if (typeDef instanceof UnionTypeDefinition) { QName qname = originalLeaf.getQName(); final Module enumModule = schemaContext.findModuleByNamespaceAndRevision(qname.getNamespace(), qname.getRevision()); returnType = genCtx.get(enumModule).getInnerType(originalLeaf.getType().getPath()); } else { returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf);
private void emitRefineLeafNodes(final LeafSchemaNode value) { final LeafSchemaNode original = getOriginalChecked(value); // emitMustNodes(child.getConstraints().getMustConstraints()); if (Objects.deepEquals(original.getType().getDefaultValue(), value.getType().getDefaultValue())) { emitDefaultNode(value.getType().getDefaultValue()); } if (Objects.deepEquals(original.isConfiguration(), value.isConfiguration())) { emitConfigNode(value.isConfiguration()); } emitDocumentedNodeRefine(original, value); if (Objects.deepEquals(original.isMandatory(), value.isMandatory())) { emitMandatoryNode(value.isMandatory()); } }
if (leaf == null || typeBuilder == null || leaf.isAddedByUses()) { return null; returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf); final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) typeDef; final EnumBuilder enumBuilder = resolveInnerEnumFromTypeDefinition(enumTypeDef, leaf.getQName(), typeBuilder, context); if (enumBuilder != null) { returnType = enumBuilder.toInstance(typeBuilder); typeProvider.putReferencedType(leaf.getPath(), returnType); } else if (typeDef instanceof UnionTypeDefinition) { final UnionTypeDefinition unionDef = (UnionTypeDefinition)typeDef; returnType = typeProvider.javaTypeForSchemaDefinitionType(getBaseOrDeclaredType(typeDef), leaf, restrictions); addPatternConstant(typeBuilder, leaf.getQName().getLocalName(), restrictions.getPatternConstraints()); addPatternConstant(typeBuilder, leaf.getQName().getLocalName(), restrictions.getPatternConstraints()); typeProvider.putReferencedType(leaf.getPath(), returnType);
String className; final Module parent = getParentModule(node); final Iterator<QName> path = node.getPath().getPathFromRoot().iterator(); path.next(); if (!path.hasNext()) { parentName = BindingMapping.getClassName(parent.getName()) + "Data"; final String basePackageName = BindingMapping.getRootPackageName(parent.getQNameModule()); className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName()); } else { final String basePackageName = BindingMapping.getRootPackageName(parent.getQNameModule()); type.getPath()); parentName = BindingMapping.getClassName(parent.getName()); className = packageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName()); final String basePackageName = BindingMapping.getRootPackageName(parentModule.getQNameModule()); final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, node.getPath()); className = packageName + "." + BindingMapping.getClassName(node.getQName());
return false; final String leafName = leaf.getQName().getLocalName(); final String leafDesc = leaf.getDescription(); final GeneratedPropertyBuilder propBuilder = toBuilder.addProperty(BindingMapping.getPropertyName(leafName)); propBuilder.setReadOnly(isReadOnly);
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 void processContextRefExtension(final LeafSchemaNode leaf, final MethodSignatureBuilder getter, final Module module) { for (final UnknownSchemaNode node : leaf.getUnknownSchemaNodes()) { final QName nodeType = node.getNodeType(); if ("context-reference".equals(nodeType.getLocalName())) {
LeafSchemaNode refine = (LeafSchemaNode) usesNode.getRefines().values().iterator().next(); boolean mandatory = refine.getConstraints().isMandatory(); AbstractDependencyAttribute reference; if (dataNodeContainer instanceof ContainerSchemaNode) {
protected LeafContextNode(final LeafSchemaNode potential) { super(NodeIdentifier.create(potential.getQName()), potential); }
public String getTypeDefaultConstruction(final LeafSchemaNode node, final String defaultValue) { TypeDefinition<?> type = node.getType(); QName typeQName = type.getQName(); TypeDefinition<?> base = baseTypeDefForExtendedType(type); String className; Module parent = getParentModule(node); Iterator<QName> path = node.getPath().getPathFromRoot().iterator(); path.next(); if (!(path.hasNext())) { parentName = BindingMapping.getClassName(parent.getName()) + "Data"; String basePackageName = BindingMapping.getRootPackageName(parent.getQNameModule()); className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName()); } else { String basePackageName = BindingMapping.getRootPackageName(parent.getQNameModule()); String packageName = packageNameForGeneratedType(basePackageName, type.getPath()); parentName = BindingMapping.getClassName(parent.getName()); className = packageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName()); Module parentModule = getParentModule(node); String basePackageName = BindingMapping.getRootPackageName(parentModule.getQNameModule()); String packageName = packageNameForGeneratedType(basePackageName, node.getPath()); className = packageName + "." + BindingMapping.getClassName(node.getQName());
private boolean resolveLeafSchemaNodeAsProperty(final GeneratedTOBuilder toBuilder, final LeafSchemaNode leaf, final boolean isReadOnly) { if (leaf != null && toBuilder != null) { Type returnType; final TypeDefinition<?> typeDef = CompatUtils.compatLeafType(leaf); if (typeDef instanceof UnionTypeDefinition) { // GeneratedType for this type definition should have be already created final ModuleContext mc = moduleContext(typeDef.getQName().getModule()); returnType = mc.getTypedefs().get(typeDef.getPath()); if (returnType == null) { // This may still be an inner type, try to find it returnType = mc.getInnerType(typeDef.getPath()); } } else if (typeDef instanceof EnumTypeDefinition && typeDef.getBaseType() == null) { // Annonymous enumeration (already generated, since it is inherited via uses). LeafSchemaNode originalLeaf = (LeafSchemaNode) SchemaNodeUtils.getRootOriginalIfPossible(leaf); QName qname = originalLeaf.getQName(); returnType = moduleContext(qname.getModule()).getInnerType(originalLeaf.getType().getPath()); } else { returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf); } return resolveLeafSchemaNodeAsProperty(toBuilder, leaf, returnType, isReadOnly); } return false; }