ServiceGroupIdentifier should be a record
[mdsal.git] / singleton-service / mdsal-singleton-common-api / src / main / java / org / opendaylight / mdsal / singleton / common / api / ServiceGroupIdentifier.java
index 0a7ca41f827c7e933de05a89a4c39cebbfb497bc..1e2aa4659dd3b6f4641ce40d8f28a61ddd5832a0 100644 (file)
@@ -7,32 +7,21 @@
  */
 package org.opendaylight.mdsal.singleton.common.api;
 
-import java.io.Serial;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.util.AbstractStringIdentifier;
+import org.opendaylight.yangtools.concepts.Identifier;
 
 /**
- * Identifier represents a service group competence. It's based on String.
+ * An {@link Identifier} of a group of {@link ClusterSingletonService}s.
+ *
+ * @param value String value, must not be {@link String#isBlank()}
  */
-public class ServiceGroupIdentifier extends AbstractStringIdentifier<ServiceGroupIdentifier> {
-    @Serial
-    private static final long serialVersionUID = 6853612584804702662L;
-
-    protected ServiceGroupIdentifier(final @NonNull String string) {
-        super(string);
-    }
-
-    /**
-     * Method to create immutable instances of {@link ServiceGroupIdentifier}.
-     *
-     * @param name the String identifier for the ServiceGroupIdentifier instance
-     * @return {@link ServiceGroupIdentifier} new instance
-     */
-    public static @NonNull ServiceGroupIdentifier create(final String name) {
-        return new ServiceGroupIdentifier(name);
-    }
+public record ServiceGroupIdentifier(@NonNull String value) implements Identifier {
+    @java.io.Serial
+    private static final long serialVersionUID = 1L;
 
-    public final @NonNull String getName() {
-        return getValue();
+    public ServiceGroupIdentifier {
+        if (value.isBlank()) {
+            throw new IllegalArgumentException("Value must not be blank");
+        }
     }
 }