YangResource should be a record 71/108471/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 17 Oct 2023 08:41:32 +0000 (10:41 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 17 Oct 2023 08:41:32 +0000 (10:41 +0200)
This is a trivial data holder, convert it to a record.

Change-Id: If98bc2f8865ea8658aca707d01b6eae3b275331e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/config/YangResource.java

index b40938347f4baa844b8fa542fe930a54222dbeb5..61fb0d0bc75a015304ba5efc8ffb6226b6843298 100644 (file)
@@ -87,8 +87,8 @@ public class NetconfDeviceSimulator implements Closeable {
 
     public NetconfDeviceSimulator(final Configuration configuration) {
         this.configuration = configuration;
-        this.servers = new ArrayList<>(configuration.getDeviceCount());
-        this.sshTransportStackFactory = new SSHTransportStackFactory("netconf-device-simulator-threads",
+        servers = new ArrayList<>(configuration.getDeviceCount());
+        sshTransportStackFactory = new SSHTransportStackFactory("netconf-device-simulator-threads",
             configuration.getThreadPoolSize());
         hashedWheelTimer = new HashedWheelTimer();
     }
@@ -271,8 +271,7 @@ public class NetconfDeviceSimulator implements Closeable {
         }
 
         configuration.getDefaultYangResources().forEach(r -> {
-            final SourceIdentifier sourceIdentifier = new SourceIdentifier(r.getModuleName(), r.getRevision());
-            registerSource(consumer, r.getResourcePath(), sourceIdentifier);
+            registerSource(consumer, r.resourcePath(), new SourceIdentifier(r.moduleName(), r.revision()));
         });
 
         try {
index 0893be4350b5e9095c26cc0d6b49ef9d7795baad..6cd02a5323fcd32285d3ac6561bf98fbe458aa9d 100644 (file)
@@ -7,49 +7,6 @@
  */
 package org.opendaylight.netconf.test.tool.config;
 
-import java.util.Objects;
-
-public class YangResource {
-
-    private final String moduleName;
-    private final String revision;
-    private final String resourcePath;
-
-    public YangResource(String moduleName, String revision, String resourcePath) {
-        this.moduleName = moduleName;
-        this.revision = revision;
-        this.resourcePath = resourcePath;
-    }
-
-    public String getModuleName() {
-        return moduleName;
-    }
-
-    public String getRevision() {
-        return revision;
-    }
-
-    public String getResourcePath() {
-        return resourcePath;
-    }
-
-    @Override
-    public boolean equals(Object object) {
-        if (this == object) {
-            return true;
-        }
-        if (object == null || getClass() != object.getClass()) {
-            return false;
-        }
-        YangResource that = (YangResource) object;
-        return Objects.equals(moduleName, that.moduleName)
-                && Objects.equals(revision, that.revision)
-                && Objects.equals(resourcePath, that.resourcePath);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(moduleName, revision, resourcePath);
-    }
-
+public record YangResource(String moduleName, String revision, String resourcePath) {
+    // Nothing else
 }