InstanceIdentifierContext does not take generics
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / restconf / impl / ControllerContext.java
index 627a9d9db2d40e28a3d07cb54f4793c26ebb81e0..cc01ef9fe477410590be4a659429d6fdb701237e 100644 (file)
@@ -18,7 +18,6 @@ import com.google.common.collect.Iterables;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.Closeable;
 import java.io.UnsupportedEncodingException;
-import java.net.URI;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
@@ -36,7 +35,6 @@ import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.ws.rs.core.Response.Status;
-import org.apache.aries.blueprint.annotation.service.Reference;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
@@ -45,13 +43,14 @@ import org.opendaylight.netconf.sal.rest.api.Draft02;
 import org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
-import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.util.RestUtil;
 import org.opendaylight.yangtools.concepts.IllegalArgumentCodec;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
+import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
@@ -72,11 +71,10 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
+import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -104,10 +102,10 @@ public final class ControllerContext implements EffectiveModelContextListener, C
     private volatile DataNormalizer dataNormalizer;
 
     @Inject
-    public ControllerContext(final @Reference DOMSchemaService schemaService,
-            final @Reference DOMMountPointService mountService, final @Reference DOMSchemaService domSchemaService) {
+    public ControllerContext(final DOMSchemaService schemaService, final DOMMountPointService mountService,
+            final DOMSchemaService domSchemaService) {
         this.mountService = mountService;
-        this.yangTextSourceProvider = domSchemaService.getExtensions().getInstance(DOMYangTextSourceProvider.class);
+        yangTextSourceProvider = domSchemaService.getExtensions().getInstance(DOMYangTextSourceProvider.class);
 
         onModelContextUpdated(schemaService.getGlobalContext());
         listenerRegistration = schemaService.registerSchemaContextListener(this);
@@ -128,7 +126,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
 
     private void setGlobalSchema(final EffectiveModelContext globalSchema) {
         this.globalSchema = globalSchema;
-        this.dataNormalizer = new DataNormalizer(globalSchema);
+        dataNormalizer = new DataNormalizer(globalSchema);
     }
 
     public DOMYangTextSourceProvider getYangTextSourceProvider() {
@@ -136,7 +134,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
     }
 
     private void checkPreconditions() {
-        if (this.globalSchema == null) {
+        if (globalSchema == null) {
             throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE);
         }
     }
@@ -151,25 +149,24 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         onModelContextUpdated(schemas);
     }
 
-    public InstanceIdentifierContext<?> toInstanceIdentifier(final String restconfInstance) {
+    public InstanceIdentifierContext toInstanceIdentifier(final String restconfInstance) {
         return toIdentifier(restconfInstance, false);
     }
 
     public EffectiveModelContext getGlobalSchema() {
-        return this.globalSchema;
+        return globalSchema;
     }
 
-    public InstanceIdentifierContext<?> toMountPointIdentifier(final String restconfInstance) {
+    public InstanceIdentifierContext toMountPointIdentifier(final String restconfInstance) {
         return toIdentifier(restconfInstance, true);
     }
 
-    private InstanceIdentifierContext<?> toIdentifier(final String restconfInstance,
-                                                      final boolean toMountPointIdentifier) {
+    private InstanceIdentifierContext toIdentifier(final String restconfInstance,
+                                                   final boolean toMountPointIdentifier) {
         checkPreconditions();
 
         if (restconfInstance == null) {
-            return new InstanceIdentifierContext<>(YangInstanceIdentifier.empty(), this.globalSchema, null,
-                    this.globalSchema);
+            return new InstanceIdentifierContext(YangInstanceIdentifier.empty(), globalSchema, null, globalSchema);
         }
 
         final List<String> pathArgs = urlPathArgsDecode(SLASH_SPLITTER.split(restconfInstance));
@@ -186,14 +183,14 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         }
 
         final InstanceIdentifierBuilder builder = YangInstanceIdentifier.builder();
-        final Collection<? extends Module> latestModule = this.globalSchema.findModules(startModule);
+        final Collection<? extends Module> latestModule = globalSchema.findModules(startModule);
 
         if (latestModule.isEmpty()) {
             throw new RestconfDocumentedException("The module named '" + startModule + "' does not exist.",
                     ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
         }
 
-        final InstanceIdentifierContext<?> iiWithSchemaNode =
+        final InstanceIdentifierContext iiWithSchemaNode =
                 collectPathArguments(builder, pathArgs, latestModule.iterator().next(), null, toMountPointIdentifier);
 
         if (iiWithSchemaNode == null) {
@@ -228,42 +225,36 @@ public final class ControllerContext implements EffectiveModelContextListener, C
     public Module findModuleByName(final String moduleName) {
         checkPreconditions();
         checkArgument(moduleName != null && !moduleName.isEmpty());
-        return this.globalSchema.findModules(moduleName).stream().findFirst().orElse(null);
+        return globalSchema.findModules(moduleName).stream().findFirst().orElse(null);
     }
 
-    public Module findModuleByName(final DOMMountPoint mountPoint, final String moduleName) {
+    public static Module findModuleByName(final DOMMountPoint mountPoint, final String moduleName) {
         checkArgument(moduleName != null && mountPoint != null);
 
-        final SchemaContext mountPointSchema = getModelContext(mountPoint);
-        if (mountPointSchema == null) {
-            return null;
-        }
-
-        return mountPointSchema.findModules(moduleName).stream().findFirst().orElse(null);
+        final EffectiveModelContext mountPointSchema = getModelContext(mountPoint);
+        return mountPointSchema == null ? null
+            : mountPointSchema.findModules(moduleName).stream().findFirst().orElse(null);
     }
 
-    public Module findModuleByNamespace(final URI namespace) {
+    public Module findModuleByNamespace(final XMLNamespace namespace) {
         checkPreconditions();
         checkArgument(namespace != null);
-        return this.globalSchema.findModules(namespace).stream().findFirst().orElse(null);
+        return globalSchema.findModules(namespace).stream().findFirst().orElse(null);
     }
 
-    public Module findModuleByNamespace(final DOMMountPoint mountPoint, final URI namespace) {
+    public static Module findModuleByNamespace(final DOMMountPoint mountPoint, final XMLNamespace namespace) {
         checkArgument(namespace != null && mountPoint != null);
 
-        final SchemaContext mountPointSchema = getModelContext(mountPoint);
-        if (mountPointSchema == null) {
-            return null;
-        }
-
-        return mountPointSchema.findModules(namespace).stream().findFirst().orElse(null);
+        final EffectiveModelContext mountPointSchema = getModelContext(mountPoint);
+        return mountPointSchema == null ? null
+            : mountPointSchema.findModules(namespace).stream().findFirst().orElse(null);
     }
 
     public Module findModuleByNameAndRevision(final String name, final Revision revision) {
         checkPreconditions();
         checkArgument(name != null && revision != null);
 
-        return this.globalSchema.findModule(name, revision).orElse(null);
+        return globalSchema.findModule(name, revision).orElse(null);
     }
 
     public Module findModuleByNameAndRevision(final DOMMountPoint mountPoint, final String name,
@@ -271,7 +262,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         checkPreconditions();
         checkArgument(name != null && revision != null && mountPoint != null);
 
-        final SchemaContext schemaContext = getModelContext(mountPoint);
+        final EffectiveModelContext schemaContext = getModelContext(mountPoint);
         return schemaContext == null ? null : schemaContext.findModule(name, revision).orElse(null);
     }
 
@@ -281,7 +272,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         final Iterable<PathArgument> elements = path.getPathArguments();
         final PathArgument head = elements.iterator().next();
         final QName startQName = head.getNodeType();
-        final Module initialModule = this.globalSchema.findModule(startQName.getModule()).orElse(null);
+        final Module initialModule = globalSchema.findModule(startQName.getModule()).orElse(null);
         DataNodeContainer node = initialModule;
         for (final PathArgument element : elements) {
             final QName _nodeType = element.getNodeType();
@@ -302,11 +293,11 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         final StringBuilder builder = new StringBuilder();
         final PathArgument head = elements.iterator().next();
         final QName startQName = head.getNodeType();
-        final SchemaContext schemaContext;
+        final EffectiveModelContext schemaContext;
         if (mount != null) {
             schemaContext = getModelContext(mount);
         } else {
-            schemaContext = this.globalSchema;
+            schemaContext = globalSchema;
         }
         final Module initialModule = schemaContext.findModule(startQName.getModule()).orElse(null);
         DataNodeContainer node = initialModule;
@@ -327,69 +318,58 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         return builder.toString();
     }
 
-    public String findModuleNameByNamespace(final URI namespace) {
+    public String findModuleNameByNamespace(final XMLNamespace namespace) {
         checkPreconditions();
 
         final Module module = this.findModuleByNamespace(namespace);
         return module == null ? null : module.getName();
     }
 
-    public String findModuleNameByNamespace(final DOMMountPoint mountPoint, final URI namespace) {
-        final Module module = this.findModuleByNamespace(mountPoint, namespace);
+    public static String findModuleNameByNamespace(final DOMMountPoint mountPoint, final XMLNamespace namespace) {
+        final Module module = findModuleByNamespace(mountPoint, namespace);
         return module == null ? null : module.getName();
     }
 
-    public URI findNamespaceByModuleName(final String moduleName) {
+    public XMLNamespace findNamespaceByModuleName(final String moduleName) {
         final Module module = this.findModuleByName(moduleName);
         return module == null ? null : module.getNamespace();
     }
 
-    public URI findNamespaceByModuleName(final DOMMountPoint mountPoint, final String moduleName) {
-        final Module module = this.findModuleByName(mountPoint, moduleName);
+    public static XMLNamespace findNamespaceByModuleName(final DOMMountPoint mountPoint, final String moduleName) {
+        final Module module = findModuleByName(mountPoint, moduleName);
         return module == null ? null : module.getNamespace();
     }
 
     public Collection<? extends Module> getAllModules(final DOMMountPoint mountPoint) {
         checkPreconditions();
 
-        final SchemaContext schemaContext = mountPoint == null ? null : getModelContext(mountPoint);
+        final EffectiveModelContext schemaContext = mountPoint == null ? null : getModelContext(mountPoint);
         return schemaContext == null ? null : schemaContext.getModules();
     }
 
     public Collection<? extends Module> getAllModules() {
         checkPreconditions();
-        return this.globalSchema.getModules();
+        return globalSchema.getModules();
     }
 
-    private static CharSequence toRestconfIdentifier(final SchemaContext context, final QName qname) {
+    private static String toRestconfIdentifier(final EffectiveModelContext context, final QName qname) {
         final Module schema = context.findModule(qname.getModule()).orElse(null);
         return schema == null ? null : schema.getName() + ':' + qname.getLocalName();
     }
 
-    public CharSequence toRestconfIdentifier(final QName qname, final DOMMountPoint mount) {
-        final SchemaContext schema;
-        if (mount != null) {
-            schema = getModelContext(mount);
-        } else {
-            checkPreconditions();
-            schema = this.globalSchema;
-        }
-
-        return toRestconfIdentifier(schema, qname);
+    public String toRestconfIdentifier(final QName qname, final DOMMountPoint mountPoint) {
+        return mountPoint != null ? toRestconfIdentifier(getModelContext(mountPoint), qname)
+            : toRestconfIdentifier(qname);
     }
 
-    public CharSequence toRestconfIdentifier(final QName qname) {
+    public String toRestconfIdentifier(final QName qname) {
         checkPreconditions();
 
-        return toRestconfIdentifier(this.globalSchema, qname);
+        return toRestconfIdentifier(globalSchema, qname);
     }
 
-    public CharSequence toRestconfIdentifier(final DOMMountPoint mountPoint, final QName qname) {
-        if (mountPoint == null) {
-            return null;
-        }
-
-        return toRestconfIdentifier(getModelContext(mountPoint), qname);
+    public static String toRestconfIdentifier(final DOMMountPoint mountPoint, final QName qname) {
+        return mountPoint == null ? null : toRestconfIdentifier(getModelContext(mountPoint), qname);
     }
 
     public Module getRestconfModule() {
@@ -481,7 +461,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
     }
 
     private static DataSchemaNode childByQName(final CaseSchemaNode container, final QName name) {
-        return container.getDataChildByName(name);
+        return container.dataChildByName(name);
     }
 
     private static DataSchemaNode childByQName(final ContainerSchemaNode container, final QName name) {
@@ -521,7 +501,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
     }
 
     private static DataSchemaNode dataNodeChildByQName(final DataNodeContainer container, final QName name) {
-        final DataSchemaNode ret = container.getDataChildByName(name);
+        final DataSchemaNode ret = container.dataChildByName(name);
         if (ret == null) {
             for (final DataSchemaNode node : container.getChildNodes()) {
                 if (node instanceof ChoiceSchemaNode) {
@@ -543,7 +523,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
     }
 
     @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification = "Unrecognised NullableDecl")
-    private InstanceIdentifierContext<?> collectPathArguments(final InstanceIdentifierBuilder builder,
+    private InstanceIdentifierContext collectPathArguments(final InstanceIdentifierBuilder builder,
             final List<String> strings, final DataNodeContainer parentNode, final DOMMountPoint mountPoint,
             final boolean returnJustMountPoint) {
         requireNonNull(strings);
@@ -554,7 +534,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
 
         if (strings.isEmpty()) {
             return createContext(builder.build(), (DataSchemaNode) parentNode, mountPoint,
-                mountPoint != null ? getModelContext(mountPoint) : this.globalSchema);
+                mountPoint != null ? getModelContext(mountPoint) : globalSchema);
         }
 
         final String head = strings.iterator().next();
@@ -575,15 +555,15 @@ public final class ControllerContext implements EffectiveModelContextListener, C
                             ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED);
                 }
 
-                if (this.mountService == null) {
+                if (mountService == null) {
                     throw new RestconfDocumentedException(
                             "MountService was not found. Finding behind mount points does not work.",
                             ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED);
                 }
 
-                final YangInstanceIdentifier partialPath = this.dataNormalizer.toNormalized(builder.build());
-                final Optional<DOMMountPoint> mountOpt = this.mountService.getMountPoint(partialPath);
-                if (!mountOpt.isPresent()) {
+                final YangInstanceIdentifier partialPath = dataNormalizer.toNormalized(builder.build());
+                final Optional<DOMMountPoint> mountOpt = mountService.getMountPoint(partialPath);
+                if (mountOpt.isEmpty()) {
                     LOG.debug("Instance identifier to missing mount point: {}", partialPath);
                     throw new RestconfDocumentedException("Mount point does not exist.", ErrorType.PROTOCOL,
                             ErrorTag.DATA_MISSING);
@@ -597,8 +577,8 @@ public final class ControllerContext implements EffectiveModelContextListener, C
                 }
 
                 if (returnJustMountPoint || strings.size() == 1) {
-                    final YangInstanceIdentifier instance = YangInstanceIdentifier.builder().build();
-                    return new InstanceIdentifierContext<>(instance, mountPointSchema, mount, mountPointSchema);
+                    return new InstanceIdentifierContext(YangInstanceIdentifier.empty(), mountPointSchema, mount,
+                        mountPointSchema);
                 }
 
                 final String moduleNameBehindMountPoint = toModuleName(strings.get(1));
@@ -623,7 +603,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
             Module module = null;
             if (mountPoint == null) {
                 checkPreconditions();
-                module = this.globalSchema.findModules(moduleName).stream().findFirst().orElse(null);
+                module = globalSchema.findModules(moduleName).stream().findFirst().orElse(null);
                 if (module == null) {
                     throw new RestconfDocumentedException("\"" + moduleName + "\" module does not exist.",
                             ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
@@ -652,8 +632,8 @@ public final class ControllerContext implements EffectiveModelContextListener, C
                     rpc = getRpcDefinition(module, rpcName);
                 }
                 if (rpc != null) {
-                    return new InstanceIdentifierContext<>(builder.build(), rpc, mountPoint,
-                            mountPoint != null ? getModelContext(mountPoint) : this.globalSchema);
+                    return new InstanceIdentifierContext(builder.build(), rpc, mountPoint,
+                            mountPoint != null ? getModelContext(mountPoint) : globalSchema);
                 }
             }
 
@@ -732,18 +712,18 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         }
 
         return createContext(builder.build(), targetNode, mountPoint,
-            mountPoint != null ? getModelContext(mountPoint) : this.globalSchema);
+            mountPoint != null ? getModelContext(mountPoint) : globalSchema);
     }
 
-    private static InstanceIdentifierContext<?> createContext(final YangInstanceIdentifier instance,
+    private static InstanceIdentifierContext createContext(final YangInstanceIdentifier instance,
             final DataSchemaNode dataSchemaNode, final DOMMountPoint mountPoint,
             final EffectiveModelContext schemaContext) {
         final YangInstanceIdentifier instanceIdentifier = new DataNormalizer(schemaContext).toNormalized(instance);
-        return new InstanceIdentifierContext<>(instanceIdentifier, dataSchemaNode, mountPoint, schemaContext);
+        return new InstanceIdentifierContext(instanceIdentifier, dataSchemaNode, mountPoint, schemaContext);
     }
 
     public static DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container,
-            final String name, final URI namespace) {
+            final String name, final XMLNamespace namespace) {
         requireNonNull(namespace);
 
         final Iterable<DataSchemaNode> result = Iterables.filter(findInstanceDataChildrenByName(container, name),
@@ -792,12 +772,13 @@ public final class ControllerContext implements EffectiveModelContextListener, C
             final DOMMountPoint mountPoint) {
         checkArgument(node instanceof LeafSchemaNode);
 
-        final SchemaContext schemaContext = mountPoint == null ? this.globalSchema : getModelContext(mountPoint);
+        final EffectiveModelContext schemaContext = mountPoint == null ? globalSchema : getModelContext(mountPoint);
         final String urlDecoded = urlPathArgDecode(requireNonNull(uriValue));
         TypeDefinition<?> typedef = ((LeafSchemaNode) node).getType();
         final TypeDefinition<?> baseType = RestUtil.resolveBaseTypeFrom(typedef);
         if (baseType instanceof LeafrefTypeDefinition) {
-            typedef = SchemaContextUtil.getBaseTypeForLeafRef((LeafrefTypeDefinition) baseType, schemaContext, node);
+            typedef = SchemaInferenceStack.ofInstantiatedPath(schemaContext, node.getPath())
+                .resolveLeafref((LeafrefTypeDefinition) baseType);
         }
         final IllegalArgumentCodec<Object, Object> codec = RestCodec.from(typedef, mountPoint, this);
         Object decoded = codec.deserialize(urlDecoded);
@@ -846,7 +827,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         return str.substring(idx + 1);
     }
 
-    private QName toQName(final SchemaContext schemaContext, final String name,
+    private QName toQName(final EffectiveModelContext schemaContext, final String name,
             final Optional<Revision> revisionDate) {
         checkPreconditions();
         final String module = toModuleName(name);
@@ -855,7 +836,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
         return m == null ? null : QName.create(m.getQNameModule(), node);
     }
 
-    private QName toQName(final SchemaContext schemaContext, final String name) {
+    private QName toQName(final EffectiveModelContext schemaContext, final String name) {
         checkPreconditions();
         final String module = toModuleName(name);
         final String node = toNodeName(name);
@@ -868,13 +849,13 @@ public final class ControllerContext implements EffectiveModelContextListener, C
     }
 
     public RpcDefinition getRpcDefinition(final String name, final Optional<Revision> revisionDate) {
-        final QName validName = toQName(this.globalSchema, name, revisionDate);
-        return validName == null ? null : this.qnameToRpc.get().get(validName);
+        final QName validName = toQName(globalSchema, name, revisionDate);
+        return validName == null ? null : qnameToRpc.get().get(validName);
     }
 
     public RpcDefinition getRpcDefinition(final String name) {
-        final QName validName = toQName(this.globalSchema, name);
-        return validName == null ? null : this.qnameToRpc.get().get(validName);
+        final QName validName = toQName(globalSchema, name);
+        return validName == null ? null : qnameToRpc.get().get(validName);
     }
 
     private static RpcDefinition getRpcDefinition(final Module module, final String rpcName) {
@@ -898,7 +879,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
             }
 
             // FIXME: still not completely atomic
-            this.qnameToRpc.set(ImmutableMap.copyOf(newMap));
+            qnameToRpc.set(ImmutableMap.copyOf(newMap));
             setGlobalSchema(context);
         }
     }
@@ -975,7 +956,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
 
     public YangInstanceIdentifier toNormalized(final YangInstanceIdentifier legacy) {
         try {
-            return this.dataNormalizer.toNormalized(legacy);
+            return dataNormalizer.toNormalized(legacy);
         } catch (final NullPointerException e) {
             throw new RestconfDocumentedException("Data normalizer isn't set. Normalization isn't possible", e);
         }
@@ -983,7 +964,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
 
     public YangInstanceIdentifier toXpathRepresentation(final YangInstanceIdentifier instanceIdentifier) {
         try {
-            return this.dataNormalizer.toLegacy(instanceIdentifier);
+            return dataNormalizer.toLegacy(instanceIdentifier);
         } catch (final NullPointerException e) {
             throw new RestconfDocumentedException("Data normalizer isn't set. Normalization isn't possible", e);
         } catch (final DataNormalizationException e) {
@@ -994,7 +975,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C
     public boolean isNodeMixin(final YangInstanceIdentifier path) {
         final DataNormalizationOperation<?> operation;
         try {
-            operation = this.dataNormalizer.getOperation(path);
+            operation = dataNormalizer.getOperation(path);
         } catch (final DataNormalizationException e) {
             throw new RestconfDocumentedException("Data normalizer failed. Normalization isn't possible", e);
         }