Specialize JSONCodec to JSONValueWriter
[yangtools.git] / common / util / src / main / java / org / opendaylight / yangtools / util / AbstractIdentifier.java
index dbe5ca69ef815fffb4c8afbc696a3d78dab4d06c..133dcb019f2168adb74620ddd699b310ae2ec60b 100644 (file)
@@ -7,28 +7,29 @@
  */
 package org.opendaylight.yangtools.util;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Identifier;
 
 /**
  * An abstract {@link Identifier} backed by an immutable object. Subclasses have no control over {@link #hashCode()}
  * and {@link #equals(Object)}, hence they should not add any fields.
  *
- * @author Robert Varga
- *
  * @param <T> Object type
  */
 public abstract class AbstractIdentifier<T> implements Identifier {
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
-    private final T value;
+    private final @NonNull T value;
 
-    public AbstractIdentifier(final T value) {
-        this.value = Preconditions.checkNotNull(value);
+    public AbstractIdentifier(final @NonNull T value) {
+        this.value = requireNonNull(value);
     }
 
-    public final T getValue() {
+    protected final @NonNull T getValue() {
         return value;
     }
 
@@ -38,19 +39,15 @@ public abstract class AbstractIdentifier<T> implements Identifier {
     }
 
     @Override
-    public final boolean equals(final Object o) {
-        if (this == o) {
+    public final boolean equals(final Object obj) {
+        if (this == obj) {
             return true;
         }
-        if (o == null) {
-            return false;
-        }
-
-        return getClass().equals(o.getClass()) && value.equals(((AbstractIdentifier<?>)o).value);
+        return obj != null && getClass().equals(obj.getClass()) && value.equals(((AbstractIdentifier<?>)obj).value);
     }
 
     @Override
-    public final String toString() {
+    public final @NonNull String toString() {
         return MoreObjects.toStringHelper(this).add("value", value).toString();
     }
 }