Fixup Augmentable and Identifiable methods changing 55/71255/8
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 24 Apr 2018 13:30:01 +0000 (15:30 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 4 Jun 2018 12:07:20 +0000 (12:07 +0000)
This is a fixup of the change in binding codegen, adjusting:
- getKey() -> key()
- setKey() -> withKey()
- getAugmentation() -> augmentation()

Change-Id: I7533bd17bcd4a742862576d38f76991162845f4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Stephen Kitt <skitt@redhat.com>
36 files changed:
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallhomeStatusReporter.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java
netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriter.java
netconf/mdsal-netconf-monitoring/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriterTest.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NotificationToMdsalWriter.java
netconf/mdsal-netconf-notification/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/CapabilityChangeNotificationProducerTest.java
netconf/mdsal-netconf-notification/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NotificationToMdsalWriterTest.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSource.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManager.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceRegistration.java
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfTestUtils.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/impl/NetconfCommandsImpl.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/utils/NetconfConsoleUtils.java
netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfCommandsImplTest.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSession.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfCapabilityMonitoringService.java
netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/xml/model/MonitoringSession.java
netconf/netconf-monitoring/src/test/java/org/opendaylight/netconf/monitoring/xml/JaxBSerializerTest.java
netconf/netconf-notifications-impl/src/main/java/org/opendaylight/netconf/notifications/impl/NetconfNotificationManager.java
netconf/netconf-notifications-impl/src/test/java/org/opendaylight/netconf/notifications/impl/ops/GetTest.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeManager.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyContext.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologyUtils.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/NetconfConnectorFactoryImpl.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapter.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfKeystoreAdapter.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/NetconfSalKeystoreService.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfKeystoreAdapterTest.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfSalKeystoreServiceTest.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/DummyMonitoringService.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapterTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenerAdapterTest.java

index 226fd27d78ae5728e34acdeacd09b8c243c94f2b..b315aeef989fc6b1b8cc55219e3eb76101311c2a 100644 (file)
@@ -78,7 +78,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
                     if (isNetconfNode(rootNode.getDataAfter())) {
                         NodeId nodeId = getNodeId(identifier);
                         if (nodeId != null) {
-                            NetconfNode nnode = rootNode.getDataAfter().getAugmentation(NetconfNode.class);
+                            NetconfNode nnode = rootNode.getDataAfter().augmentation(NetconfNode.class);
                             handledNetconfNode(nodeId, nnode);
                         }
                     }
@@ -98,7 +98,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
     }
 
     private static boolean isNetconfNode(final Node node) {
-        return node.getAugmentation(NetconfNode.class) != null;
+        return node.augmentation(NetconfNode.class) != null;
     }
 
     private static NodeId getNodeId(final InstanceIdentifier<?> path) {
@@ -197,7 +197,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         Device1 d1 = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILEDNOTALLOWED).build();
         DeviceBuilder builder = new DeviceBuilder()
                 .setUniqueId(id)
-                .setKey(new DeviceKey(id))
+                .withKey(new DeviceKey(id))
                 .setSshHostKey(sshEncodedKey)
                 .addAugmentation(Device1.class, d1);
 
@@ -262,7 +262,7 @@ class CallhomeStatusReporter implements DataTreeChangeListener<Node>, StatusReco
         InstanceIdentifier<Device> deviceIId =
                 InstanceIdentifier.create(NetconfCallhomeServer.class)
                         .child(AllowedDevices.class)
-                        .child(Device.class, device.getKey());
+                        .child(Device.class, device.key());
 
         tx.merge(LogicalDatastoreType.OPERATIONAL, deviceIId, device);
         tx.submit();
index 987fcc03646c64f3806674a533986c8cf96d8db6..982ec0c6f631abbe2c4fde470f2b58d28c99bfc2 100644 (file)
@@ -206,7 +206,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT
         Device1 devStatus = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.DISCONNECTED).build();
         if (opDevGet.isPresent()) {
             Device opDevice = opDevGet.get();
-            devStatus = opDevice.getAugmentation(Device1.class);
+            devStatus = opDevice.augmentation(Device1.class);
         }
 
         cfgDevice = new DeviceBuilder().addAugmentation(Device1.class, devStatus)
index 0bd79fde0ce6a734ca8540e0738dcf64a87347ee..66079b9ed8c807c3bd44e4982068d13c69551ab7 100644 (file)
@@ -62,32 +62,32 @@ public final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMoni
     }
 
     @Override
