import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;\r
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;\r
\r
+import java.net.URI;\r
+import java.net.URISyntaxException;\r
import java.util.ArrayList;\r
import java.util.Collections;\r
import java.util.Comparator;\r
import org.opendaylight.yangtools.yang.model.api.SchemaNode;\r
import org.opendaylight.yangtools.yang.model.api.SchemaPath;\r
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;\r
import org.opendaylight.yangtools.yang.model.api.UsesNode;\r
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;\r
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;\r
/**\r
* Only parent constructor is invoked.\r
*/\r
+ \r
+ private final static String YANG_EXT_NAMESPACE = "urn:opendaylight:yang:extension:yang-ext";\r
+ private final static String AUGMENT_IDENTIFIER_NAME = "augment-identifier";\r
+ \r
public BindingGeneratorImpl() {\r
super();\r
}\r
augmentBuilders = new HashMap<>();\r
genTypeBuilders.put(augmentPackageName, augmentBuilders);\r
}\r
-\r
- final String augTypeName = augGenTypeName(augmentBuilders, targetTypeName);\r
+ final String augIdentifier = getAugmentIdentifier(augSchema.getUnknownSchemaNodes());\r
+ \r
+ final String augTypeName = augIdentifier != null ? parseToClassName(augIdentifier): augGenTypeName(augmentBuilders, targetTypeName);\r
final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName, targetTypeName);\r
final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();\r
\r
return augTypeBuilder;\r
}\r
\r
+ private String getAugmentIdentifier(List<UnknownSchemaNode> unknownSchemaNodes) {\r
+ String ret = null;\r
+ for (UnknownSchemaNode unknownSchemaNode : unknownSchemaNodes) {\r
+ QName nodeType = unknownSchemaNode.getNodeType();\r
+ if(AUGMENT_IDENTIFIER_NAME.equals(nodeType.getLocalName()) &&\r
+ YANG_EXT_NAMESPACE.equals(nodeType.getNamespace().toString())) {\r
+ return unknownSchemaNode.getNodeParameter();\r
+ }\r
+ }\r
+ return ret;\r
+ }\r
+\r
/**\r
* Convert a container, list and choice subnodes (and recursivelly their\r
* subnodes) of augment to generated types\r
-module yang-ext {
- yang-version 1;
- namespace "urn:opendaylight:params:ns:yang:extension:yang-ext";
- prefix "ext";
-
- contact "Anton Tkacik <ttkacik@cisco.com>";
-
- revision "2013-07-09" {
- description "";
- }
-
- // Augmentation name
-
- extension "augment-identifier" {
- description
- "YANG language extension which assigns an identifier to
- augmentation. Augment identifier is used to identify
- specific augment statement by name.
-
- The identifier syntax is defined formally defined by the rule
- 'identifier' in Section 12 of RFC 6020.
-
- All augment identifiers defined in a namespace MUST be unique.
- The namespace of augment identifiers is shared by module and
- its submodules.
- ";
- /*
- Discussion:
- This extension allows for ease of development / debug
- of YANG modules and it is suitable for code generation,
- where each augment statement is nicely identified by
- unique name instead of combination of augment target
- and when condition.
- */
- argument "identifier";
- }
-
-
- // Context-aware RPCs
-
- grouping rpc-context-ref {
- description
- "A reference to RPC context.";
- leaf context-instance {
- type instance-identifier;
- description "Pointer to the context. ";
- }
- }
-
- extension "rpc-context-instance" {
- description
- "YANG language extension which defines enclosing (parent)
- schema node as referencable context for RPCs.
-
- The argument is identity which is used to identify RPC context
- type.";
-
- argument "context-type";
- }
+module yang-ext {\r
+ yang-version 1;\r
+ namespace "urn:opendaylight:yang:extension:yang-ext";\r
+ prefix "ext";\r
+ \r
+ contact "Anton Tkacik <ttkacik@cisco.com>";\r
+\r
+ revision "2013-07-09" {\r
+ description "";\r
+ }\r
+\r
+ // Augmentation name\r
+\r
+ extension "augment-identifier" {\r
+ description \r
+ "YANG language extension which assigns an identifier to \r
+ augmentation. Augment identifier is used to identify\r
+ specific augment statement by name. \r
+\r
+ The identifier syntax is defined formally defined by the rule\r
+ 'identifier' in Section 12 of RFC 6020.\r
+\r
+ All augment identifiers defined in a namespace MUST be unique.\r
+ The namespace of augment identifiers is shared by module and\r
+ its submodules. \r
+ ";\r
+ /*\r
+ Discussion:\r
+ This extension allows for ease of development / debug\r
+ of YANG modules and it is suitable for code generation,\r
+ where each augment statement is nicely identified by\r
+ unique name instead of combination of augment target\r
+ and when condition. \r
+ */\r
+ argument "identifier";\r
+ }\r
+\r
+\r
+ // Context-aware RPCs\r
+\r
+ grouping rpc-context-ref {\r
+ description \r
+ "A reference to RPC context.";\r
+ leaf context-instance {\r
+ type instance-identifier;\r
+ description "Pointer to the context. ";\r
+ }\r
+ }\r
+\r
+ extension "rpc-context-instance" {\r
+ description\r
+ "YANG language extension which defines enclosing (parent) \r
+ schema node as referencable context for RPCs.\r
+\r
+ The argument is identity which is used to identify RPC context\r
+ type.";\r
+\r
+ argument "context-type";\r
+ }\r
}
\ No newline at end of file