Merge "Remove unused warnings suppressions"
authorTony Tkacik <ttkacik@cisco.com>
Thu, 20 Nov 2014 12:48:59 +0000 (12:48 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 20 Nov 2014 12:48:59 +0000 (12:48 +0000)
12 files changed:
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationSubscriptionService.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPoint.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTx.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnInstanceIdentifierTest.java

index 15f5d48a6f51f43decd567129ce5d0854cc9ddcb..da6349ac5386c75ef17a8120a8c5a10b16726367 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
 import static com.google.common.base.Preconditions.checkState;
-
+import com.google.common.base.Preconditions;
 import com.google.common.reflect.AbstractInvocationHandler;
 import com.google.common.reflect.Reflection;
 import java.lang.reflect.InvocationTargetException;
@@ -54,10 +54,10 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
     private final DeadlockMonitor deadlockMonitor;
     private final MBeanServer mBeanServer;
 
-    public DependencyResolverManager(TransactionIdentifier transactionIdentifier,
-                                     TransactionStatus transactionStatus,
-                                     ServiceReferenceReadableRegistry readableRegistry, CodecRegistry codecRegistry,
-                                     MBeanServer mBeanServer) {
+    public DependencyResolverManager(final TransactionIdentifier transactionIdentifier,
+                                     final TransactionStatus transactionStatus,
+                                     final ServiceReferenceReadableRegistry readableRegistry, final CodecRegistry codecRegistry,
+                                     final MBeanServer mBeanServer) {
         this.transactionIdentifier = transactionIdentifier;
         this.modulesHolder = new ModulesHolder(transactionIdentifier);
         this.transactionStatus = transactionStatus;
@@ -68,11 +68,11 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
     }
 
     @Override
-    public DependencyResolver createDependencyResolver(ModuleIdentifier moduleIdentifier) {
+    public DependencyResolver createDependencyResolver(final ModuleIdentifier moduleIdentifier) {
         return getOrCreate(moduleIdentifier);
     }
 
-    public synchronized DependencyResolverImpl getOrCreate(ModuleIdentifier name) {
+    public synchronized DependencyResolverImpl getOrCreate(final ModuleIdentifier name) {
         DependencyResolverImpl dependencyResolver = moduleIdentifiersToDependencyResolverMap.get(name);
         if (dependencyResolver == null) {
             transactionStatus.checkNotCommitted();
@@ -109,7 +109,7 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
     }
 
     public ModuleInternalTransactionalInfo destroyModule(
-            ModuleIdentifier moduleIdentifier) {
+            final ModuleIdentifier moduleIdentifier) {
         transactionStatus.checkNotCommitted();
         ModuleInternalTransactionalInfo found = modulesHolder
                 .destroyModule(moduleIdentifier);
@@ -119,52 +119,62 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
 
     // protect write access
 
+    private static final class ModuleInvocationHandler extends AbstractInvocationHandler {
+        private final DeadlockMonitor deadlockMonitor;
+        private final ModuleIdentifier moduleIdentifier;
+        private final Module module;
+
+        // optimization: subsequent calls to getInstance MUST return the same value during transaction,
+        // so it is safe to cache the response
+        private Object cachedInstance;
+
+        ModuleInvocationHandler(final DeadlockMonitor deadlockMonitor, final ModuleIdentifier moduleIdentifier, final Module module) {
+            this.deadlockMonitor = Preconditions.checkNotNull(deadlockMonitor);
+            this.moduleIdentifier = Preconditions.checkNotNull(moduleIdentifier);
+            this.module = Preconditions.checkNotNull(module);
+        }
+
+        @Override
+        protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
+            boolean isGetInstance = "getInstance".equals(method.getName());
+            if (isGetInstance) {
+                if (cachedInstance != null) {
+                    return cachedInstance;
+                }
+
+                checkState(deadlockMonitor.isAlive(), "Deadlock monitor is not alive");
+                deadlockMonitor.setCurrentlyInstantiatedModule(moduleIdentifier);
+            }
+            try {
+                Object response = method.invoke(module, args);
+                if (isGetInstance) {
+                    cachedInstance = response;
+                }
+                return response;
+            } catch(InvocationTargetException e) {
+                throw e.getCause();
+            } finally {
+                if (isGetInstance) {
+                    deadlockMonitor.setCurrentlyInstantiatedModule(null);
+                }
+            }
+        }
+    }
+
     public void put(
             final ModuleIdentifier moduleIdentifier,
             final Module module,
-            ModuleFactory moduleFactory,
-            ModuleInternalInfo maybeOldInternalInfo,
-            TransactionModuleJMXRegistration transactionModuleJMXRegistration,
-            boolean isDefaultBean, BundleContext bundleContext) {
+            final ModuleFactory moduleFactory,
+            final ModuleInternalInfo maybeOldInternalInfo,
+            final TransactionModuleJMXRegistration transactionModuleJMXRegistration,
+            final boolean isDefaultBean, final BundleContext bundleContext) {
         transactionStatus.checkNotCommitted();
 
         Class<? extends Module> moduleClass = Module.class;
         if (module instanceof RuntimeBeanRegistratorAwareModule) {
             moduleClass = RuntimeBeanRegistratorAwareModule.class;
         }
-        Module proxiedModule = Reflection.newProxy(moduleClass, new AbstractInvocationHandler() {
-            // optimization: subsequent calls to getInstance MUST return the same value during transaction,
-            // so it is safe to cache the response
-            private Object cachedInstance;
-
-            @Override
-            protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
-                boolean isGetInstance = "getInstance".equals(method.getName());
-                if (isGetInstance) {
-                    if (cachedInstance != null) {
-                        return cachedInstance;
-                    }
-
-                    checkState(deadlockMonitor.isAlive(), "Deadlock monitor is not alive");
-                    deadlockMonitor.setCurrentlyInstantiatedModule(moduleIdentifier);
-                }
-                try {
-                    Object response = method.invoke(module, args);
-                    if (isGetInstance) {
-                        cachedInstance = response;
-                    }
-                    return response;
-                } catch(InvocationTargetException e) {
-                    throw e.getCause();
-                } finally {
-                    if (isGetInstance) {
-                        deadlockMonitor.setCurrentlyInstantiatedModule(null);
-                    }
-                }
-            }
-        });
-
-
+        Module proxiedModule = Reflection.newProxy(moduleClass, new ModuleInvocationHandler(deadlockMonitor, moduleIdentifier, module));
         ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = new ModuleInternalTransactionalInfo(
                 moduleIdentifier, proxiedModule, moduleFactory,
                 maybeOldInternalInfo, transactionModuleJMXRegistration, isDefaultBean, module, bundleContext);
@@ -177,18 +187,18 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
         return modulesHolder.toCommitInfo();
     }
 
-    public Module findModule(ModuleIdentifier moduleIdentifier,
-                             JmxAttribute jmxAttributeForReporting) {
+    public Module findModule(final ModuleIdentifier moduleIdentifier,
+                             final JmxAttribute jmxAttributeForReporting) {
         return modulesHolder.findModule(moduleIdentifier,
                 jmxAttributeForReporting);
     }
 
-    public ModuleInternalTransactionalInfo findModuleInternalTransactionalInfo(ModuleIdentifier moduleIdentifier) {
+    public ModuleInternalTransactionalInfo findModuleInternalTransactionalInfo(final ModuleIdentifier moduleIdentifier) {
         return modulesHolder.findModuleInternalTransactionalInfo(moduleIdentifier);
     }
 
-    public ModuleFactory findModuleFactory(ModuleIdentifier moduleIdentifier,
-                                           JmxAttribute jmxAttributeForReporting) {
+    public ModuleFactory findModuleFactory(final ModuleIdentifier moduleIdentifier,
+                                           final JmxAttribute jmxAttributeForReporting) {
         return modulesHolder.findModuleFactory(moduleIdentifier,
                 jmxAttributeForReporting);
     }
@@ -197,12 +207,12 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
         return modulesHolder.getAllModules();
     }
 
-    public void assertNotExists(ModuleIdentifier moduleIdentifier)
+    public void assertNotExists(final ModuleIdentifier moduleIdentifier)
             throws InstanceAlreadyExistsException {
         modulesHolder.assertNotExists(moduleIdentifier);
     }
 
-    public List<ModuleIdentifier> findAllByFactory(ModuleFactory factory) {
+    public List<ModuleIdentifier> findAllByFactory(final ModuleFactory factory) {
         List<ModuleIdentifier> result = new ArrayList<>();
         for (ModuleInternalTransactionalInfo info : modulesHolder.getAllInfos()) {
             if (factory.equals(info.getModuleFactory())) {
@@ -212,6 +222,7 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
         return result;
     }
 
+    @Override
     public void close() {
         deadlockMonitor.close();
     }
index 4a148669b16eaabaf076d41f7f89e56e6169786c..c595562220487c08ceae0f1bf8e8b10cf01fe7d4 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.controller.config.manager.impl.dynamicmbean;
 
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.annotations.Description;
-import org.opendaylight.controller.config.api.annotations.RequireInterface;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.impl.util.InterfacesHelper;
-import org.opendaylight.controller.config.spi.Module;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import static java.lang.String.format;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import javax.management.Attribute;
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
@@ -38,17 +39,14 @@ import javax.management.Notification;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static java.lang.String.format;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.api.annotations.Description;
+import org.opendaylight.controller.config.api.annotations.RequireInterface;
+import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.config.manager.impl.util.InterfacesHelper;
+import org.opendaylight.controller.config.spi.Module;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Contains common code for readable/rw dynamic mbean wrappers. Routes all
@@ -57,9 +55,42 @@ import static java.lang.String.format;
  * a read only wrapper.
  */
 abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
-    private static final Logger LOGGER = LoggerFactory
-            .getLogger(AbstractDynamicWrapper.class);
+    private static final class ModuleNotificationListener implements NotificationListener {
+        private final ObjectName objectNameInternal;
+        private final MBeanServer internalServer;
+        private final ObjectName thisWrapperObjectName;
+        private final MBeanServer configMBeanServer;
+
+        private ModuleNotificationListener(final ObjectName objectNameInternal, final MBeanServer internalServer,
+                final ObjectName thisWrapperObjectName, final MBeanServer configMBeanServer) {
+            this.objectNameInternal = objectNameInternal;
+            this.internalServer = internalServer;
+            this.thisWrapperObjectName = thisWrapperObjectName;
+            this.configMBeanServer = configMBeanServer;
+        }
+
+        @Override
+        public void handleNotification(final Notification n, final Object handback) {
+            if (n instanceof MBeanServerNotification
+                    && n.getType()
+                    .equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
+                if (((MBeanServerNotification) n).getMBeanName().equals(
+                        thisWrapperObjectName)) {
+                    try {
+                        internalServer.unregisterMBean(objectNameInternal);
+                        configMBeanServer.removeNotificationListener(
+                                MBeanServerDelegate.DELEGATE_NAME, this);
+                    } catch (MBeanRegistrationException
+                            | ListenerNotFoundException
+                            | InstanceNotFoundException e) {
+                        throw new IllegalStateException(e);
+                    }
+                }
+            }
+        }
+    }
 
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractDynamicWrapper.class);
     protected final boolean writable;
     protected final Module module;
 
@@ -69,10 +100,10 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     protected final ModuleIdentifier moduleIdentifier;
     protected final MBeanServer internalServer;
 
-    public AbstractDynamicWrapper(Module module, boolean writable,
-                                  ModuleIdentifier moduleIdentifier,
-                                  ObjectName thisWrapperObjectName, MBeanOperationInfo[] dOperations,
-                                  MBeanServer internalServer, MBeanServer configMBeanServer) {
+    public AbstractDynamicWrapper(final Module module, final boolean writable,
+                                  final ModuleIdentifier moduleIdentifier,
+                                  final ObjectName thisWrapperObjectName, final MBeanOperationInfo[] dOperations,
+                                  final MBeanServer internalServer, final MBeanServer configMBeanServer) {
 
         this.writable = writable;
         this.module = module;
@@ -96,7 +127,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
      * platform mbean server. Wait until this wrapper gets unregistered, in that
      * case unregister the module and remove listener.
      */
-    private final NotificationListener registerActualModule(Module module,
+    private final NotificationListener registerActualModule(final Module module,
                                                             final ObjectName thisWrapperObjectName,
                                                             final ObjectName objectNameInternal,
                                                             final MBeanServer internalServer,
@@ -110,27 +141,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                     "Error occured during mbean registration with name " + objectNameInternal, e);
         }
 
-        NotificationListener listener = new NotificationListener() {
-            @Override
-            public void handleNotification(Notification n, Object handback) {
-                if (n instanceof MBeanServerNotification
-                        && n.getType()
-                        .equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
-                    if (((MBeanServerNotification) n).getMBeanName().equals(
-                            thisWrapperObjectName)) {
-                        try {
-                            internalServer.unregisterMBean(objectNameInternal);
-                            configMBeanServer.removeNotificationListener(
-                                    MBeanServerDelegate.DELEGATE_NAME, this);
-                        } catch (MBeanRegistrationException
-                                | ListenerNotFoundException
-                                | InstanceNotFoundException e) {
-                            throw new IllegalStateException(e);
-                        }
-                    }
-                }
-            }
-        };
+        NotificationListener listener = new ModuleNotificationListener(objectNameInternal, internalServer, thisWrapperObjectName, configMBeanServer);
         try {
             configMBeanServer.addNotificationListener(
                     MBeanServerDelegate.DELEGATE_NAME, listener, null, null);
@@ -140,9 +151,9 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         return listener;
     }
 
-    private static MBeanInfo generateMBeanInfo(String className, Module module,
-                                               Map<String, AttributeHolder> attributeHolderMap,
-                                               MBeanOperationInfo[] dOperations, Set<Class<?>> jmxInterfaces) {
+    private static MBeanInfo generateMBeanInfo(final String className, final Module module,
+                                               final Map<String, AttributeHolder> attributeHolderMap,
+                                               final MBeanOperationInfo[] dOperations, final Set<Class<?>> jmxInterfaces) {
 
         String dDescription = findDescription(module.getClass(), jmxInterfaces);
         MBeanConstructorInfo[] dConstructors = new MBeanConstructorInfo[0];
@@ -156,7 +167,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                 dOperations, new MBeanNotificationInfo[0]);
     }
 
-    static String findDescription(Class<?> clazz, Set<Class<?>> jmxInterfaces) {
+    static String findDescription(final Class<?> clazz, final Set<Class<?>> jmxInterfaces) {
         List<Description> descriptions = AnnotationsHelper
                 .findClassAnnotationInSuperClassesAndIfcs(clazz, Description.class, jmxInterfaces);
         return AnnotationsHelper.aggregateDescriptions(descriptions);
@@ -168,10 +179,10 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
 
     // inspect all exported interfaces ending with MXBean, extract getters &
     // setters into attribute holder
-    private static Map<String, AttributeHolder> buildMBeanInfo(Module module,
-                                                               boolean writable, ModuleIdentifier moduleIdentifier,
-                                                               Set<Class<?>> jmxInterfaces, MBeanServer internalServer,
-                                                               ObjectName internalObjectName) {
+    private static Map<String, AttributeHolder> buildMBeanInfo(final Module module,
+                                                               final boolean writable, final ModuleIdentifier moduleIdentifier,
+                                                               final Set<Class<?>> jmxInterfaces, final MBeanServer internalServer,
+                                                               final ObjectName internalObjectName) {
 
         // internal variables for describing MBean elements
         Set<Method> methods = new HashSet<>();
@@ -231,7 +242,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     @Override
-    public Object getAttribute(String attributeName)
+    public Object getAttribute(final String attributeName)
             throws AttributeNotFoundException, MBeanException,
             ReflectionException {
         if ("MBeanInfo".equals(attributeName)) {
@@ -263,7 +274,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         return obj;
     }
 
-    private Object fixDependencyListAttribute(Object attribute) {
+    private Object fixDependencyListAttribute(final Object attribute) {
         if (attribute.getClass().isArray() == false) {
             throw new IllegalArgumentException("Unexpected attribute type, should be an array, but was " + attribute.getClass());
         }
@@ -282,7 +293,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         return attribute;
     }
 
-    private boolean isDependencyListAttr(String attributeName, Object attribute) {
+    private boolean isDependencyListAttr(final String attributeName, final Object attribute) {
         if (attributeHolderMap.containsKey(attributeName) == false) {
             return false;
         }
@@ -295,7 +306,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         return isDepList;
     }
 
-    protected ObjectName fixObjectName(ObjectName on) {
+    protected ObjectName fixObjectName(final ObjectName on) {
         if (!ObjectNameUtil.ON_DOMAIN.equals(on.getDomain())) {
             throw new IllegalArgumentException("Wrong domain, expected "
                     + ObjectNameUtil.ON_DOMAIN + " setter on " + on);
@@ -310,7 +321,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     @Override
-    public AttributeList getAttributes(String[] attributes) {
+    public AttributeList getAttributes(final String[] attributes) {
         AttributeList result = new AttributeList();
         for (String attributeName : attributes) {
             try {
@@ -318,14 +329,14 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                 result.add(new Attribute(attributeName, value));
 
             } catch (Exception e) {
-                LOGGER.debug("Getting attribute {} failed", attributeName, e);
+                LOG.debug("Getting attribute {} failed", attributeName, e);
             }
         }
         return result;
     }
 
     @Override
-    public Object invoke(String actionName, Object[] params, String[] signature)
+    public Object invoke(final String actionName, final Object[] params, final String[] signature)
             throws MBeanException, ReflectionException {
         if ("getAttribute".equals(actionName) && params.length == 1
                 && signature[0].equals(String.class.getName())) {
@@ -342,7 +353,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                 && signature[0].equals(AttributeList.class.getName())) {
             return setAttributes((AttributeList) params[0]);
         } else {
-            LOGGER.debug("Operation not found {} ", actionName);
+            LOG.debug("Operation not found {} ", actionName);
             throw new UnsupportedOperationException(
                     format("Operation not found on %s. Method invoke is only supported for getInstance and getAttribute(s) "
                             + "method, got actionName %s, params %s, signature %s ",
@@ -356,7 +367,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     @Override
-    public final boolean equals(Object other) {
+    public final boolean equals(final Object other) {
         return module.equals(other);
     }
 
index bb866f276e713151ccf18b0e57e589c65633647f..0dd04d539c93617d95d4f6bffc834dc4c99947f8 100644 (file)
@@ -15,7 +15,7 @@ import java.util.concurrent.ExecutorService;
  * Users of this interface can publish any YANG-modeled notification which will
  * be delivered to all subscribed listeners.
  * <p>
- * Prefered way of publishing of notifications is done by invoking {@link #publish(Object)}.
+ * Preferred way of publishing of notifications is done by invoking {@link #publish(Object)}.
  *
  * <p>You may consider using {@link #publish(Object, ExecutorService)} if and only if
  * your use-case requires customized  execution policy or run-to-completion
@@ -50,7 +50,7 @@ public interface NotificationPublishService<N> {
      * Publishes a notification and notifies subscribed listeners. All listener
      * notifications are done via the provided executor.
      * <p>
-     * <b>Note:</b> Use only if ineccessary. Consider using
+     * <b>Note:</b> Use only if necessary. Consider using
      * {@link #publish(Object)} for most use-cases.
      *
      * <p>
index feccbbad92f694fb070af73c355376acbf26e928..a83610fe9166b537defe8f790c5e6369ee634674 100644 (file)
@@ -8,10 +8,9 @@
 package org.opendaylight.controller.md.sal.common.api.notify;
 
 import java.util.EventListener;
-
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 
-public interface NotificationSubscriptionService<T,N,L extends EventListener> {
+public interface NotificationSubscriptionService<T, N, L extends EventListener> {
 
-    ListenerRegistration<L> registerNotificationListener(T type,L listener);
+    ListenerRegistration<L> registerNotificationListener(T type, L listener);
 }
index fb72b5a99a130efbcfcd0ea04056ef61978f2e06..7a3b80b9f574c337c019e3864260eec0652992e9 100644 (file)
@@ -11,10 +11,15 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
@@ -65,18 +70,11 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 
-import javax.annotation.Nullable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
 public class BackwardsCompatibleMountPoint implements MountProvisionInstance, SchemaContextProvider, SchemaService {
 
     private final DataProviderService dataReader;
@@ -285,12 +283,10 @@ public class BackwardsCompatibleMountPoint implements MountProvisionInstance, Sc
 
     class ReadWrapper implements DataReader<YangInstanceIdentifier, CompositeNode> {
         private YangInstanceIdentifier shortenPath(final YangInstanceIdentifier path) {
-            YangInstanceIdentifier ret = null;
-            if(mountPath.contains(path)) {
-                final List<PathArgument> newArgs = path.getPath().subList(mountPath.getPath().size(), path.getPath().size());
-                ret = YangInstanceIdentifier.create(newArgs);
+            if (!mountPath.contains(path)) {
+                return null;
             }
-            return ret;
+            return YangInstanceIdentifier.create(Iterables.skip(path.getPathArguments(), Iterables.size(mountPath.getPathArguments())));
         }
 
         @Override
@@ -405,8 +401,8 @@ public class BackwardsCompatibleMountPoint implements MountProvisionInstance, Sc
                 return Futures.immediateCheckedFuture(normalizedNodeOptional);
             }
 
-            @Override public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store,
-                YangInstanceIdentifier path) {
+            @Override public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+                final YangInstanceIdentifier path) {
 
                 try {
                     return Futures.immediateCheckedFuture(read(store, path).get().isPresent());
@@ -527,8 +523,8 @@ public class BackwardsCompatibleMountPoint implements MountProvisionInstance, Sc
                 return new BackwardsCompatibleReadTransaction(dataReader, dataNormalizer).read(store, path);
             }
 
-            @Override public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store,
-                YangInstanceIdentifier path) {
+            @Override public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+                final YangInstanceIdentifier path) {
 
                 try {
                     return Futures.immediateCheckedFuture(read(store, path).get().isPresent());
index 054c8ea851cf2e8f56e6891a40c0dd790b72e34e..d7ff8e6756415d8dd29cb741bf3821967e1d1b07 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.sal.dom.broker;
 
-import java.util.List;
+import com.google.common.collect.Iterables;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Set;
-
 import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
@@ -37,11 +37,8 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-import com.google.common.util.concurrent.ListenableFuture;
-
 @Deprecated
 public class MountPointImpl implements MountProvisionInstance, SchemaContextProvider {
 
@@ -187,12 +184,11 @@ public class MountPointImpl implements MountProvisionInstance, SchemaContextProv
 
     class ReadWrapper implements DataReader<YangInstanceIdentifier, CompositeNode> {
         private YangInstanceIdentifier shortenPath(final YangInstanceIdentifier path) {
-            YangInstanceIdentifier ret = null;
-            if(mountPath.contains(path)) {
-                List<PathArgument> newArgs = path.getPath().subList(mountPath.getPath().size(), path.getPath().size());
-                ret = YangInstanceIdentifier.create(newArgs);
+            if (!mountPath.contains(path)) {
+                return null;
             }
-            return ret;
+
+            return YangInstanceIdentifier.create(Iterables.skip(path.getPathArguments(), Iterables.size(mountPath.getPathArguments())));
         }
 
         @Override
index 94553f52757dbc24a811ab2a840c797d29608f3a..d65a3cfe91ac6099e5d0d8676304da585046d1d2 100644 (file)
@@ -8,12 +8,10 @@
 package org.opendaylight.controller.sal.dom.broker.impl;
 
 import static com.google.common.base.Preconditions.checkState;
-
 import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
-
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -21,7 +19,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.Future;
-
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
@@ -33,9 +30,9 @@ import org.opendaylight.controller.sal.dom.broker.util.YangSchemaUtils;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -226,7 +223,7 @@ AutoCloseable {
         public int compare(final Entry<YangInstanceIdentifier, CompositeNode> o1, final Entry<YangInstanceIdentifier, CompositeNode> o2) {
             YangInstanceIdentifier o1Key = o1.getKey();
             YangInstanceIdentifier o2Key = o2.getKey();
-            return Integer.compare(o1Key.getPath().size(), o2Key.getPath().size());
+            return Integer.compare(Iterables.size(o1Key.getPathArguments()), Iterables.size(o2Key.getPathArguments()));
         }
     };
 
@@ -246,7 +243,7 @@ AutoCloseable {
                     childNodes.addAll(original.getValue());
                     qname = original.getNodeType();
                 } else {
-                    qname = path.getPath().get(path.getPath().size() - 1).getNodeType();
+                    qname = path.getLastPathArgument().getNodeType();
                 }
 
                 FluentIterable<YangInstanceIdentifier> directChildren = FluentIterable.from(getStoredConfigurationPaths())
@@ -254,7 +251,7 @@ AutoCloseable {
                             @Override
                             public boolean apply(final YangInstanceIdentifier input) {
                                 if (path.contains(input)) {
-                                    int nesting = input.getPath().size() - path.getPath().size();
+                                    int nesting = Iterables.size(input.getPathArguments()) - Iterables.size(path.getPathArguments());
                                     if (nesting == 1) {
                                         return true;
                                     }
@@ -289,7 +286,7 @@ AutoCloseable {
                     childNodes.addAll(original.getValue());
                     qname = original.getNodeType();
                 } else {
-                    qname = path.getPath().get(path.getPath().size() - 1).getNodeType();
+                    qname = path.getLastPathArgument().getNodeType();
                 }
 
                 FluentIterable<YangInstanceIdentifier> directChildren = FluentIterable.from(getStoredOperationalPaths())
@@ -297,7 +294,7 @@ AutoCloseable {
                             @Override
                             public boolean apply(final YangInstanceIdentifier input) {
                                 if (path.contains(input)) {
-                                    int nesting = input.getPath().size() - path.getPath().size();
+                                    int nesting = Iterables.size(input.getPathArguments()) - Iterables.size(path.getPathArguments());
                                     if (nesting == 1) {
                                         return true;
                                     }
index 87f5477d35d0f986b6f2a0fd8b1044b8b421e58c..4b53dd7c44dc74a67eedf75f923fe220befb3e1c 100644 (file)
@@ -19,18 +19,17 @@ import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessag
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_TARGET_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.ROLLBACK_ON_ERROR_OPTION;
-
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
@@ -48,10 +47,11 @@ import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
@@ -260,17 +260,16 @@ public class NetconfDeviceWriteOnlyTx implements DOMDataWriteTransaction, Future
                                                     final Optional<CompositeNode> lastChildOverride) {
         Preconditions.checkArgument(Iterables.isEmpty(dataPath.getPathArguments()) == false, "Instance identifier with empty path %s", dataPath);
 
-        List<YangInstanceIdentifier.PathArgument> reversedPath = Lists.reverse(dataPath.getPath());
-
         // Create deepest edit element with expected edit operation
-        CompositeNode previous = getDeepestEditElement(reversedPath.get(0), operation, lastChildOverride);
+        CompositeNode previous = getDeepestEditElement(dataPath.getLastPathArgument(), operation, lastChildOverride);
 
+        Iterator<PathArgument> it = dataPath.getReversePathArguments().iterator();
         // Remove already processed deepest child
-        reversedPath = Lists.newArrayList(reversedPath);
-        reversedPath.remove(0);
+        it.next();
 
         // Create edit structure in reversed order
-        for (final YangInstanceIdentifier.PathArgument arg : reversedPath) {
+        while (it.hasNext()) {
+            final YangInstanceIdentifier.PathArgument arg = it.next();
             final CompositeNodeBuilder<ImmutableCompositeNode> builder = ImmutableCompositeNode.builder();
             builder.setQName(arg.getNodeType());
 
index efc020ecd0044ef4e8d13f081611972e20db1efa..e3a7441caf746fdb56cc8d0a4cc87287908c41b9 100644 (file)
@@ -7,15 +7,21 @@
  */
 package org.opendaylight.controller.sal.connect.netconf.util;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import javax.annotation.Nullable;
-
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.util.messages.NetconfMessageUtil;
@@ -40,15 +46,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-
 public class NetconfMessageTransformUtil {
 
     public static final String MESSAGE_ID_ATTR = "message-id";
@@ -62,34 +59,34 @@ public class NetconfMessageTransformUtil {
     public static final QName IETF_NETCONF_MONITORING_SCHEMA_VERSION = QName.create(IETF_NETCONF_MONITORING, "version");
     public static final QName IETF_NETCONF_MONITORING_SCHEMA_NAMESPACE = QName.create(IETF_NETCONF_MONITORING, "namespace");
 
-    public static URI NETCONF_URI = URI.create("urn:ietf:params:xml:ns:netconf:base:1.0");
-    public static QName NETCONF_QNAME = QName.create(NETCONF_URI, null, "netconf");
-    public static QName NETCONF_DATA_QNAME = QName.create(NETCONF_QNAME, "data");
-    public static QName NETCONF_RPC_REPLY_QNAME = QName.create(NETCONF_QNAME, "rpc-reply");
-    public static QName NETCONF_ERROR_OPTION_QNAME = QName.create(NETCONF_QNAME, "error-option");
-    public static QName NETCONF_RUNNING_QNAME = QName.create(NETCONF_QNAME, "running");
-    static List<Node<?>> RUNNING = Collections.<Node<?>> singletonList(new SimpleNodeTOImpl<>(NETCONF_RUNNING_QNAME, null, null));
-    public static QName NETCONF_SOURCE_QNAME = QName.create(NETCONF_QNAME, "source");
-    public static CompositeNode CONFIG_SOURCE_RUNNING = new CompositeNodeTOImpl(NETCONF_SOURCE_QNAME, null, RUNNING);
-    public static QName NETCONF_CANDIDATE_QNAME = QName.create(NETCONF_QNAME, "candidate");
-    public static QName NETCONF_TARGET_QNAME = QName.create(NETCONF_QNAME, "target");
-    public static QName NETCONF_CONFIG_QNAME = QName.create(NETCONF_QNAME, "config");
-    public static QName NETCONF_COMMIT_QNAME = QName.create(NETCONF_QNAME, "commit");
-    public static QName NETCONF_OPERATION_QNAME = QName.create(NETCONF_QNAME, "operation");
-    public static QName NETCONF_DEFAULT_OPERATION_QNAME = QName.create(NETCONF_OPERATION_QNAME, "default-operation");
-    public static QName NETCONF_EDIT_CONFIG_QNAME = QName.create(NETCONF_QNAME, "edit-config");
-    public static QName NETCONF_GET_CONFIG_QNAME = QName.create(NETCONF_QNAME, "get-config");
-    public static QName NETCONF_DISCARD_CHANGES_QNAME = QName.create(NETCONF_QNAME, "discard-changes");
-    public static QName NETCONF_TYPE_QNAME = QName.create(NETCONF_QNAME, "type");
-    public static QName NETCONF_FILTER_QNAME = QName.create(NETCONF_QNAME, "filter");
-    public static QName NETCONF_GET_QNAME = QName.create(NETCONF_QNAME, "get");
-    public static QName NETCONF_RPC_QNAME = QName.create(NETCONF_QNAME, "rpc");
-
-    public static URI NETCONF_ROLLBACK_ON_ERROR_URI = URI
+    public static final URI NETCONF_URI = URI.create("urn:ietf:params:xml:ns:netconf:base:1.0");
+    public static final QName NETCONF_QNAME = QName.create(NETCONF_URI, null, "netconf");
+    public static final QName NETCONF_DATA_QNAME = QName.create(NETCONF_QNAME, "data");
+    public static final QName NETCONF_RPC_REPLY_QNAME = QName.create(NETCONF_QNAME, "rpc-reply");
+    public static final QName NETCONF_ERROR_OPTION_QNAME = QName.create(NETCONF_QNAME, "error-option");
+    public static final QName NETCONF_RUNNING_QNAME = QName.create(NETCONF_QNAME, "running");
+    static final List<Node<?>> RUNNING = Collections.<Node<?>> singletonList(new SimpleNodeTOImpl<>(NETCONF_RUNNING_QNAME, null, null));
+    public static final QName NETCONF_SOURCE_QNAME = QName.create(NETCONF_QNAME, "source");
+    public static final CompositeNode CONFIG_SOURCE_RUNNING = new CompositeNodeTOImpl(NETCONF_SOURCE_QNAME, null, RUNNING);
+    public static final QName NETCONF_CANDIDATE_QNAME = QName.create(NETCONF_QNAME, "candidate");
+    public static final QName NETCONF_TARGET_QNAME = QName.create(NETCONF_QNAME, "target");
+    public static final QName NETCONF_CONFIG_QNAME = QName.create(NETCONF_QNAME, "config");
+    public static final QName NETCONF_COMMIT_QNAME = QName.create(NETCONF_QNAME, "commit");
+    public static final QName NETCONF_OPERATION_QNAME = QName.create(NETCONF_QNAME, "operation");
+    public static final QName NETCONF_DEFAULT_OPERATION_QNAME = QName.create(NETCONF_OPERATION_QNAME, "default-operation");
+    public static final QName NETCONF_EDIT_CONFIG_QNAME = QName.create(NETCONF_QNAME, "edit-config");
+    public static final QName NETCONF_GET_CONFIG_QNAME = QName.create(NETCONF_QNAME, "get-config");
+    public static final QName NETCONF_DISCARD_CHANGES_QNAME = QName.create(NETCONF_QNAME, "discard-changes");
+    public static final QName NETCONF_TYPE_QNAME = QName.create(NETCONF_QNAME, "type");
+    public static final QName NETCONF_FILTER_QNAME = QName.create(NETCONF_QNAME, "filter");
+    public static final QName NETCONF_GET_QNAME = QName.create(NETCONF_QNAME, "get");
+    public static final QName NETCONF_RPC_QNAME = QName.create(NETCONF_QNAME, "rpc");
+
+    public static final URI NETCONF_ROLLBACK_ON_ERROR_URI = URI
             .create("urn:ietf:params:netconf:capability:rollback-on-error:1.0");
-    public static String ROLLBACK_ON_ERROR_OPTION = "rollback-on-error";
+    public static final String ROLLBACK_ON_ERROR_OPTION = "rollback-on-error";
 
-    public static URI NETCONF_CANDIDATE_URI = URI
+    public static final URI NETCONF_CANDIDATE_URI = URI
             .create("urn:ietf:params:netconf:capability:candidate:1.0");
 
     // Discard changes message
index 97cd67d34b70095a1571c1384e4a0e46c61f155a..423825827a4749f559f4b831fad5a71c98338750 100644 (file)
@@ -16,8 +16,8 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.XML;
-
 import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import java.io.IOException;
@@ -188,7 +188,7 @@ public class RestPostOperationTest extends JerseyTest {
         assertEquals(400, post(uri, MediaType.APPLICATION_JSON, ""));
     }
 
-    private void mockInvokeRpc(CompositeNode result, boolean sucessful, Collection<RpcError> errors) {
+    private void mockInvokeRpc(final CompositeNode result, final boolean sucessful, final Collection<RpcError> errors) {
 
         DummyRpcResult.Builder<CompositeNode> builder = new DummyRpcResult.Builder<CompositeNode>().result(result)
                 .isSuccessful(sucessful);
@@ -200,7 +200,7 @@ public class RestPostOperationTest extends JerseyTest {
                 Futures.<RpcResult<CompositeNode>> immediateFuture(rpcResult));
     }
 
-    private void mockInvokeRpc(CompositeNode result, boolean sucessful) {
+    private void mockInvokeRpc(final CompositeNode result, final boolean sucessful) {
         mockInvokeRpc(result, sucessful, Collections.<RpcError> emptyList());
     }
 
@@ -229,14 +229,14 @@ public class RestPostOperationTest extends JerseyTest {
         assertEquals(204, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface));
         verify(brokerFacade).commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
         String identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces]";
-        assertEquals(identifier, instanceIdCaptor.getValue().getPath().toString());
+        assertEquals(identifier, ImmutableList.copyOf(instanceIdCaptor.getValue().getPathArguments()).toString());
 
         String URI_2 = "/config/test-interface:interfaces";
         assertEquals(204, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData));
         verify(brokerFacade, times(2))
                 .commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
         identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces, (urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)block]";
-        assertEquals(identifier, instanceIdCaptor.getValue().getPath().toString());
+        assertEquals(identifier, ImmutableList.copyOf(instanceIdCaptor.getValue().getPathArguments()).toString());
     }
 
     @Test
@@ -264,7 +264,7 @@ public class RestPostOperationTest extends JerseyTest {
         restconfImpl.setControllerContext(controllerContext);
     }
 
-    private int post(String uri, String mediaType, String data) {
+    private int post(final String uri, final String mediaType, final String data) {
         return target(uri).request(mediaType).post(Entity.entity(data, mediaType)).getStatus();
     }
 
index 4900e6a66f1ab9d9d3324c85e6ca5c98f103e5ba..efd5482bfe7925e1dd81706544ca8d1f178ea2ed 100644 (file)
@@ -13,8 +13,8 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-
 import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import java.io.FileNotFoundException;
 import java.util.Set;
@@ -124,7 +124,7 @@ public class URITest {
                 .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name");
         assertEquals(
                 "[(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)student[{(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)name=name}]]",
-                instanceIdentifier.getInstanceIdentifier().getPath().toString());
+                ImmutableList.copyOf(instanceIdentifier.getInstanceIdentifier().getPathArguments()).toString());
     }
 
     @Test
@@ -140,8 +140,7 @@ public class URITest {
         exception.expect(RestconfDocumentedException.class);
 
         controllerContext.setMountService(null);
-        InstanceIdentifierContext instanceIdentifier = controllerContext
-                .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name");
+        controllerContext.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name");
     }
 
     @Test
@@ -149,8 +148,7 @@ public class URITest {
         initMountService(false);
         exception.expect(RestconfDocumentedException.class);
 
-        InstanceIdentifierContext instanceIdentifier = controllerContext
-                .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class");
+        controllerContext.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class");
     }
 
     public void initMountService(final boolean withSchema) {
index 23e868c8b2d738e040081603234a86038146f593..6bd5178f1343a6b328ea641613abda7424896dc7 100644 (file)
@@ -8,12 +8,12 @@
 package org.opendaylight.controller.sal.restconf.impl.test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-
 import java.io.IOException;
 import java.net.URISyntaxException;
-import java.util.List;
+import java.util.Iterator;
 import java.util.Map;
 import javax.ws.rs.WebApplicationException;
 import org.junit.BeforeClass;
@@ -22,12 +22,12 @@ import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider;
 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.data.api.SimpleNode;
 
 public class XmlAndJsonToCnSnInstanceIdentifierTest extends YangAndXmlAndDataSchemaLoader {
 
@@ -80,52 +80,51 @@ public class XmlAndJsonToCnSnInstanceIdentifierTest extends YangAndXmlAndDataSch
         verifyLeafListPredicate(cnSn);
     }
 
-    private void verifyLeafListPredicate(CompositeNode cnSn) throws URISyntaxException {
+    private void verifyLeafListPredicate(final CompositeNode cnSn) throws URISyntaxException {
         SimpleNode<?> lf11 = getSnWithInstanceIdentifierWhenLeafList(cnSn);
         Object value = lf11.getValue();
         assertTrue(value instanceof YangInstanceIdentifier);
 
         YangInstanceIdentifier instanceIdentifier = (YangInstanceIdentifier) value;
-        List<PathArgument> pathArguments = instanceIdentifier.getPath();
-        assertEquals(3, pathArguments.size());
+        Iterator<PathArgument> it = instanceIdentifier.getPathArguments().iterator();
         String revisionDate = "2014-01-17";
-        assertEquals(TestUtils.buildQName("cont", "instance:identifier:module", revisionDate), pathArguments.get(0)
-                .getNodeType());
-        assertEquals(TestUtils.buildQName("cont1", "instance:identifier:module", revisionDate), pathArguments.get(1)
-                .getNodeType());
-        assertEquals(TestUtils.buildQName("lflst11", "augment:module:leaf:list", "2014-01-27"), pathArguments.get(2)
-                .getNodeType());
 
-        assertTrue(pathArguments.get(2) instanceof NodeWithValue);
-        assertEquals("lflst11_1", ((NodeWithValue) pathArguments.get(2)).getValue());
+        assertEquals(TestUtils.buildQName("cont", "instance:identifier:module", revisionDate), it.next().getNodeType());
+        assertEquals(TestUtils.buildQName("cont1", "instance:identifier:module", revisionDate), it.next().getNodeType());
+
+        PathArgument arg = it.next();
+        assertFalse(it.hasNext());
+        assertEquals(TestUtils.buildQName("lflst11", "augment:module:leaf:list", "2014-01-27"), arg.getNodeType());
+
+        assertTrue(arg instanceof NodeWithValue);
+        assertEquals("lflst11_1", ((NodeWithValue) arg).getValue());
 
     }
 
-    private void verifyListPredicate(CompositeNode cnSn) throws URISyntaxException {
+    private void verifyListPredicate(final CompositeNode cnSn) throws URISyntaxException {
         SimpleNode<?> lf111 = getSnWithInstanceIdentifierWhenList(cnSn);
         Object value = lf111.getValue();
         assertTrue(value instanceof YangInstanceIdentifier);
 
         YangInstanceIdentifier instanceIdentifier = (YangInstanceIdentifier) value;
-        List<PathArgument> pathArguments = instanceIdentifier.getPath();
-        assertEquals(4, pathArguments.size());
+        Iterator<PathArgument> it = instanceIdentifier.getPathArguments().iterator();
         String revisionDate = "2014-01-17";
-        assertEquals(TestUtils.buildQName("cont", "instance:identifier:module", revisionDate), pathArguments.get(0)
-                .getNodeType());
-        assertEquals(TestUtils.buildQName("cont1", "instance:identifier:module", revisionDate), pathArguments.get(1)
-                .getNodeType());
-        assertEquals(TestUtils.buildQName("lst11", "augment:module", revisionDate), pathArguments.get(2).getNodeType());
-        assertEquals(TestUtils.buildQName("lf112", "augment:augment:module", revisionDate), pathArguments.get(3)
-                .getNodeType());
-
-        assertTrue(pathArguments.get(2) instanceof NodeIdentifierWithPredicates);
-        Map<QName, Object> predicates = ((NodeIdentifierWithPredicates) pathArguments.get(2)).getKeyValues();
+        assertEquals(TestUtils.buildQName("cont", "instance:identifier:module", revisionDate), it.next().getNodeType());
+        assertEquals(TestUtils.buildQName("cont1", "instance:identifier:module", revisionDate), it.next().getNodeType());
+
+        PathArgument arg = it.next();
+        assertEquals(TestUtils.buildQName("lst11", "augment:module", revisionDate), arg.getNodeType());
+        assertEquals(TestUtils.buildQName("lf112", "augment:augment:module", revisionDate), it.next().getNodeType());
+        assertFalse(it.hasNext());
+
+        assertTrue(arg instanceof NodeIdentifierWithPredicates);
+        Map<QName, Object> predicates = ((NodeIdentifierWithPredicates) arg).getKeyValues();
         assertEquals(2, predicates.size());
         assertEquals("value1", predicates.get(TestUtils.buildQName("keyvalue111", "augment:module", revisionDate)));
         assertEquals("value2", predicates.get(TestUtils.buildQName("keyvalue112", "augment:module", revisionDate)));
     }
 
-    private SimpleNode<?> getSnWithInstanceIdentifierWhenList(CompositeNode cnSn) throws URISyntaxException {
+    private SimpleNode<?> getSnWithInstanceIdentifierWhenList(final CompositeNode cnSn) throws URISyntaxException {
         CompositeNode cont1 = cnSn.getFirstCompositeByName(TestUtils.buildQName("cont1", "instance:identifier:module",
                 "2014-01-17"));
         assertNotNull(cont1);
@@ -138,7 +137,7 @@ public class XmlAndJsonToCnSnInstanceIdentifierTest extends YangAndXmlAndDataSch
         return lf111;
     }
 
-    private SimpleNode<?> getSnWithInstanceIdentifierWhenLeafList(CompositeNode cnSn) throws URISyntaxException {
+    private SimpleNode<?> getSnWithInstanceIdentifierWhenLeafList(final CompositeNode cnSn) throws URISyntaxException {
         CompositeNode cont1 = cnSn.getFirstCompositeByName(TestUtils.buildQName("cont1", "instance:identifier:module",
                 "2014-01-17"));
         assertNotNull(cont1);