*/
package org.opendaylight.mdsal.binding.javav2.dom.codec.impl;
-import static org.opendaylight.yangtools.yang.binding.BindingMapping.toFirstUpper;
+import static org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer.normalizeSpecificIdentifier;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableSet;
import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base.BindingCodecContext;
import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.value.ReflectionBasedCodec;
import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifier;
-import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer;
import org.opendaylight.mdsal.binding.javav2.generator.yang.types.BaseYangTypes;
import org.opendaylight.yangtools.concepts.Codec;
-import org.opendaylight.yangtools.yang.binding.BindingMapping;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
if (subtype instanceof LeafrefTypeDefinition) {
addLeafrefValueCodec(unionCls, unionType, bindingCodecContext, values, subtype);
} else {
- final Method valueGetter = unionCls.getMethod("get" + JavaIdentifierNormalizer
- .normalizeSpecificIdentifier(subtype.getQName().getLocalName(), JavaIdentifier.CLASS));
+ final Method valueGetter = unionCls.getMethod("get"
+ + normalizeSpecificIdentifier(subtype.getQName().getLocalName(), JavaIdentifier.CLASS));
final Class<?> valueType = valueGetter.getReturnType();
final Codec<Object, Object> valueCodec = bindingCodecContext.getCodec(valueType, subtype);
values.add(new UnionValueOptionContext(unionCls, valueType, valueGetter, valueCodec));
} else {
dataNode = SchemaContextUtil.findDataSchemaNodeForRelativeXPath(schemaContext, module, unionType, xpath);
}
- final String className = BindingMapping.getClassName(unionCls.getSimpleName());
+
final LeafSchemaNode typeNode = (LeafSchemaNode) dataNode;
// prepare name of type form return type of referenced leaf
- final String typeName = BindingMapping.getClassName(BaseYangTypes.BASE_YANG_TYPES_PROVIDER
- .javaTypeForSchemaDefinitionType(typeNode.getType(), typeNode, null).getName());
+ final String typeName = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
+ .javaTypeForSchemaDefinitionType(typeNode.getType(), typeNode, null).getName();
// get method via reflection from generated code according to
// get_TypeName_Value method
- final String method = toFirstUpper(JavaIdentifierNormalizer.normalizeSpecificIdentifier(
- new StringBuilder(typeName).append(className).append("Value").toString(), JavaIdentifier.METHOD));
- final Method valueGetterParent = unionCls
- .getMethod(new StringBuilder("get").append(method).toString());
+ final String method = normalizeSpecificIdentifier(new StringBuilder("get").append("_")
+ .append(typeName).append(unionCls.getSimpleName()).append("Value").toString(),
+ JavaIdentifier.METHOD);
+ final Method valueGetterParent = unionCls.getMethod(method);
final Class<?> returnType = valueGetterParent.getReturnType();
// prepare codec of union subtype according to return type of referenced
+++ /dev/null
-module opendaylight-mdsal-binding-test {
-
- namespace "urn:opendaylight:params:xml:ns:yang:mdsal:test:binding";
- prefix list-test;
-
-
- description
- "This module contains a collection of YANG definitions used for
- some test cases.";
-
- revision 2014-07-01 {
- description
- "Test model for testing data broker with nested lists.";
- }
-
- typedef int32-string-union {
- type union {
- type int32;
- type string;
- }
- }
-
- identity test-root;
-
- identity test-one {
- base test-root;
- }
-
- identity test-two {
- base test-root;
- }
-
- typedef test-identityref {
- type identityref {
- base test-root;
- }
- }
-
- grouping two-level-list {
- list top-level-list {
- description
- "Top Level List";
- key "name";
- leaf name {
- type string;
- }
-
- choice choice-in-list {
- case simple-case {
- leaf simple {
- type string;
- }
- }
- }
-
- list nested-list {
- key "name";
- leaf name {
- type string;
- }
- leaf type {
- type string;
- mandatory true;
- description
- "Mandatory type of list.";
- }
- ordered-by user;
- description
- "A list of service functions that compose the service chain";
- }
- }
- leaf-list top-level-leaf-list {
- type string;
- }
-
- leaf-list top-level-ordered-leaf-list {
- type string;
- ordered-by user;
- }
- }
-
- grouping choice {
- choice identifier {
- case simple {
- container simple-id {
- leaf id {
- type int32;
- }
- }
- }
- case extended {
- container extended-id {
- leaf id {
- type string;
- }
- }
- }
- }
- }
-
- container top {
- uses two-level-list;
- }
-
- container choice-container {
- uses choice;
- }
-
- rpc put-top {
- input {
- uses two-level-list;
- }
- }
-
- notification two-level-list-changed {
- uses two-level-list;
- }
-
- rpc get-top {
- output {
- uses two-level-list;
- }
- }
-
- augment "/list-test:top" {
- leaf augmented-string {
- type string;
- }
- }
-
- augment "/list-test:top" {
- leaf augmented-int {
- type int32;
- }
- }
-}