Reduce JSR305 proliferation
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / md / sal / binding / api / DataTreeIdentifier.java
index c1c23d5e6fc7d3d17f24c9a7613375fb6b4881e3..94e1f8bfcb223329507de23cbfb05c48bbbf2204 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.md.sal.binding.api;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.Serializable;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.concepts.Path;
@@ -20,14 +21,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  * A unique identifier for a particular subtree. It is composed of the logical
  * data store type and the instance identifier of the root node.
  */
-public final class DataTreeIdentifier<T extends DataObject> implements Immutable, Path<DataTreeIdentifier<?>>, Serializable {
+public final class DataTreeIdentifier<T extends DataObject> implements Immutable,
+        Path<DataTreeIdentifier<?>>, Serializable {
     private static final long serialVersionUID = 1L;
-    private final InstanceIdentifier<T> rootIdentifier;
-    private final LogicalDatastoreType datastoreType;
+
+    private final @NonNull InstanceIdentifier<T> rootIdentifier;
+    private final @NonNull LogicalDatastoreType datastoreType;
 
     public DataTreeIdentifier(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> rootIdentifier) {
-        this.datastoreType = Preconditions.checkNotNull(datastoreType);
-        this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier);
+        this.datastoreType = requireNonNull(datastoreType);
+        this.rootIdentifier = requireNonNull(rootIdentifier);
     }
 
     /**
@@ -35,16 +38,16 @@ public final class DataTreeIdentifier<T extends DataObject> implements Immutable
      *
      * @return Logical data store type. Guaranteed to be non-null.
      */
-    public @Nonnull LogicalDatastoreType getDatastoreType() {
+    public @NonNull LogicalDatastoreType getDatastoreType() {
         return datastoreType;
     }
 
     /**
-     * Return the {@link YangInstanceIdentifier} of the root node.
+     * Return the {@link InstanceIdentifier} of the root node.
      *
      * @return Instance identifier corresponding to the root node.
      */
-    public @Nonnull InstanceIdentifier<?> getRootIdentifier() {
+    public @NonNull InstanceIdentifier<T> getRootIdentifier() {
         return rootIdentifier;
     }
 
@@ -76,4 +79,10 @@ public final class DataTreeIdentifier<T extends DataObject> implements Immutable
         }
         return rootIdentifier.equals(other.rootIdentifier);
     }
-}
\ No newline at end of file
+
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + "{datastoreType = " + datastoreType + ", rootIdentifier = "
+                + rootIdentifier + "}";
+    }
+}