Fixed Checkstyle violation errors in mdsal-dom-api module
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMRpcIdentifier.java
index 2c948e66bdac4243be1b241385cea818dd8a1ee8..c5e4fce87c7f5ab5a7408356e5d610213fb0d5dd 100644 (file)
@@ -9,12 +9,10 @@ package org.opendaylight.mdsal.dom.api;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
-import java.util.Collections;
 import java.util.Objects;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 /**
@@ -24,9 +22,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
  * contexts concurrently.
  */
 public abstract class DOMRpcIdentifier {
-
-    private static final YangInstanceIdentifier GLOBAL_CONTEXT = YangInstanceIdentifier.create(Collections.<PathArgument>emptySet());
-
     private static final class Global extends DOMRpcIdentifier {
         private Global(final @Nonnull SchemaPath type) {
             super(type);
@@ -34,7 +29,7 @@ public abstract class DOMRpcIdentifier {
 
         @Override
         public YangInstanceIdentifier getContextReference() {
-            return GLOBAL_CONTEXT;
+            return YangInstanceIdentifier.EMPTY;
         }
     }
 
@@ -75,8 +70,9 @@ public abstract class DOMRpcIdentifier {
      * @param contextReference Context reference, null means a global RPC identifier.
      * @return A global RPC identifier, guaranteed to be non-null.
      */
-    public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type, final @Nullable YangInstanceIdentifier contextReference) {
-        if (contextReference == null || GLOBAL_CONTEXT.equals(contextReference)) {
+    public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type,
+            final @Nullable YangInstanceIdentifier contextReference) {
+        if (contextReference == null || contextReference.isEmpty()) {
             return new Global(type);
         } else {
             return new Local(type, contextReference);
@@ -125,6 +121,7 @@ public abstract class DOMRpcIdentifier {
 
     @Override
     public final String toString() {
-        return MoreObjects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference", getContextReference()).toString();
+        return MoreObjects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference",
+                getContextReference()).toString();
     }
 }