-    public void onSessionStarted(Session session) {
+    public void onSessionStarted(final Session session) {
         final InstanceIdentifier<Session> sessionPath =
-                SESSIONS_INSTANCE_IDENTIFIER.child(Session.class, session.getKey());
+                SESSIONS_INSTANCE_IDENTIFIER.child(Session.class, session.key());
         runTransaction((tx) -> tx.put(LogicalDatastoreType.OPERATIONAL, sessionPath, session));
     }
 
     @Override
-    public void onSessionEnded(Session session) {
+    public void onSessionEnded(final Session session) {
         final InstanceIdentifier<Session> sessionPath =
-                SESSIONS_INSTANCE_IDENTIFIER.child(Session.class, session.getKey());
+                SESSIONS_INSTANCE_IDENTIFIER.child(Session.class, session.key());
         runTransaction((tx) -> tx.delete(LogicalDatastoreType.OPERATIONAL, sessionPath));
     }
 
     @Override
-    public void onSessionsUpdated(Collection<Session> sessions) {
+    public void onSessionsUpdated(final Collection<Session> sessions) {
         runTransaction((tx) -> updateSessions(tx, sessions));
     }
 
     @Override
-    public void onCapabilitiesChanged(Capabilities capabilities) {
+    public void onCapabilitiesChanged(final Capabilities capabilities) {
         runTransaction((tx) -> tx.put(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_INSTANCE_IDENTIFIER,
                 capabilities));
     }
 
     @Override
-    public void onSchemasChanged(Schemas schemas) {
+    public void onSchemasChanged(final Schemas schemas) {
         runTransaction((tx) -> tx.put(LogicalDatastoreType.OPERATIONAL, SCHEMAS_INSTANCE_IDENTIFIER, schemas));
     }
 
@@ -99,27 +99,27 @@ public final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMoni
         serverMonitoringDependency.registerSessionsListener(this);
     }
 
-    private void runTransaction(Consumer<WriteTransaction> txUser) {
+    private void runTransaction(final Consumer<WriteTransaction> txUser) {
         Preconditions.checkState(dataBroker != null);
         final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         txUser.accept(tx);
         Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
             @Override
-            public void onSuccess(@Nullable Void result) {
+            public void onSuccess(@Nullable final Void result) {
                 LOG.debug("Netconf state updated successfully");
             }
 
             @Override
-            public void onFailure(Throwable throwable) {
+            public void onFailure(final Throwable throwable) {
                 LOG.warn("Unable to update netconf state", throwable);
             }
         }, MoreExecutors.directExecutor());
     }
 
-    private static void updateSessions(WriteTransaction tx, Collection<Session> sessions) {
+    private static void updateSessions(final WriteTransaction tx, final Collection<Session> sessions) {
         for (Session session : sessions) {
             final InstanceIdentifier<Session> sessionPath =
-                    SESSIONS_INSTANCE_IDENTIFIER.child(Session.class, session.getKey());
+                    SESSIONS_INSTANCE_IDENTIFIER.child(Session.class, session.key());
             tx.put(LogicalDatastoreType.OPERATIONAL, sessionPath, session);
         }
     }
index 05b6bd15f9054aeee639fb7fd62c090014bbbb81..5304743c8c8a5cfb054e4d697b05f248368015ed 100644 (file)
@@ -108,7 +108,7 @@ public class MonitoringToMdsalWriterTest {
         final InstanceIdentifier<Session> id =
                 InstanceIdentifier.create(NetconfState.class)
                         .child(Sessions.class)
-                        .child(Session.class, session.getKey());
+                        .child(Session.class, session.key());
         writer.start();
         writer.onSessionStarted(session);
         InOrder inOrder = inOrder(writeTransaction);
@@ -124,7 +124,7 @@ public class MonitoringToMdsalWriterTest {
         final InstanceIdentifier<Session> id =
                 InstanceIdentifier.create(NetconfState.class)
                         .child(Sessions.class)
-                        .child(Session.class, session.getKey());
+                        .child(Session.class, session.key());
         writer.start();
         writer.onSessionEnded(session);
         InOrder inOrder = inOrder(writeTransaction);
@@ -146,11 +146,11 @@ public class MonitoringToMdsalWriterTest {
         final InstanceIdentifier<Session> id1 =
                 InstanceIdentifier.create(NetconfState.class)
                         .child(Sessions.class)
-                        .child(Session.class, session1.getKey());
+                        .child(Session.class, session1.key());
         final InstanceIdentifier<Session> id2 =
                 InstanceIdentifier.create(NetconfState.class)
                         .child(Sessions.class)
-                        .child(Session.class, session2.getKey());
+                        .child(Session.class, session2.key());
         writer.start();
         writer.onSessionsUpdated(sessions);
         InOrder inOrder = inOrder(writeTransaction);
index d5ba353fe64ab4ed812c330c859d0104ddfe826a..5621f1728e7b4762365c76f0bc07eefde2e0ced2 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
 
-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.MoreExecutors;
@@ -35,6 +34,8 @@ public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNo
         .NetconfNotificationStreamListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(NotificationToMdsalWriter.class);
+    private static final InstanceIdentifier<Streams> STREAMS = InstanceIdentifier.builder(Netconf.class)
+            .child(Streams.class).build();
 
     private final NetconfNotificationCollector netconfNotificationCollector;
     private final DataBroker dataBroker;
@@ -50,16 +51,15 @@ public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNo
     public void close() {
         final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.delete(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Netconf.class));
-        final CheckedFuture<Void, TransactionCommitFailedException> submit = tx.submit();
 
-        Futures.addCallback(submit, new FutureCallback<Void>() {
+        Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
             @Override
-            public void onSuccess(Void avoid) {
+            public void onSuccess(final Void avoid) {
                 LOG.debug("Streams cleared successfully");
             }
 
             @Override
-            public void onFailure(Throwable throwable) {
+            public void onFailure(final Throwable throwable) {
                 LOG.warn("Unable to clear streams", throwable);
             }
         }, MoreExecutors.directExecutor());
@@ -75,11 +75,10 @@ public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNo
     }
 
     @Override
-    public void onStreamRegistered(Stream stream) {
+    public void onStreamRegistered(final Stream stream) {
         final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
 
-        final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class).child(Streams.class)
-                .builder().child(Stream.class, stream.getKey()).build();
+        final InstanceIdentifier<Stream> streamIdentifier = STREAMS.child(Stream.class, stream.key());
         tx.merge(LogicalDatastoreType.OPERATIONAL, streamIdentifier, stream, true);
 
         try {
@@ -91,12 +90,10 @@ public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNo
     }
 
     @Override
-    public void onStreamUnregistered(StreamNameType stream) {
+    public void onStreamUnregistered(final StreamNameType stream) {
         final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
 
-        final StreamKey streamKey = new StreamKey(stream);
-        final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class).child(Streams.class)
-                .builder().child(Stream.class, streamKey).build();
+        final InstanceIdentifier<Stream> streamIdentifier = STREAMS.child(Stream.class, new StreamKey(stream));
 
         tx.delete(LogicalDatastoreType.OPERATIONAL, streamIdentifier);
 
index 549c0ce2e1504aa7f4a97ac477bdc789f862c9d3..5652af80ce7945a6114d5f25fe389903724a5ef0 100644 (file)
@@ -74,8 +74,8 @@ public class CapabilityChangeNotificationProducerTest {
 
     @Test
     public void testOnDataChangedCreate() {
-        final InstanceIdentifier capabilitiesIdentifier =
-                InstanceIdentifier.create(NetconfState.class).child(Capabilities.class).builder().build();
+        final InstanceIdentifier<Capabilities> capabilitiesIdentifier =
+                InstanceIdentifier.create(NetconfState.class).child(Capabilities.class);
         final List<Uri> newCapabilitiesList =
                 Lists.newArrayList(new Uri("newCapability"), new Uri("createdCapability"));
         Capabilities newCapabilities = new CapabilitiesBuilder().setCapability(newCapabilitiesList).build();
@@ -111,8 +111,8 @@ public class CapabilityChangeNotificationProducerTest {
 
     @SuppressWarnings("unchecked")
     private void verifyDataTreeChange(final DataObjectModification.ModificationType modificationType,
-                                      Capabilities originalCapabilities, Capabilities updatedCapabilities,
-                                      NetconfCapabilityChange expectedChange) {
+                                      final Capabilities originalCapabilities, final Capabilities updatedCapabilities,
+                                      final NetconfCapabilityChange expectedChange) {
         final DataTreeModification<Capabilities> treeChange2 = mock(DataTreeModification.class);
         final DataObjectModification<Capabilities> objectChange2 = mock(DataObjectModification.class);
         doReturn(modificationType).when(objectChange2).getModificationType();
@@ -123,7 +123,7 @@ public class CapabilityChangeNotificationProducerTest {
         verify(baseNotificationPublisherRegistration).onCapabilityChanged(expectedChange);
     }
 
-    private NetconfCapabilityChange changedCapabilitesFrom(List<Uri> added, List<Uri> deleted) {
+    private NetconfCapabilityChange changedCapabilitesFrom(final List<Uri> added, final List<Uri> deleted) {
         NetconfCapabilityChangeBuilder netconfCapabilityChangeBuilder = new NetconfCapabilityChangeBuilder();
         netconfCapabilityChangeBuilder.setChangedBy(new ChangedByBuilder().setServerOrUser(
                 new ServerBuilder().setServer(true).build()).build());
index 072fc3657ab0b31cd9e9a03b3ac7ba78fa23e191..5c7fdb8b93ebc6de75f0e477cef39970d5402cd3 100644 (file)
@@ -69,8 +69,8 @@ public class NotificationToMdsalWriterTest {
     public void testStreamRegisteration() {
         final StreamNameType testStreamName = new StreamNameType("TESTSTREAM");
         final Stream testStream = new StreamBuilder().setName(testStreamName).build();
-        final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class).child(Streams.class)
-                .builder().child(Stream.class, testStream.getKey()).build();
+        final InstanceIdentifier<Stream> streamIdentifier = InstanceIdentifier.create(Netconf.class)
+                .child(Streams.class).child(Stream.class, testStream.key());
 
         writer.onStreamRegistered(testStream);
 
@@ -86,7 +86,7 @@ public class NotificationToMdsalWriterTest {
     public void testClose() {
         doNothing().when(notificationRegistration).close();
 
-        final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class);
+        final InstanceIdentifier<Netconf> streamIdentifier = InstanceIdentifier.create(Netconf.class);
 
         writer.close();
 
index 0722d8ae01c86b89cc774ba07085623c9fe0f1ab..2581ae692406c445bbca17f181672f9c1b255670 100644 (file)
@@ -284,7 +284,7 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
 
     @Override
     public NodeKey getSourceNodeKey() {
-        return mount.getNode().getKey();
+        return mount.getNode().key();
     }
 
     @Override
index 6360136b9fd3f401cf1b6c2e2f0b558ebb8f705a..fe409a8ed02399b81d2e28dc60e6075f6f4ac0ee 100644 (file)
@@ -79,7 +79,7 @@ public final class NetconfEventSourceManager implements DataTreeChangeListener<N
     }
 
     @Override
-    public void onDataTreeChanged(Collection<DataTreeModification<Node>> changes) {
+    public void onDataTreeChanged(final Collection<DataTreeModification<Node>> changes) {
         for (DataTreeModification<Node> change: changes) {
             LOG.debug("DataTreeModification: {}", change);
             final DataObjectModification<Node> rootNode = change.getRootNode();
@@ -123,11 +123,8 @@ public final class NetconfEventSourceManager implements DataTreeChangeListener<N
         }
     }
 
-    private boolean validateNode(final Node node) {
-        if (node == null) {
-            return false;
-        }
-        return isNetconfNode(node);
+    private static boolean validateNode(final Node node) {
+        return node == null ? false : isNetconfNode(node);
     }
 
     Map<String, String> getStreamMap() {
@@ -151,12 +148,12 @@ public final class NetconfEventSourceManager implements DataTreeChangeListener<N
      *
      * @param streamMap Stream map
      */
-    public void setStreamMap(Map<String, String> streamMap) {
+    public void setStreamMap(final Map<String, String> streamMap) {
         this.streamMap = streamMap;
     }
 
-    private boolean isNetconfNode(final Node node) {
-        return node.getAugmentation(NetconfNode.class) != null;
+    private static boolean isNetconfNode(final Node node) {
+        return node.augmentation(NetconfNode.class) != null;
     }
 
     @Override
index 649454ef11c866b945e81f70a7d806297c1ee645..2d1aab54e89c8da45eb6d4e513a95b271ae17e13 100644 (file)
@@ -60,7 +60,7 @@ public final class NetconfEventSourceRegistration implements AutoCloseable {
     }
 
     private static boolean isEventSource(final Node node) {
-        final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+        final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
         if (netconfNode == null) {
             return false;
         }
@@ -92,7 +92,7 @@ public final class NetconfEventSourceRegistration implements AutoCloseable {
     }
 
     NetconfNode getNetconfNode() {
-        return node.getAugmentation(NetconfNode.class);
+        return node.augmentation(NetconfNode.class);
     }
 
     void updateStatus() {
@@ -104,12 +104,12 @@ public final class NetconfEventSourceRegistration implements AutoCloseable {
         changeStatus(netconfConnStatus);
     }
 
-    private boolean checkConnectionStatusType(ConnectionStatus status) {
+    private static boolean checkConnectionStatusType(final ConnectionStatus status) {
         return status == ConnectionStatus.Connected || status == ConnectionStatus.Connecting
                 || status == ConnectionStatus.UnableToConnect;
     }
 
-    private void changeStatus(ConnectionStatus newStatus) {
+    private void changeStatus(final ConnectionStatus newStatus) {
         Preconditions.checkNotNull(newStatus);
         Preconditions.checkState(this.currentNetconfConnStatus != null);
         if (!checkConnectionStatusType(newStatus)) {
@@ -155,7 +155,7 @@ public final class NetconfEventSourceRegistration implements AutoCloseable {
         this.eventSourceRegistration = registration;
     }
 
-    private YangInstanceIdentifier domMountPath(final NodeId nodeId) {
+    private static YangInstanceIdentifier domMountPath(final NodeId nodeId) {
         return YangInstanceIdentifier.builder(NETCONF_DEVICE_DOM_PATH)
                 .nodeWithKey(Node.QNAME, NODE_ID_QNAME, nodeId.getValue()).build();
     }
index 25c3a84756a0c80b3afcef498b65fd938bd3223b..aa908b2e09b6db280417c85be75988cb927e8f7e 100644 (file)
@@ -51,8 +51,8 @@ public final class NetconfTestUtils {
     private NetconfTestUtils() {
     }
 
-    public static Node getNetconfNode(String nodeIdent, String hostName, ConnectionStatus cs,
-                                      String notificationCapabilityPrefix) {
+    public static Node getNetconfNode(final String nodeIdent, final String hostName, final ConnectionStatus cs,
+                                      final String notificationCapabilityPrefix) {
 
         DomainName dn = new DomainName(hostName);
         Host host = new Host(dn);
@@ -67,28 +67,28 @@ public final class NetconfTestUtils {
         NodeId nodeId = new NodeId(nodeIdent);
         NodeKey nk = new NodeKey(nodeId);
         NodeBuilder nb = new NodeBuilder();
-        nb.setKey(nk);
+        nb.withKey(nk);
 
         nb.addAugmentation(NetconfNode.class, nn);
         return nb.build();
     }
 
-    public static Node getNode(String nodeIdent) {
+    public static Node getNode(final String nodeIdent) {
         NodeId nodeId = new NodeId(nodeIdent);
         NodeKey nk = new NodeKey(nodeId);
         NodeBuilder nb = new NodeBuilder();
-        nb.setKey(nk);
+        nb.withKey(nk);
         return nb.build();
     }
 
-    public static InstanceIdentifier<Node> getInstanceIdentifier(Node node) {
+    public static InstanceIdentifier<Node> getInstanceIdentifier(final Node node) {
         TopologyKey netconfTopologyKey = new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()));
         InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(NetworkTopology.class)
-                .child(Topology.class, netconfTopologyKey).child(Node.class, node.getKey());
+                .child(Topology.class, netconfTopologyKey).child(Node.class, node.key());
         return nodeII;
     }
 
-    public static Optional<Streams> getAvailableStream(String name, boolean replaySupport) {
+    public static Optional<Streams> getAvailableStream(final String name, final boolean replaySupport) {
         Stream stream = new StreamBuilder().setName(new StreamNameType(name)).setReplaySupport(replaySupport).build();
         List<Stream> streamList = new ArrayList<>();
         streamList.add(stream);
@@ -96,7 +96,7 @@ public final class NetconfTestUtils {
         return Optional.of(streams);
     }
 
-    public static NormalizedNode<?, ?> getStreamsNode(String... streamName) {
+    public static NormalizedNode<?, ?> getStreamsNode(final String... streamName) {
         QName nameNode = QName.create(Stream.QNAME, "name");
         Set<MapEntryNode> streamSet = new HashSet<>();
         for (String s : streamName) {
index 8954e4a2947cc3c20a10108447e8d617b315fa83..21d1697659ceec75c2bd7d9824e8f91efafe357b 100644 (file)
@@ -68,7 +68,7 @@ public class NetconfCommandsImpl implements NetconfCommands {
         }
         final Map<String, Map<String, String>> netconfNodes = new HashMap<>();
         for (final Node node : topology.getNode()) {
-            final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+            final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
             final Map<String, String> attributes = new HashMap<>();
             attributes.put(NetconfConsoleConstants.NETCONF_ID, node.getNodeId().getValue());
             attributes.put(NetconfConsoleConstants.NETCONF_IP,
@@ -93,7 +93,7 @@ public class NetconfCommandsImpl implements NetconfCommands {
         if (nodeList != null) {
             for (final Node node : nodeList) {
                 if (node != null) {
-                    final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+                    final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
                     final Map<String, List<String>> attributes = new HashMap<>();
                     attributes.put(NetconfConsoleConstants.NETCONF_ID, ImmutableList.of(node.getNodeId().getValue()));
                     attributes.put(NetconfConsoleConstants.NETCONF_IP,
@@ -123,7 +123,7 @@ public class NetconfCommandsImpl implements NetconfCommands {
         final List<Node> nodeList = NetconfConsoleUtils.getNetconfNodeFromId(deviceId, dataBroker);
         if (nodeList != null && nodeList.size() > 0) {
             for (final Node node : nodeList) {
-                final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+                final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
                 final Map<String, List<String>> attributes = new HashMap<>();
                 attributes.put(NetconfConsoleConstants.NETCONF_ID, ImmutableList.of(node.getNodeId().getValue()));
                 attributes.put(NetconfConsoleConstants.NETCONF_IP,
@@ -146,7 +146,7 @@ public class NetconfCommandsImpl implements NetconfCommands {
     }
 
     @Override
-    public void connectDevice(NetconfNode netconfNode, String netconfNodeId) {
+    public void connectDevice(final NetconfNode netconfNode, final String netconfNodeId) {
         final NodeId nodeId;
         if (!Strings.isNullOrEmpty(netconfNodeId)) {
             nodeId = new NodeId(netconfNodeId);
@@ -154,7 +154,7 @@ public class NetconfCommandsImpl implements NetconfCommands {
             nodeId = new NodeId(UUID.randomUUID().toString().replace("-", ""));
         }
         final Node node = new NodeBuilder()
-                .setKey(new NodeKey(nodeId))
+                .withKey(new NodeKey(nodeId))
                 .setNodeId(nodeId)
                 .addAugmentation(NetconfNode.class, netconfNode)
                 .build();
@@ -165,12 +165,12 @@ public class NetconfCommandsImpl implements NetconfCommands {
         Futures.addCallback(transaction.submit(), new FutureCallback<Void>() {
 
             @Override
-            public void onSuccess(Void result) {
+            public void onSuccess(final Void result) {
                 LOG.debug("NetconfNode={} created successfully", netconfNode);
             }
 
             @Override
-            public void onFailure(Throwable throwable) {
+            public void onFailure(final Throwable throwable) {
                 LOG.error("Failed to created NetconfNode={}", netconfNode);
                 throw new RuntimeException(throwable);
             }
@@ -178,7 +178,7 @@ public class NetconfCommandsImpl implements NetconfCommands {
     }
 
     @Override
-    public boolean disconnectDevice(String netconfNodeId) {
+    public boolean disconnectDevice(final String netconfNodeId) {
         boolean result = false;
         final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         InstanceIdentifier<Node> iid = NetconfIidFactory.netconfNodeIid(netconfNodeId);
@@ -202,13 +202,13 @@ public class NetconfCommandsImpl implements NetconfCommands {
     }
 
     @Override
-    public String updateDevice(final String netconfNodeId, String username, String password,
-                               Map<String, String> updated) {
+    public String updateDevice(final String netconfNodeId, final String username, final String password,
+                               final Map<String, String> updated) {
         final Node node = NetconfConsoleUtils
                 .read(LogicalDatastoreType.OPERATIONAL, NetconfIidFactory.netconfNodeIid(netconfNodeId), dataBroker);
 
-        if (node != null && node.getAugmentation(NetconfNode.class) != null) {
-            final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+        if (node != null && node.augmentation(NetconfNode.class) != null) {
+            final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
 
             // Get NETCONF attributes to update if present else get their original values from NetconfNode instance
             final String deviceIp = Strings.isNullOrEmpty(updated.get(NetconfConsoleConstants.NETCONF_IP))
@@ -235,7 +235,7 @@ public class NetconfCommandsImpl implements NetconfCommands {
                     .build();
 
             final Node updatedNode = new NodeBuilder()
-                    .setKey(node.getKey())
+                    .withKey(node.key())
                     .setNodeId(node.getNodeId())
                     .addAugmentation(NetconfNode.class, updatedNetconfNode)
                     .build();
@@ -247,12 +247,12 @@ public class NetconfCommandsImpl implements NetconfCommands {
             Futures.addCallback(transaction.submit(), new FutureCallback<Void>() {
 
                 @Override
-                public void onSuccess(Void result) {
+                public void onSuccess(final Void result) {
                     LOG.debug("NetconfNode={} updated successfully", netconfNode);
                 }
 
                 @Override
-                public void onFailure(Throwable throwable) {
+                public void onFailure(final Throwable throwable) {
                     LOG.error("Failed to updated NetconfNode={}", netconfNode);
                     throw new RuntimeException(throwable);
                 }
index 560ddcae4a02923fb683b24e7f03d2115467191a..7766847198fe20ce3f65ed50b11b5fcd447c9441 100644 (file)
@@ -42,14 +42,14 @@ public final class NetconfConsoleUtils {
         List<Node> nodes = new ArrayList<>();
         if (isNetconfNodesPresent(topology)) {
             for (Node node : topology.getNode()) {
-                final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+                final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
                 if (netconfNode != null
                         && netconfNode.getHost().getIpAddress().getIpv4Address().getValue().equals(deviceIp)) {
                     nodes.add(node);
                 }
             }
         }
-        return (nodes.isEmpty()) ? null : nodes;
+        return nodes.isEmpty() ? null : nodes;
     }
 
     /**
@@ -78,7 +78,7 @@ public final class NetconfConsoleUtils {
         final Topology topology = read(LogicalDatastoreType.OPERATIONAL, NetconfIidFactory.NETCONF_TOPOLOGY_IID, db);
         if (isNetconfNodesPresent(topology)) {
             for (Node node : topology.getNode()) {
-                final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+                final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
                 if (netconfNode != null
                         && netconfNode.getHost().getIpAddress().getIpv4Address().getValue().equals(deviceIp)
                         && devicePort.equals(netconfNode.getPort().getValue().toString())) {
index 576408b371e6a8d95e9a876a365eb7f7b20a4c64..0b5e6083fecbb68a59e72b6bd702b93155322dc0 100644 (file)
@@ -169,11 +169,11 @@ public class NetconfCommandsImplTest {
         assertEquals(2, nodes.size());
 
         final Optional<Node> storedNode = nodes.stream().filter(node ->
-                node.getKey().getNodeId().getValue().equals("netconf-ID")).findFirst();
+                node.key().getNodeId().getValue().equals("netconf-ID")).findFirst();
 
         assertTrue(storedNode.isPresent());
 
-        NetconfNode storedNetconfNode = storedNode.get().getAugmentation(NetconfNode.class);
+        NetconfNode storedNetconfNode = storedNode.get().augmentation(NetconfNode.class);
         assertEquals(7777, storedNetconfNode.getPort().getValue().longValue());
         assertEquals("10.10.1.1", storedNetconfNode.getHost().getIpAddress().getIpv4Address().getValue());
 
@@ -185,7 +185,7 @@ public class NetconfCommandsImplTest {
         assertEquals(1, nodesDeleted.size());
 
         final Optional<Node> storedNodeDeleted = nodesDeleted.stream().filter(node ->
-                node.getKey().getNodeId().getValue().equals("netconf-ID")).findFirst();
+                node.key().getNodeId().getValue().equals("netconf-ID")).findFirst();
 
         assertFalse(storedNodeDeleted.isPresent());
     }
@@ -210,10 +210,10 @@ public class NetconfCommandsImplTest {
         assertEquals(1, nodes.size());
 
         final Optional<Node> storedNode = nodes.stream().filter(node ->
-                node.getKey().getNodeId().getValue().equals(NODE_ID)).findFirst();
+                node.key().getNodeId().getValue().equals(NODE_ID)).findFirst();
         assertTrue(storedNode.isPresent());
 
-        NetconfNode storedNetconfNode = storedNode.get().getAugmentation(NetconfNode.class);
+        NetconfNode storedNetconfNode = storedNode.get().augmentation(NetconfNode.class);
         assertEquals("7.7.7.7", storedNetconfNode.getHost().getIpAddress().getIpv4Address().getValue());
     }
 
@@ -234,7 +234,7 @@ public class NetconfCommandsImplTest {
         nodes.add(node);
 
         final Topology topology = new TopologyBuilder()
-                .setKey(new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
+                .withKey(new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
                 .setTopologyId(new TopologyId(TopologyNetconf.QNAME.getLocalName())).setNode(nodes).build();
 
         final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
@@ -260,7 +260,7 @@ public class NetconfCommandsImplTest {
         final NodeId nodeId = new NodeId(nodeIdent);
         final NodeKey nk = new NodeKey(nodeId);
         final NodeBuilder nb = new NodeBuilder();
-        nb.setKey(nk);
+        nb.withKey(nk);
         nb.setNodeId(nodeId);
         nb.addAugmentation(NetconfNode.class, nn);
         return nb.build();
index dc314c05e0fe49a198ce33cce94925faa305af44..bb0964bb5892541877af2a4eaeec518b53d8647d 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.base.Preconditions;
 import com.google.common.net.InetAddresses;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
 import io.netty.handler.codec.ByteToMessageDecoder;
 import io.netty.handler.codec.MessageToByteEncoder;
 import java.net.Inet4Address;
@@ -97,12 +96,7 @@ public final class NetconfServerSession extends AbstractNetconfSession<NetconfSe
         }
         // delayed close was set, close after the message was sent
         if (delayedClose) {
-            channelFuture.addListener(new ChannelFutureListener() {
-                @Override
-                public void operationComplete(final ChannelFuture future) throws Exception {
-                    close();
-                }
-            });
+            channelFuture.addListener(future -> close());
         }
         return channelFuture;
     }
@@ -150,7 +144,7 @@ public final class NetconfServerSession extends AbstractNetconfSession<NetconfSe
 
         builder.setOutNotifications(new ZeroBasedCounter32(outNotification));
 
-        builder.setKey(new SessionKey(getSessionId()));
+        builder.withKey(new SessionKey(getSessionId()));
 
         Session1Builder builder1 = new Session1Builder();
         builder1.setSessionIdentifier(header.getSessionIdentifier());
index 6259ba28a3af10d84eaf787c28ac09dc6b10b3c0..4aafb58654ac5c432da48efa5dc54514f52eac30 100644 (file)
@@ -171,7 +171,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
 
                 builder.setLocation(transformLocations(cap.getLocation()));
 
-                builder.setKey(new SchemaKey(Yang.class, identifier, version));
+                builder.withKey(new SchemaKey(Yang.class, identifier, version));
 
                 schemas.add(builder.build());
             }
index 7fb3fa11e2d5d5af232ee6fe37afc8d5aef2badc..267950444ba04891b134564a8b4b5531ddd01c39 100644 (file)
@@ -21,14 +21,14 @@ final class MonitoringSession {
     @XmlTransient
     private Session managementSession;
 
-    MonitoringSession(Session managementSession) {
+    MonitoringSession(final Session managementSession) {
         this.managementSession = managementSession;
     }
 
     MonitoringSession() {
     }
 
-    public void setManagementSession(Session managementSession) {
+    public void setManagementSession(final Session managementSession) {
         this.managementSession = managementSession;
     }
 
@@ -90,7 +90,7 @@ final class MonitoringSession {
 
     @XmlElement(name = "session-identifier", namespace = MonitoringConstants.EXTENSION_NAMESPACE)
     public String getSessionType() {
-        return managementSession.getAugmentation(Session1.class).getSessionIdentifier();
+        return managementSession.augmentation(Session1.class).getSessionIdentifier();
     }
 
     @XmlElement(name = "username")
index 0a3bdabbf284322f43adee12794ae82c6d6ef829..b7b460f55d1e37f5f1a428005ad85dfb5c437682 100644 (file)
@@ -93,7 +93,7 @@ public class JaxBSerializerTest {
                 String.format(SESSION_XML, IPV6)));
     }
 
-    private Schema getMockSchema(final String id, final String version, final Class<Yang> format) {
+    private static Schema getMockSchema(final String id, final String version, final Class<Yang> format) {
         final Schema mock = mock(Schema.class);
 
         doReturn(format).when(mock).getFormat();
@@ -101,23 +101,23 @@ public class JaxBSerializerTest {
         doReturn(new Uri("localhost")).when(mock).getNamespace();
         doReturn(version).when(mock).getVersion();
         doReturn(Lists.newArrayList(new Schema.Location(Schema.Location.Enumeration.NETCONF))).when(mock).getLocation();
-        doReturn(new SchemaKey(format, id, version)).when(mock).getKey();
+        doReturn(new SchemaKey(format, id, version)).when(mock).key();
         return mock;
     }
 
-    private Session getMockIPv4Session(final Class<? extends Transport> transportType) {
+    private static Session getMockIPv4Session(final Class<? extends Transport> transportType) {
         final Session mocked = getMockSession(transportType);
         doReturn(new Host(new IpAddress(new Ipv4Address(IPV4)))).when(mocked).getSourceHost();
         return mocked;
     }
 
-    private Session getMockIPv6Session(final Class<? extends Transport> transportType) {
+    private static Session getMockIPv6Session(final Class<? extends Transport> transportType) {
         final Session mocked = getMockSession(transportType);
         doReturn(new Host(new IpAddress(new Ipv6Address(IPV6)))).when(mocked).getSourceHost();
         return mocked;
     }
 
-    private Session getMockSession(final Class<? extends Transport> transportType) {
+    private static Session getMockSession(final Class<? extends Transport> transportType) {
         final Session mocked = mock(Session.class);
         final Session1 mockedSession1 = mock(Session1.class);
         doReturn("client").when(mockedSession1).getSessionIdentifier();
@@ -129,7 +129,7 @@ public class JaxBSerializerTest {
         doReturn(new ZeroBasedCounter32(0L)).when(mocked).getOutRpcErrors();
         doReturn(transportType).when(mocked).getTransport();
         doReturn("username").when(mocked).getUsername();
-        doReturn(mockedSession1).when(mocked).getAugmentation(Session1.class);
+        doReturn(mockedSession1).when(mocked).augmentation(Session1.class);
         return mocked;
     }
 }
index c8989e59496ae304ccbf721f75c4e3d3c3023c29..ac29d547444c8f321be54deecb38de42c78678b5 100644 (file)
@@ -53,7 +53,7 @@ public class NetconfNotificationManager implements NetconfNotificationCollector,
     static {
         BASE_NETCONF_STREAM = new StreamBuilder()
                 .setName(BASE_STREAM_NAME)
-                .setKey(new StreamKey(BASE_STREAM_NAME))
+                .withKey(new StreamKey(BASE_STREAM_NAME))
                 .setReplaySupport(false)
                 .setDescription("Default Event Stream")
                 .build();
@@ -138,12 +138,9 @@ public class NetconfNotificationManager implements NetconfNotificationCollector,
             listener.onStreamRegistered(availableStream);
         }
 
-        return new NotificationRegistration() {
-            @Override
-            public void close() {
-                synchronized (NetconfNotificationManager.this) {
-                    streamListeners.remove(listener);
-                }
+        return () -> {
+            synchronized (NetconfNotificationManager.this) {
+                streamListeners.remove(listener);
             }
         };
     }
@@ -277,7 +274,8 @@ public class NetconfNotificationManager implements NetconfNotificationCollector,
             baseRegistration.close();
         }
 
-        private static NetconfNotification serializeNotification(final Notification notification, SchemaPath path) {
+        private static NetconfNotification serializeNotification(final Notification notification,
+                final SchemaPath path) {
             return NotificationsTransformUtil.transform(notification, path);
         }
 
@@ -288,12 +286,12 @@ public class NetconfNotificationManager implements NetconfNotificationCollector,
         }
 
         @Override
-        public void onSessionStarted(NetconfSessionStart start) {
+        public void onSessionStarted(final NetconfSessionStart start) {
             baseRegistration.onNotification(BASE_STREAM_NAME, serializeNotification(start, SESSION_START_PATH));
         }
 
         @Override
-        public void onSessionEnded(NetconfSessionEnd end) {
+        public void onSessionEnded(final NetconfSessionEnd end) {
             baseRegistration.onNotification(BASE_STREAM_NAME, serializeNotification(end, SESSION_END_PATH));
         }
     }
index 90c975df4ccb22f6689e5289b8017b38de6e26c9..0a7aa6d7e5eb45fa2e8ecf6caf3a49ae03969a1a 100644 (file)
@@ -28,7 +28,7 @@ public class GetTest {
         final StreamBuilder streamBuilder = new StreamBuilder();
         final StreamNameType base = new StreamNameType("base");
         streamBuilder.setName(base);
-        streamBuilder.setKey(new StreamKey(base));
+        streamBuilder.withKey(new StreamKey(base));
         streamBuilder.setDescription("description");
         streamBuilder.setReplaySupport(false);
         streamsBuilder.setStream(Lists.newArrayList(streamBuilder.build()));
index b749d011ad4db3ec53a5b1ead10349b14cab351e..1fdce0c0b85a2bece422b51303757c8e74f87b43 100644 (file)
@@ -158,7 +158,7 @@ class NetconfNodeManager
         }
 
         @SuppressWarnings("ConstantConditions")
-        final NetconfNode netconfNodeAfter = rootNode.getDataAfter().getAugmentation(NetconfNode.class);
+        final NetconfNode netconfNodeAfter = rootNode.getDataAfter().augmentation(NetconfNode.class);
 
         if (NetconfNodeConnectionStatus.ConnectionStatus.Connected.equals(netconfNodeAfter.getConnectionStatus())) {
             lastUpdateCount++;
index 2560d7bd2f031758b44a1b71eef3336ba894a0e9..7275be18e6aaeda1620cffcf57e4557882d6c29f 100644 (file)
@@ -60,7 +60,7 @@ class NetconfTopologyContext implements ClusterSingletonService, AutoCloseable {
         this.mountService = mountService;
 
         remoteDeviceId = NetconfTopologyUtils.createRemoteDeviceId(netconfTopologyDeviceSetup.getNode().getNodeId(),
-                netconfTopologyDeviceSetup.getNode().getAugmentation(NetconfNode.class));
+                netconfTopologyDeviceSetup.getNode().augmentation(NetconfNode.class));
 
         remoteDeviceConnector = new RemoteDeviceConnectorImpl(netconfTopologyDeviceSetup, remoteDeviceId);
 
@@ -114,7 +114,7 @@ class NetconfTopologyContext implements ClusterSingletonService, AutoCloseable {
         final NetconfNodeManager ndm =
                 new NetconfNodeManager(netconfTopologyDeviceSetup, remoteDeviceId, actorResponseWaitTime, mountService);
         ndm.registerDataTreeChangeListener(netconfTopologyDeviceSetup.getTopologyId(),
-                netconfTopologyDeviceSetup.getNode().getKey());
+                netconfTopologyDeviceSetup.getNode().key());
 
         return ndm;
     }
@@ -139,7 +139,7 @@ class NetconfTopologyContext implements ClusterSingletonService, AutoCloseable {
     void refresh(@Nonnull final NetconfTopologySetup setup) {
         netconfTopologyDeviceSetup = Preconditions.checkNotNull(setup);
         remoteDeviceId = NetconfTopologyUtils.createRemoteDeviceId(netconfTopologyDeviceSetup.getNode().getNodeId(),
-                netconfTopologyDeviceSetup.getNode().getAugmentation(NetconfNode.class));
+                netconfTopologyDeviceSetup.getNode().augmentation(NetconfNode.class));
 
         if (isMaster) {
             remoteDeviceConnector.stopRemoteDeviceConnection();
index 4096153d1237d3e7bb8f32c349763d8f46bf187a..86b7111f78ce325bfd0b6ee6285f08df3ee30922 100644 (file)
@@ -153,7 +153,7 @@ public class NetconfTopologyManager
     // TODO change to a specific documented Exception when changed in ClusterSingletonServiceProvider
     @SuppressWarnings("checkstyle:IllegalCatch")
     private void startNetconfDeviceContext(final InstanceIdentifier<Node> instanceIdentifier, final Node node) {
-        final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+        final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
         Preconditions.checkNotNull(netconfNode);
         Preconditions.checkNotNull(netconfNode.getHost());
         Preconditions.checkNotNull(netconfNode.getHost().getIpAddress());
@@ -230,14 +230,14 @@ public class NetconfTopologyManager
     /**
      * Sets the private key path from location specified in configuration file using blueprint.
      */
-    public void setPrivateKeyPath(String privateKeyPath) {
+    public void setPrivateKeyPath(final String privateKeyPath) {
         this.privateKeyPath = privateKeyPath;
     }
 
     /**
      * Sets the private key passphrase from location specified in configuration file using blueprint.
      */
-    public void setPrivateKeyPassphrase(String privateKeyPassphrase) {
+    public void setPrivateKeyPassphrase(final String privateKeyPassphrase) {
         this.privateKeyPassphrase = privateKeyPassphrase;
     }
 
index eb99f5cf52c77e8913ba0583b516a5d1894c9042..71fbda8ae35d6e16df313d235905055574160be1 100644 (file)
@@ -105,7 +105,7 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
     @Override
     public void startRemoteDeviceConnection(final RemoteDeviceHandler<NetconfSessionPreferences> deviceHandler) {
 
-        final NetconfNode netconfNode = netconfTopologyDeviceSetup.getNode().getAugmentation(NetconfNode.class);
+        final NetconfNode netconfNode = netconfTopologyDeviceSetup.getNode().augmentation(NetconfNode.class);
         final NodeId nodeId = netconfTopologyDeviceSetup.getNode().getNodeId();
         Preconditions.checkNotNull(netconfNode.getHost());
         Preconditions.checkNotNull(netconfNode.getPort());
index eff84bba1fd2e1b9f9be22a8384dca8ed739b296..474619ee24d05d9ce4125ba3aaa99c532761c453 100644 (file)
@@ -113,7 +113,7 @@ public final class NetconfTopologyUtils {
     }
 
     public static NetconfDevice.SchemaResourcesDTO setupSchemaCacheDTO(final Node node) {
-        final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+        final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
         final String moduleSchemaCacheDirectory = netconfNode.getSchemaCacheDirectory();
         final RemoteDeviceId deviceId = createRemoteDeviceId(node.getNodeId(), netconfNode);
 
index b19a2cca2079ba04b035217c198ff925a06d1253..6b292647000ea2db2d584990bf072a5efabaa77b 100644 (file)
@@ -451,7 +451,7 @@ public class MountPointEndToEndTest {
                 Optional<Node> node = readTx.read(LogicalDatastoreType.OPERATIONAL,
                         NODE_INSTANCE_ID).get(5, TimeUnit.SECONDS);
                 assertTrue(node.isPresent());
-                final NetconfNode netconfNode = node.get().getAugmentation(NetconfNode.class);
+                final NetconfNode netconfNode = node.get().augmentation(NetconfNode.class);
                 return netconfNode.getConnectionStatus() != NetconfNodeConnectionStatus.ConnectionStatus.Connected;
             }
         });
index 5f7f3594dedc5df2ff7cf6bfdf246779b9da7676..b5f6a172fd8f005e0946579bbf0f94974a66d6db 100644 (file)
@@ -249,7 +249,7 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
 
     protected ListenableFuture<NetconfDeviceCapabilities> setupConnection(final NodeId nodeId,
                                                                           final Node configNode) {
-        final NetconfNode netconfNode = configNode.getAugmentation(NetconfNode.class);
+        final NetconfNode netconfNode = configNode.augmentation(NetconfNode.class);
 
         Preconditions.checkNotNull(netconfNode.getHost());
         Preconditions.checkNotNull(netconfNode.getPort());
index 7017d807bc2cc005158a7d8d1d230b1095f47d3a..f27f09eb7ec3391a3516a020b86a4805af3473c1 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.topology.impl;
 
-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.MoreExecutors;
@@ -15,7 +14,6 @@ import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.netconf.topology.api.NetconfConnectorFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.HostBuilder;
@@ -77,15 +75,14 @@ public class NetconfConnectorFactoryImpl implements NetconfConnectorFactory {
                 .build();
         final Node node =  new NodeBuilder()
                 .setNodeId(nodeId)
-                .setKey(nodeKey)
+                .withKey(nodeKey)
                 .addAugmentation(NetconfNode.class, netconfNode)
                 .build();
 
         final InstanceIdentifier<Node> nodePath = TOPOLOGY_PATH.child(Node.class, nodeKey);
         final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.put(LogicalDatastoreType.CONFIGURATION, nodePath, node);
-        final CheckedFuture<Void, TransactionCommitFailedException> submitFuture = transaction.submit();
-        Futures.addCallback(submitFuture, new FutureCallback<Void>() {
+        Futures.addCallback(transaction.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(@Nullable final Void result) {
                 LOG.debug("Node {} was successfully added to the topology", instanceName);
index 9e247018e19638d1d169f69a58e648e91b15d9c7..1d8b4a1aca9aeeed3cb7eb0c099008b08e3bdb8b 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.netconf.sal.connect.netconf.sal;
 
 import com.google.common.base.Preconditions;
-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.MoreExecutors;
@@ -21,7 +20,6 @@ import java.util.stream.Collectors;
 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
@@ -229,9 +227,8 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
     private void commitTransaction(final WriteTransaction transaction, final String txType) {
         LOG.trace("{}: Committing Transaction {}:{}", id, txType,
                 transaction.getIdentifier());
-        final CheckedFuture<Void, TransactionCommitFailedException> result = transaction.submit();
 
-        Futures.addCallback(result, new FutureCallback<Void>() {
+        Futures.addCallback(transaction.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(final Void result) {
                 LOG.trace("{}: Transaction({}) {} SUCCESSFUL", id, txType,
@@ -250,7 +247,7 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
 
     private static NodeBuilder getNodeIdBuilder(final RemoteDeviceId id) {
         final NodeBuilder nodeBuilder = new NodeBuilder();
-        nodeBuilder.setKey(new NodeKey(new NodeId(id.getName())));
+        nodeBuilder.withKey(new NodeKey(new NodeId(id.getName())));
         return nodeBuilder;
     }
 
index 6facc7d237001620181ac6cc006748e0b541f84b..19577f4f2490565f2849922adebbedf79893837b 100644 (file)
@@ -111,7 +111,7 @@ public class NetconfKeystoreAdapter implements ClusteredDataTreeChangeListener<K
         return keyStore;
     }
 
-    private java.security.PrivateKey getJavaPrivateKey(final String base64PrivateKey)
+    private static java.security.PrivateKey getJavaPrivateKey(final String base64PrivateKey)
             throws GeneralSecurityException {
         final byte[] encodedKey = base64Decode(base64PrivateKey);
         final PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey);
@@ -128,7 +128,7 @@ public class NetconfKeystoreAdapter implements ClusteredDataTreeChangeListener<K
         return key;
     }
 
-    private List<X509Certificate> getCertificateChain(final String[] base64Certificates)
+    private static List<X509Certificate> getCertificateChain(final String[] base64Certificates)
             throws GeneralSecurityException {
         final CertificateFactory factory = CertificateFactory.getInstance("X.509");
         final List<X509Certificate> certificates = new ArrayList<>();
@@ -141,7 +141,7 @@ public class NetconfKeystoreAdapter implements ClusteredDataTreeChangeListener<K
         return certificates;
     }
 
-    private byte[] base64Decode(final String base64) {
+    private static byte[] base64Decode(final String base64) {
         return Base64.getMimeDecoder().decode(base64.getBytes(java.nio.charset.StandardCharsets.US_ASCII));
     }
 
@@ -158,7 +158,7 @@ public class NetconfKeystoreAdapter implements ClusteredDataTreeChangeListener<K
 
                     pairs.clear();
                     if (dataAfter != null) {
-                        dataAfter.getKeyCredential().forEach(pair -> pairs.put(pair.getKey().getKeyId(), pair));
+                        dataAfter.getKeyCredential().forEach(pair -> pairs.put(pair.key().getKeyId(), pair));
                     }
                     break;
 
index 3c3b733a93840259262905120e5b64c8938f33f0..29d345287a28e542799d48c8ddb1064a4d4441d1 100644 (file)
@@ -137,13 +137,12 @@ public class NetconfSalKeystoreService implements NetconfKeystoreService {
 
         for (KeyCredential keypair : keypairs) {
             writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
-                    keystoreIid.child(KeyCredential.class, keypair.getKey()), keypair);
+                    keystoreIid.child(KeyCredential.class, keypair.key()), keypair);
         }
 
         final SettableFuture<RpcResult<AddKeystoreEntryOutput>> rpcResult = SettableFuture.create();
 
-        final ListenableFuture<Void> submit = writeTransaction.submit();
-        Futures.addCallback(submit, new FutureCallback<Void>() {
+        Futures.addCallback(writeTransaction.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(@Nullable final Void result) {
                 LOG.debug("add-key-pair success. Input: {}");
@@ -167,13 +166,12 @@ public class NetconfSalKeystoreService implements NetconfKeystoreService {
 
         for (TrustedCertificate certificate : input.getTrustedCertificate()) {
             writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
-                    keystoreIid.child(TrustedCertificate.class, certificate.getKey()), certificate);
+                    keystoreIid.child(TrustedCertificate.class, certificate.key()), certificate);
         }
 
         final SettableFuture<RpcResult<AddTrustedCertificateOutput>> rpcResult = SettableFuture.create();
 
-        final ListenableFuture<Void> submit = writeTransaction.submit();
-        Futures.addCallback(submit, new FutureCallback<Void>() {
+        Futures.addCallback(writeTransaction.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(@Nullable final Void result) {
                 LOG.debug("add-trusted-certificate success. Input: {}", input);
@@ -203,8 +201,7 @@ public class NetconfSalKeystoreService implements NetconfKeystoreService {
 
         final SettableFuture<RpcResult<RemoveTrustedCertificateOutput>> rpcResult = SettableFuture.create();
 
-        final ListenableFuture<Void> submit = writeTransaction.submit();
-        Futures.addCallback(submit, new FutureCallback<Void>() {
+        Futures.addCallback(writeTransaction.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(@Nullable final Void result) {
                 LOG.debug("remove-trusted-certificate success. Input: {}", input);
@@ -227,13 +224,12 @@ public class NetconfSalKeystoreService implements NetconfKeystoreService {
 
         for (PrivateKey key: input.getPrivateKey()) {
             writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
-                    keystoreIid.child(PrivateKey.class, key.getKey()), key);
+                    keystoreIid.child(PrivateKey.class, key.key()), key);
         }
 
         final SettableFuture<RpcResult<AddPrivateKeyOutput>> rpcResult = SettableFuture.create();
 
-        final ListenableFuture<Void> submit = writeTransaction.submit();
-        Futures.addCallback(submit, new FutureCallback<Void>() {
+        Futures.addCallback(writeTransaction.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(@Nullable final Void result) {
                 LOG.debug("add-private-key success. Input: {}", input);
@@ -262,8 +258,7 @@ public class NetconfSalKeystoreService implements NetconfKeystoreService {
 
         final SettableFuture<RpcResult<RemovePrivateKeyOutput>> rpcResult = SettableFuture.create();
 
-        final ListenableFuture<Void> submit = writeTransaction.submit();
-        Futures.addCallback(submit, new FutureCallback<Void>() {
+        Futures.addCallback(writeTransaction.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(@Nullable final Void result) {
                 LOG.debug("remove-private-key success. Input: {}", input);
index 727614f6b56adf33fdee75d47db2545166164643..a31bd083aaf09f843d5d36acbf3067adfb2e814d 100644 (file)
@@ -166,7 +166,7 @@ public class NetconfKeystoreAdapterTest {
             }
 
             final PrivateKey privateKey = new PrivateKeyBuilder()
-                    .setKey(new PrivateKeyKey(keyName))
+                    .withKey(new PrivateKeyKey(keyName))
                     .setName(keyName)
                     .setData(keyData)
                     .setCertificateChain(certChain)
@@ -191,7 +191,7 @@ public class NetconfKeystoreAdapterTest {
             final String certData = element.getElementsByTagName(XML_ELEMENT_CERT).item(0).getTextContent();
 
             final TrustedCertificate certificate = new TrustedCertificateBuilder()
-                    .setKey(new TrustedCertificateKey(certName))
+                    .withKey(new TrustedCertificateKey(certName))
                     .setName(certName)
                     .setCertificate(certData)
                     .build();
index 2b98e5050cfd7d1c14509f8b0bd2d224ebb1ae9d..1d85790b6befbf014fbb5a9e103f92811b5e2a0f 100644 (file)
@@ -114,7 +114,7 @@ public class NetconfSalKeystoreServiceTest {
             }
 
             final PrivateKey privateKey = new PrivateKeyBuilder()
-                    .setKey(new PrivateKeyKey(keyName))
+                    .withKey(new PrivateKeyKey(keyName))
                     .setName(keyName)
                     .setData(keyData)
                     .setCertificateChain(certChain)
@@ -139,7 +139,7 @@ public class NetconfSalKeystoreServiceTest {
             final String certData = element.getElementsByTagName(XML_ELEMENT_CERT).item(0).getTextContent();
 
             final TrustedCertificate certificate = new TrustedCertificateBuilder()
-                    .setKey(new TrustedCertificateKey(certName))
+                    .withKey(new TrustedCertificateKey(certName))
                     .setName(certName)
                     .setCertificate(certData)
                     .build();
index 53c89f1895d53129bb9a8a2f5d19acbb5dc8d076..a3aa411beaf1b016756f2b668ea88f187b541885 100644 (file)
@@ -46,14 +46,15 @@ public class DummyMonitoringService implements NetconfMonitoringService {
     private static final Function<Capability, Schema> CAPABILITY_SCHEMA_FUNCTION = new Function<Capability, Schema>() {
         @Nullable
         @Override
-        public Schema apply(@Nonnull Capability capability) {
+        public Schema apply(@Nonnull final Capability capability) {
             return new SchemaBuilder()
                     .setIdentifier(capability.getModuleName().get())
                     .setNamespace(new Uri(capability.getModuleNamespace().get()))
                     .setFormat(Yang.class)
                     .setVersion(capability.getRevision().get())
                     .setLocation(Collections.singletonList(new Location(Enumeration.NETCONF)))
-                    .setKey(new SchemaKey(Yang.class, capability.getModuleName().get(), capability.getRevision().get()))
+                    .withKey(new SchemaKey(Yang.class, capability.getModuleName().get(),
+                        capability.getRevision().get()))
                     .build();
         }
     };
@@ -62,7 +63,7 @@ public class DummyMonitoringService implements NetconfMonitoringService {
     private final ArrayListMultimap<String, Capability> capabilityMultiMap;
     private final Schemas schemas;
 
-    public DummyMonitoringService(Set<Capability> capabilities) {
+    public DummyMonitoringService(final Set<Capability> capabilities) {
 
         this.capabilities = new CapabilitiesBuilder().setCapability(
                 Lists.newArrayList(Collections2.transform(capabilities, CAPABILITY_URI_FUNCTION))).build();
@@ -89,17 +90,17 @@ public class DummyMonitoringService implements NetconfMonitoringService {
     public SessionListener getSessionListener() {
         return new SessionListener() {
             @Override
-            public void onSessionUp(NetconfManagementSession session) {
+            public void onSessionUp(final NetconfManagementSession session) {
                 //no op
             }
 
             @Override
-            public void onSessionDown(NetconfManagementSession session) {
+            public void onSessionDown(final NetconfManagementSession session) {
                 //no op
             }
 
             @Override
-            public void onSessionEvent(SessionEvent event) {
+            public void onSessionEvent(final SessionEvent event) {
                 //no op
             }
         };
@@ -111,7 +112,7 @@ public class DummyMonitoringService implements NetconfMonitoringService {
     }
 
     @Override
-    public String getSchemaForCapability(String moduleName, Optional<String> revision) {
+    public String getSchemaForCapability(final String moduleName, final Optional<String> revision) {
 
         for (Capability capability : capabilityMultiMap.get(moduleName)) {
             if (capability.getRevision().get().equals(revision.get())) {
@@ -128,12 +129,12 @@ public class DummyMonitoringService implements NetconfMonitoringService {
     }
 
     @Override
-    public AutoCloseable registerCapabilitiesListener(CapabilitiesListener listener) {
+    public AutoCloseable registerCapabilitiesListener(final CapabilitiesListener listener) {
         return null;
     }
 
     @Override
-    public AutoCloseable registerSessionsListener(SessionsListener listener) {
+    public AutoCloseable registerSessionsListener(final SessionsListener listener) {
         return null;
     }
 
index 52ede84d419fabb374cb53e57890f401b6ad2805..68c398876a2e54c6846640b912172228b897e931 100644 (file)
@@ -143,7 +143,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
         adapter.assertGot(getNotifJson(JSON_NOTIF_LEAVES_CREATE));
 
         writeTransaction = dataBroker.newWriteOnlyTransaction();
-        builder = new MyList1Builder().setKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
+        builder = new MyList1Builder().withKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
         writeTransaction.submit();
         adapter.assertGot(getNotifJson(JSON_NOTIF_LEAVES_UPDATE));
@@ -172,7 +172,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
         adapter.assertGot(getNotifJson(JSON_NOTIF_CREATE));
 
         writeTransaction = dataBroker.newWriteOnlyTransaction();
-        builder = new MyList1Builder().setKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
+        builder = new MyList1Builder().withKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
         writeTransaction.submit();
         adapter.assertGot(getNotifJson(JSON_NOTIF_UPDATE));
index 5d1d3353800486bc92546339475a8c14e533273f..a1cb417bdf8ead090e2f88aab8dd605708284053 100644 (file)
@@ -148,7 +148,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
         adapter.assertGot(getNotifJson(JSON_NOTIF_LEAVES_CREATE));
 
         writeTransaction = dataBroker.newWriteOnlyTransaction();
-        builder = new MyList1Builder().setKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
+        builder = new MyList1Builder().withKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
         writeTransaction.submit();
         adapter.assertGot(getNotifJson(JSON_NOTIF_LEAVES_UPDATE));
@@ -179,7 +179,7 @@ public class ListenerAdapterTest extends AbstractConcurrentDataBrokerTest {
         adapter.assertGot(getNotifJson(JSON_NOTIF_CREATE));
 
         writeTransaction = dataBroker.newWriteOnlyTransaction();
-        builder = new MyList1Builder().setKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
+        builder = new MyList1Builder().withKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
         writeTransaction.submit();
         adapter.assertGot(getNotifJson(JSON_NOTIF_UPDATE));