BUG-4514: use SimpleImmutableEntry 47/32147/5
authorRobert Varga <rovarga@cisco.com>
Tue, 5 Jan 2016 15:05:44 +0000 (16:05 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 8 Jan 2016 09:11:21 +0000 (09:11 +0000)
Instead of brewing our own class, reuse an Entry implementation from
JRE.

Change-Id: I94972985050921838f0b217a0957a413d7971427
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java

index dd6c2b94222b67b6b0d04310993e83b435bdd436..53e9d47300a104ee73a4da08e01459aa1a87cf86 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.controller.config.manager.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import java.util.AbstractMap.SimpleImmutableEntry;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -422,7 +422,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
             } catch (InstanceAlreadyExistsException e) {
                 throw new IllegalStateException("Possible error in code. Cannot register " + result, e);
             }
-            mBeans.put(serviceReference, createMXBeanEntry(dummyMXBean, dummyMXBeanRegistration));
+            mBeans.put(serviceReference, new SimpleImmutableEntry<>(dummyMXBean, dummyMXBeanRegistration));
         } else {
             // update
             mxBeanEntry.getKey().setCurrentImplementation(moduleON);
@@ -441,26 +441,6 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         return result;
     }
 
-    private Entry<ServiceReferenceMXBeanImpl, ServiceReferenceJMXRegistration> createMXBeanEntry(
-            final ServiceReferenceMXBeanImpl mxBean, final ServiceReferenceJMXRegistration registration) {
-        return new Entry<ServiceReferenceMXBeanImpl, ServiceReferenceJMXRegistration>() {
-            @Override
-            public ServiceReferenceMXBeanImpl getKey() {
-                return mxBean;
-            }
-
-            @Override
-            public ServiceReferenceJMXRegistration getValue() {
-                return registration;
-            }
-
-            @Override
-            public ServiceReferenceJMXRegistration setValue(final ServiceReferenceJMXRegistration value) {
-                throw new UnsupportedOperationException();
-            }
-        };
-    }
-
     private ObjectName getServiceON(final ServiceReference serviceReference) {
         if (writable) {
             return ObjectNameUtil.createTransactionServiceON(serviceReferenceRegistrator.getNullableTransactionName(),