Remove AugmentationReader
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / UnionTypeCodec.java
index ff4873734f175b44370a84fb66c90c265c0d6b65..14065cc718f95e4da27075aa6242bc8087b159d4 100644 (file)
@@ -12,12 +12,12 @@ import java.lang.reflect.Method;
 import java.util.LinkedHashSet;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import org.opendaylight.mdsal.binding.yang.types.BaseYangTypes;
-import org.opendaylight.yangtools.concepts.Codec;
-import org.opendaylight.yangtools.yang.binding.BindingMapping;
+import org.opendaylight.mdsal.binding.generator.util.BaseYangTypes;
+import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
+import org.opendaylight.yangtools.concepts.IllegalArgumentCodec;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.PathExpression;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -41,10 +41,11 @@ final class UnionTypeCodec extends ReflectionBasedCodec {
                 if (subtype instanceof LeafrefTypeDefinition) {
                     addLeafrefValueCodec(unionCls, unionType, bindingCodecContext, values, subtype);
                 } else {
-                    final Method valueGetter =
-                            unionCls.getMethod("get" + BindingMapping.getClassName(subtype.getQName()));
+                    final Method valueGetter = unionCls.getMethod(BindingMapping.GETTER_PREFIX
+                        + BindingMapping.getClassName(subtype.getQName()));
                     final Class<?> valueType = valueGetter.getReturnType();
-                    final Codec<Object, Object> valueCodec = bindingCodecContext.getCodec(valueType, subtype);
+                    final IllegalArgumentCodec<Object, Object> valueCodec =
+                            bindingCodecContext.getCodec(valueType, subtype);
 
                     values.add(new UnionValueOptionContext(unionCls, valueType, valueGetter, valueCodec));
                 }
@@ -74,7 +75,7 @@ final class UnionTypeCodec extends ReflectionBasedCodec {
             final TypeDefinition<?> subtype) throws NoSuchMethodException {
         final SchemaContext schemaContext = bindingCodecContext.getRuntimeContext().getSchemaContext();
         final Module module = schemaContext.findModule(subtype.getQName().getModule()).get();
-        final RevisionAwareXPath xpath = ((LeafrefTypeDefinition) subtype).getPathStatement();
+        final PathExpression xpath = ((LeafrefTypeDefinition) subtype).getPathStatement();
         // find schema node in schema context by xpath of leafref
         final SchemaNode dataNode;
         if (xpath.isAbsolute()) {
@@ -91,13 +92,13 @@ final class UnionTypeCodec extends ReflectionBasedCodec {
 
         // get method via reflection from generated code according to
         // get_TypeName_Value method
-        final Method valueGetterParent = unionCls
-                .getMethod(new StringBuilder("get").append(typeName).append(className).append("Value").toString());
+        final Method valueGetterParent = unionCls.getMethod(new StringBuilder().append(BindingMapping.GETTER_PREFIX)
+            .append(typeName).append(className).append("Value").toString());
         final Class<?> returnType = valueGetterParent.getReturnType();
 
         // prepare codec of union subtype according to return type of referenced
         // leaf
-        final Codec<Object, Object> valueCodec = bindingCodecContext.getCodec(returnType, subtype);
+        final IllegalArgumentCodec<Object, Object> valueCodec = bindingCodecContext.getCodec(returnType, subtype);
         values.add(new UnionValueOptionContext(unionCls, returnType, valueGetterParent, valueCodec));
     }