Modernize YangLibRestApp 91/103991/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Jan 2023 17:28:27 +0000 (18:28 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Jan 2023 17:29:58 +0000 (18:29 +0100)
Use Set.of() and make sure the service is not null.

Change-Id: I63c3feb978344ad08d794c3441890bfecb36d5cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibRestApp.java

index 946f8d1a59cd4563109918ad2f3a9c7ab366b022..51f6366897a34e11816f36daa80e4f0b35871a1e 100644 (file)
@@ -5,10 +5,10 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yanglib.impl;
 
-import java.util.Collections;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Set;
 import javax.ws.rs.core.Application;
 import org.opendaylight.yanglib.api.YangLibService;
@@ -16,12 +16,12 @@ import org.opendaylight.yanglib.api.YangLibService;
 public class YangLibRestApp extends Application {
     private final YangLibService yangLibService;
 
-    public YangLibRestApp(YangLibService yangLibService) {
-        this.yangLibService = yangLibService;
+    public YangLibRestApp(final YangLibService yangLibService) {
+        this.yangLibService = requireNonNull(yangLibService);
     }
 
     @Override
     public Set<Object> getSingletons() {
-        return Collections.singleton(this.yangLibService);
+        return Set.of(yangLibService);
     }
 }